Skip to content

Commit e64b011

Browse files
committed
Merge branch '0.13' into 0.13.10
2 parents 3958511 + 14dcca6 commit e64b011

File tree

5 files changed

+42
-15
lines changed

5 files changed

+42
-15
lines changed

compile/interface/src/main/scala/xsbt/Compat.scala

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,10 @@ abstract class Compat {
4545
val Nullary = global.NullaryMethodType
4646
val ScalaObjectClass = definitions.ScalaObjectClass
4747

48-
// `afterPostErasure` doesn't exist in Scala < 2.10
49-
implicit def withAfterPostErasure(global: Global): WithAfterPostErasure = new WithAfterPostErasure(global)
50-
class WithAfterPostErasure(global: Global) {
51-
def afterPostErasure[T](op: => T): T = op
52-
}
53-
// `exitingPostErasure` was called `afterPostErasure` in 2.10
54-
implicit def withExitingPostErasure(global: Global): WithExitingPostErasure = new WithExitingPostErasure(global)
55-
class WithExitingPostErasure(global: Global) {
56-
def exitingPostErasure[T](op: => T): T = global afterPostErasure op
48+
// `transformedType` doesn't exist in Scala < 2.10
49+
implicit def withTransformedType(global: Global): WithTransformedType = new WithTransformedType(global)
50+
class WithTransformedType(global: Global) {
51+
def transformedType(tpe: Type): Type = tpe
5752
}
5853

5954
private[this] final class MiscCompat {

compile/interface/src/main/scala/xsbt/ExtractAPI.scala

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -225,10 +225,10 @@ class ExtractAPI[GlobalType <: CallbackGlobal](val global: GlobalType,
225225

226226
def build(t: Type, typeParams: Array[xsbti.api.TypeParameter], valueParameters: List[xsbti.api.ParameterList]): List[xsbti.api.Def] =
227227
{
228-
def parameterList(syms: List[Symbol]): xsbti.api.ParameterList =
228+
def parameterList(syms: List[Symbol], erase: Boolean = false): xsbti.api.ParameterList =
229229
{
230230
val isImplicitList = syms match { case head :: _ => isImplicit(head); case _ => false }
231-
new xsbti.api.ParameterList(syms.map(parameterS).toArray, isImplicitList)
231+
new xsbti.api.ParameterList(syms.map(parameterS(erase)).toArray, isImplicitList)
232232
}
233233
t match {
234234
case PolyType(typeParams0, base) =>
@@ -249,7 +249,7 @@ class ExtractAPI[GlobalType <: CallbackGlobal](val global: GlobalType,
249249
build(resultType, typeParams, parameterList(params) :: valueParameters)
250250
val afterErasure =
251251
if (inspectPostErasure)
252-
build(resultType, typeParams, global exitingPostErasure (parameterList(mType.params) :: valueParameters))
252+
build(resultType, typeParams, parameterList(mType.params, erase = true) :: valueParameters)
253253
else
254254
Nil
255255

@@ -277,7 +277,7 @@ class ExtractAPI[GlobalType <: CallbackGlobal](val global: GlobalType,
277277
val beforeErasure = makeDef(processType(in, dropConst(returnType)))
278278
val afterErasure =
279279
if (inspectPostErasure) {
280-
val erasedReturn = dropConst(global exitingPostErasure viewer(in).memberInfo(s)) map {
280+
val erasedReturn = dropConst(global.transformedType(viewer(in).memberInfo(s))) map {
281281
case MethodType(_, r) => r
282282
case other => other
283283
}
@@ -287,8 +287,10 @@ class ExtractAPI[GlobalType <: CallbackGlobal](val global: GlobalType,
287287
beforeErasure :: afterErasure
288288
}
289289
}
290-
def parameterS(s: Symbol): xsbti.api.MethodParameter =
291-
makeParameter(simpleName(s), s.info, s.info.typeSymbol, s)
290+
def parameterS(erase: Boolean)(s: Symbol): xsbti.api.MethodParameter = {
291+
val tp = if (erase) global.transformedType(s.info) else s.info
292+
makeParameter(simpleName(s), tp, tp.typeSymbol, s)
293+
}
292294

293295
// paramSym is only for 2.8 and is to determine if the parameter has a default
294296
def makeParameter(name: String, tpe: Type, ts: Symbol, paramSym: Symbol): xsbti.api.MethodParameter =
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package example
2+
3+
class A {
4+
case class B(x: Int)
5+
def c = B
6+
}
7+
object A {
8+
def main(args: Array[String]): Unit = {
9+
(new A).c
10+
}
11+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package example
2+
3+
class VC(val self: Int) extends AnyVal
4+
5+
class A {
6+
case class B(x: VC)
7+
def c = B
8+
}
9+
object A {
10+
def main(args: Array[String]): Unit = {
11+
(new A).c
12+
}
13+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
$ copy-file changes/A0.scala A.scala
2+
> run
3+
4+
# The same test case, but involving value classes
5+
$ copy-file changes/A1.scala A.scala
6+
> run

0 commit comments

Comments
 (0)