diff --git a/compile/interface/src/main/scala/xsbt/Compat.scala b/compile/interface/src/main/scala/xsbt/Compat.scala index 5b8c3983b..9f9fb247c 100644 --- a/compile/interface/src/main/scala/xsbt/Compat.scala +++ b/compile/interface/src/main/scala/xsbt/Compat.scala @@ -45,15 +45,10 @@ abstract class Compat { val Nullary = global.NullaryMethodType val ScalaObjectClass = definitions.ScalaObjectClass - // `afterPostErasure` doesn't exist in Scala < 2.10 - implicit def withAfterPostErasure(global: Global): WithAfterPostErasure = new WithAfterPostErasure(global) - class WithAfterPostErasure(global: Global) { - def afterPostErasure[T](op: => T): T = op - } - // `exitingPostErasure` was called `afterPostErasure` in 2.10 - implicit def withExitingPostErasure(global: Global): WithExitingPostErasure = new WithExitingPostErasure(global) - class WithExitingPostErasure(global: Global) { - def exitingPostErasure[T](op: => T): T = global afterPostErasure op + // `transformedType` doesn't exist in Scala < 2.10 + implicit def withTransformedType(global: Global): WithTransformedType = new WithTransformedType(global) + class WithTransformedType(global: Global) { + def transformedType(tpe: Type): Type = tpe } private[this] final class MiscCompat { diff --git a/compile/interface/src/main/scala/xsbt/ExtractAPI.scala b/compile/interface/src/main/scala/xsbt/ExtractAPI.scala index 172f8f090..31389218b 100644 --- a/compile/interface/src/main/scala/xsbt/ExtractAPI.scala +++ b/compile/interface/src/main/scala/xsbt/ExtractAPI.scala @@ -225,10 +225,10 @@ class ExtractAPI[GlobalType <: CallbackGlobal](val global: GlobalType, def build(t: Type, typeParams: Array[xsbti.api.TypeParameter], valueParameters: List[xsbti.api.ParameterList]): List[xsbti.api.Def] = { - def parameterList(syms: List[Symbol]): xsbti.api.ParameterList = + def parameterList(syms: List[Symbol], erase: Boolean = false): xsbti.api.ParameterList = { val isImplicitList = syms match { case head :: _ => isImplicit(head); case _ => false } - new xsbti.api.ParameterList(syms.map(parameterS).toArray, isImplicitList) + new xsbti.api.ParameterList(syms.map(parameterS(erase)).toArray, isImplicitList) } t match { case PolyType(typeParams0, base) => @@ -249,7 +249,7 @@ class ExtractAPI[GlobalType <: CallbackGlobal](val global: GlobalType, build(resultType, typeParams, parameterList(params) :: valueParameters) val afterErasure = if (inspectPostErasure) - build(resultType, typeParams, global exitingPostErasure (parameterList(mType.params) :: valueParameters)) + build(resultType, typeParams, parameterList(mType.params, erase = true) :: valueParameters) else Nil @@ -277,7 +277,7 @@ class ExtractAPI[GlobalType <: CallbackGlobal](val global: GlobalType, val beforeErasure = makeDef(processType(in, dropConst(returnType))) val afterErasure = if (inspectPostErasure) { - val erasedReturn = dropConst(global exitingPostErasure viewer(in).memberInfo(s)) map { + val erasedReturn = dropConst(global.transformedType(viewer(in).memberInfo(s))) map { case MethodType(_, r) => r case other => other } @@ -287,8 +287,10 @@ class ExtractAPI[GlobalType <: CallbackGlobal](val global: GlobalType, beforeErasure :: afterErasure } } - def parameterS(s: Symbol): xsbti.api.MethodParameter = - makeParameter(simpleName(s), s.info, s.info.typeSymbol, s) + def parameterS(erase: Boolean)(s: Symbol): xsbti.api.MethodParameter = { + val tp = if (erase) global.transformedType(s.info) else s.info + makeParameter(simpleName(s), tp, tp.typeSymbol, s) + } // paramSym is only for 2.8 and is to determine if the parameter has a default def makeParameter(name: String, tpe: Type, ts: Symbol, paramSym: Symbol): xsbti.api.MethodParameter = diff --git a/sbt/src/sbt-test/source-dependencies/nested-case-class/changes/A0.scala b/sbt/src/sbt-test/source-dependencies/nested-case-class/changes/A0.scala new file mode 100644 index 000000000..cc6a53b6a --- /dev/null +++ b/sbt/src/sbt-test/source-dependencies/nested-case-class/changes/A0.scala @@ -0,0 +1,11 @@ +package example + +class A { + case class B(x: Int) + def c = B +} +object A { + def main(args: Array[String]): Unit = { + (new A).c + } +} diff --git a/sbt/src/sbt-test/source-dependencies/nested-case-class/changes/A1.scala b/sbt/src/sbt-test/source-dependencies/nested-case-class/changes/A1.scala new file mode 100644 index 000000000..e71b1ef17 --- /dev/null +++ b/sbt/src/sbt-test/source-dependencies/nested-case-class/changes/A1.scala @@ -0,0 +1,13 @@ +package example + +class VC(val self: Int) extends AnyVal + +class A { + case class B(x: VC) + def c = B +} +object A { + def main(args: Array[String]): Unit = { + (new A).c + } +} \ No newline at end of file diff --git a/sbt/src/sbt-test/source-dependencies/nested-case-class/test b/sbt/src/sbt-test/source-dependencies/nested-case-class/test new file mode 100644 index 000000000..28ed70321 --- /dev/null +++ b/sbt/src/sbt-test/source-dependencies/nested-case-class/test @@ -0,0 +1,6 @@ +$ copy-file changes/A0.scala A.scala +> run + +# The same test case, but involving value classes +$ copy-file changes/A1.scala A.scala +> run