From f5e7fdd62af3bf5374b4f4d602c1b5ff7ec4d20b Mon Sep 17 00:00:00 2001 From: Martin Duhem Date: Mon, 9 Nov 2015 16:30:11 +0100 Subject: [PATCH] Restore source compatibility with Scala 2.8 --- .../src/main/scala/xsbt/ExtractAPI.scala | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/compile/interface/src/main/scala/xsbt/ExtractAPI.scala b/compile/interface/src/main/scala/xsbt/ExtractAPI.scala index b3227376d..7309aeeb9 100644 --- a/compile/interface/src/main/scala/xsbt/ExtractAPI.scala +++ b/compile/interface/src/main/scala/xsbt/ExtractAPI.scala @@ -183,16 +183,26 @@ class ExtractAPI[GlobalType <: CallbackGlobal](val global: GlobalType, { import MirrorHelper._ - // Here we must be careful to also consider the type parameters, because a tuple (Foo, Int) - // may become (Int, Int) for instance. - def hasValueClassAsParameter(meth: MethodSymbol): Boolean = - meth.paramss.flatten map (_.info) exists (t => isAnyValSubtype(t.typeSymbol)) + val hasValueClassAsParameter: Boolean = { + import MirrorHelper._ + s.asMethod.paramss.flatten map (_.info) exists (t => isAnyValSubtype(t.typeSymbol)) + } - // Here too we must care for the type parameters (see above comment). - def hasValueClassAsReturnType(meth: MethodSymbol): Boolean = - isAnyValSubtype(meth.returnType.typeSymbol) + // Note: We only inspect the "outermost type" (i.e. no recursion) because we don't need to + // inspect after erasure a function that would, for instance, return a function that returns + // a subtype of AnyVal. + val hasValueClassAsReturnType: Boolean = { + val tpe = viewer(in).memberInfo(s) + tpe match { + case PolyType(_, base) => isAnyValSubtype(base.typeSymbol) + case MethodType(_, resultType) => isAnyValSubtype(resultType.typeSymbol) + case Nullary(resultType) => isAnyValSubtype(resultType.typeSymbol) + case resultType => isAnyValSubtype(resultType.typeSymbol) + } + } + + val inspectPostErasure = hasValueClassAsParameter || hasValueClassAsReturnType - val inspectPostErasure = hasValueClassAsParameter(s.asMethod) || hasValueClassAsReturnType(s.asMethod) 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 =