Don't inspect signatures post erasure if macros are involved

This commit is contained in:
Martin Duhem 2015-11-04 17:44:52 +01:00
parent 111511dc6d
commit 9764b7f6ef
1 changed files with 23 additions and 12 deletions

View File

@ -180,6 +180,11 @@ class ExtractAPI[GlobalType <: CallbackGlobal](val global: GlobalType,
private def printMember(label: String, in: Symbol, t: Type) = println(label + " in " + in + " : " + t + " (debug: " + debugString(t) + " )")
private def defDef(in: Symbol, s: Symbol): List[xsbti.api.Def] =
{
def isMacro(sym: Symbol): Boolean =
sym.isMacro || (sym.info.members.sorted exists isMacro) || (sym.children exists isMacro)
//sym.isMacro || (sym.children exists isMacro) || (sym.isType && sym.asType.toType.members.sorted.exists(isMacro))
val inspectPostErasure = !isMacro(in.enclosingTopLevelClass)
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 =
@ -202,10 +207,15 @@ class ExtractAPI[GlobalType <: CallbackGlobal](val global: GlobalType,
// <- has type (I)I after erasure
// If we change A from value class to normal class, we need to recompile all clients
// of def foo.
val beforeErasure = parameterList(params) :: valueParameters
val afterErasure = global exitingPostErasure (parameterList(mType.params) :: valueParameters)
val beforeErasure =
build(resultType, typeParams, parameterList(params) :: valueParameters)
val afterErasure =
if (inspectPostErasure)
build(resultType, typeParams, global exitingPostErasure (parameterList(mType.params) :: valueParameters))
else
Nil
build(resultType, typeParams, beforeErasure) ++ build(resultType, typeParams, afterErasure)
beforeErasure ++ afterErasure
case Nullary(resultType) => // 2.9 and later
build(resultType, typeParams, valueParameters)
case returnType =>
@ -226,16 +236,17 @@ class ExtractAPI[GlobalType <: CallbackGlobal](val global: GlobalType,
// <- has type (I)I after erasure
// If we change A from value class to normal class, we need to recompile all clients
// of def foo.
val beforeErasure = processType(in, dropConst(returnType))
val afterErasure = {
val erasedReturn = dropConst(global exitingPostErasure viewer(in).memberInfo(s)) map {
case MethodType(_, r) => r
case other => other
}
processType(in, erasedReturn)
}
val beforeErasure = makeDef(processType(in, dropConst(returnType)))
val afterErasure =
if (inspectPostErasure) {
val erasedReturn = dropConst(global exitingPostErasure viewer(in).memberInfo(s)) map {
case MethodType(_, r) => r
case other => other
}
List(makeDef(processType(in, erasedReturn)))
} else Nil
makeDef(beforeErasure) :: makeDef(afterErasure) :: Nil
beforeErasure :: afterErasure
}
}
def parameterS(s: Symbol): xsbti.api.MethodParameter =