mirror of https://github.com/sbt/sbt.git
compiler interface: 2.9 compatibility
nme.LOCALCHILD -> tpename.LOCAL_CHILD handle NullaryMethodType
This commit is contained in:
parent
28d0b36b43
commit
2a4f7ac564
|
|
@ -17,7 +17,9 @@ object API
|
|||
// for 2.7 compatibility: this class was removed in 2.8
|
||||
type ImplicitMethodType = AnyRef
|
||||
}
|
||||
import API._ // imports ImplicitMethodType, which will preserve source compatibility in 2.7 for defDef
|
||||
// imports ImplicitMethodType, which will preserve source compatibility in 2.7 for defDef
|
||||
import API._
|
||||
|
||||
final class API(val global: Global, val callback: xsbti.AnalysisCallback) extends Compat
|
||||
{
|
||||
import global._
|
||||
|
|
@ -161,6 +163,8 @@ final class API(val global: Global, val callback: xsbti.AnalysisCallback) extend
|
|||
build(base, typeParameters(in, typeParams0), Nil)
|
||||
case MethodType(params, resultType) => // in 2.7, params is of type List[Type], in 2.8 it is List[Symbol]
|
||||
build(resultType, typeParams, (params: xsbti.api.ParameterList) :: valueParameters)
|
||||
case Nullary(resultType) => // 2.9 and later
|
||||
build(resultType, typeParams, valueParameters)
|
||||
case returnType =>
|
||||
new xsbti.api.Def(valueParameters.reverse.toArray, processType(in, returnType), typeParams, simpleName(s), getAccess(s), getModifiers(s), annotations(in,s))
|
||||
}
|
||||
|
|
@ -196,9 +200,13 @@ final class API(val global: Global, val callback: xsbti.AnalysisCallback) extend
|
|||
}
|
||||
private def fieldDef[T](in: Symbol, s: Symbol, create: (xsbti.api.Type, String, xsbti.api.Access, xsbti.api.Modifiers, Array[xsbti.api.Annotation]) => T): T =
|
||||
{
|
||||
val t = viewer(in).memberType(s)
|
||||
val t = dropNullary(viewer(in).memberType(s))
|
||||
create(processType(in, t), simpleName(s), getAccess(s), getModifiers(s), annotations(in, s))
|
||||
}
|
||||
private def dropNullary(t: Type): Type = t match {
|
||||
case Nullary(un) => un
|
||||
case _ => t
|
||||
}
|
||||
|
||||
private def typeDef(in: Symbol, s: Symbol): xsbti.api.TypeMember =
|
||||
{
|
||||
|
|
@ -262,7 +270,7 @@ final class API(val global: Global, val callback: xsbti.AnalysisCallback) extend
|
|||
None
|
||||
}
|
||||
private def ignoreClass(sym: Symbol): Boolean =
|
||||
sym.isLocalClass || sym.isAnonymousClass || fullName(sym).endsWith(nme.LOCALCHILD)
|
||||
sym.isLocalClass || sym.isAnonymousClass || fullName(sym).endsWith(LocalChild)
|
||||
|
||||
// This filters private[this] vals/vars that were not in the original source.
|
||||
// The getter will be used for processing instead.
|
||||
|
|
@ -314,6 +322,7 @@ final class API(val global: Global, val callback: xsbti.AnalysisCallback) extend
|
|||
case ExistentialType(tparams, result) => new xsbti.api.Existential(processType(in, result), typeParameters(in, tparams))
|
||||
case NoType => error("NoType")
|
||||
case PolyType(typeParams, resultType) => new xsbti.api.Polymorphic(processType(in, resultType), typeParameters(in, typeParams))
|
||||
case Nullary(resultType) => error("Unexpected nullary method type " + in + " in " + in.owner)
|
||||
case _ => error("Unhandled type " + t.getClass + " : " + t)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -154,13 +154,15 @@ abstract class Compat
|
|||
def nameString(s: Symbol, sep: Char): String = s.fullNameString(sep)
|
||||
def isExistential(s: Symbol): Boolean = s.isExistential
|
||||
def isNonClassType(s: Symbol): Boolean = s.isTypeMember
|
||||
val LocalChild = global.tpnme.LOCAL_CHILD
|
||||
val Nullary = global.NullaryMethodType
|
||||
|
||||
def linkedClass(s: Symbol): Symbol = s.linkedClassOfModule
|
||||
|
||||
/** After 2.8.0.Beta1, fullNameString was renamed fullName.
|
||||
* linkedClassOfModule was renamed companionClass. */
|
||||
private implicit def symCompat(sym: Symbol): SymCompat = new SymCompat(sym)
|
||||
private final class SymCompat(s: Symbol)
|
||||
private[this] implicit def symCompat(sym: Symbol): SymCompat = new SymCompat(sym)
|
||||
private[this] final class SymCompat(s: Symbol)
|
||||
{
|
||||
def fullNameString = s.fullName; def fullName = sourceCompatibilityOnly
|
||||
def fullNameString(sep: Char) = s.fullName(sep); def fullName(sep: Char) = sourceCompatibilityOnly
|
||||
|
|
@ -172,14 +174,29 @@ abstract class Compat
|
|||
// In 2.8, hasAttribute is renamed to hasAnnotation
|
||||
def hasAnnotation(a: Symbol) = s.hasAttribute(a); def hasAttribute(a: Symbol) = sourceCompatibilityOnly
|
||||
}
|
||||
private[this] final class MiscCompat
|
||||
{
|
||||
// in 2.9, nme.LOCALCHILD was renamed to tpnme.LOCAL_CHILD
|
||||
def tpnme = nme
|
||||
def LOCAL_CHILD = nme.LOCALCHILD
|
||||
def LOCALCHILD = sourceCompatibilityOnly
|
||||
|
||||
def hasAnnotation(s: Symbol)(ann: Symbol) = atPhase(currentRun.typerPhase) { s.hasAnnotation(ann) }
|
||||
def NullaryMethodType = NullaryMethodTpe
|
||||
}
|
||||
// in 2.9, NullaryMethodType was added to Type
|
||||
object NullaryMethodTpe {
|
||||
def unapply(t: Type): Option[Type] = None
|
||||
}
|
||||
|
||||
final def hasAnnotation(s: Symbol)(ann: Symbol) = atPhase(currentRun.typerPhase) { s.hasAnnotation(ann) }
|
||||
|
||||
/** After 2.8.0.Beta1, getArchive was renamed archive.*/
|
||||
private implicit def zipCompat(z: ZipArchive#Entry): ZipCompat = new ZipCompat(z)
|
||||
private final class ZipCompat(z: ZipArchive#Entry)
|
||||
private[this] implicit def zipCompat(z: ZipArchive#Entry): ZipCompat = new ZipCompat(z)
|
||||
private[this] final class ZipCompat(z: ZipArchive#Entry)
|
||||
{
|
||||
def getArchive = z.archive; def archive = sourceCompatibilityOnly
|
||||
}
|
||||
private def sourceCompatibilityOnly: Nothing = throw new RuntimeException("For source compatibility only: should not get here.")
|
||||
private[this] def sourceCompatibilityOnly: Nothing = throw new RuntimeException("For source compatibility only: should not get here.")
|
||||
|
||||
private[this] final implicit def miscCompat(n: AnyRef): MiscCompat = new MiscCompat
|
||||
}
|
||||
Loading…
Reference in New Issue