summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/transform/Delambdafy.scala2
-rw-r--r--src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala10
-rw-r--r--src/reflect/scala/reflect/api/Internals.scala174
-rw-r--r--src/reflect/scala/reflect/api/Trees.scala48
-rw-r--r--src/reflect/scala/reflect/api/Types.scala56
-rw-r--r--src/reflect/scala/reflect/internal/Trees.scala110
6 files changed, 175 insertions, 225 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/Delambdafy.scala b/src/compiler/scala/tools/nsc/transform/Delambdafy.scala
index 818d0767b9..1468680fe0 100644
--- a/src/compiler/scala/tools/nsc/transform/Delambdafy.scala
+++ b/src/compiler/scala/tools/nsc/transform/Delambdafy.scala
@@ -130,7 +130,7 @@ abstract class Delambdafy extends Transform with TypingTransformers with ast.Tre
if (!thisProxy.exists) {
target setFlag STATIC
}
- val params = ((optionSymbol(thisProxy) map {proxy:Symbol => ValDef(proxy)}) ++ (target.paramss.flatten map ValDef)).toList
+ val params = ((optionSymbol(thisProxy) map {proxy:Symbol => ValDef(proxy)}) ++ (target.paramss.flatten map ValDef.apply)).toList
val methSym = oldClass.newMethod(unit.freshTermName(nme.accessor.toString()), target.pos, FINAL | BRIDGE | SYNTHETIC | PROTECTED | STATIC)
diff --git a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
index fea49be900..02e55241b3 100644
--- a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
+++ b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
@@ -1652,7 +1652,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
case SpecialOverload(original, env) =>
debuglog("completing specialized " + symbol.fullName + " calling " + original)
debuglog("special overload " + original + " -> " + env)
- val t = DefDef(symbol, { vparamss =>
+ val t = DefDef(symbol, { vparamss: List[List[Symbol]] =>
val fun = Apply(Select(This(symbol.owner), original),
makeArguments(original, vparamss.head))
@@ -1750,7 +1750,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
// flag. nobody has to see this anyway :)
sym.setFlag(SPECIALIZED)
// create empty bodies for specializations
- localTyper.typed(Block(norm.tail.map(sym => DefDef(sym, { vparamss => EmptyTree })), ddef))
+ localTyper.typed(Block(norm.tail.map(sym => DefDef(sym, { vparamss: List[List[Symbol]] => EmptyTree })), ddef))
} else
tree
case _ =>
@@ -1815,7 +1815,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
val newBody = symSubstituter(body(source).duplicate)
tpt modifyType (_.substSym(oldtparams, newtparams))
- copyDefDef(tree)(vparamss = List(newSyms map ValDef), rhs = newBody)
+ copyDefDef(tree)(vparamss = List(newSyms map ValDef.apply), rhs = newBody)
}
/** Create trees for specialized members of 'sClass', based on the
@@ -1852,9 +1852,9 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
}
// ctor
- mbrs += DefDef(m, Modifiers(m.flags), mmap(List(vparams))(ValDef), EmptyTree)
+ mbrs += DefDef(m, Modifiers(m.flags), mmap(List(vparams))(ValDef.apply), EmptyTree)
} else {
- mbrs += DefDef(m, { paramss => EmptyTree })
+ mbrs += DefDef(m, { paramss: List[List[Symbol]] => EmptyTree })
}
} else if (m.isValue) {
mbrs += ValDef(m).setType(NoType)
diff --git a/src/reflect/scala/reflect/api/Internals.scala b/src/reflect/scala/reflect/api/Internals.scala
index 41ded97487..c2f7f411b9 100644
--- a/src/reflect/scala/reflect/api/Internals.scala
+++ b/src/reflect/scala/reflect/api/Internals.scala
@@ -995,10 +995,20 @@ trait Internals { self: Universe =>
*/
type Compat <: CompatApi
+ /** Presence of an implicit value of this type in scope
+ * indicates that source compatibility with Scala 2.10 has been enabled.
+ * @group Internal
+ */
+ @scala.annotation.implicitNotFound("This method has been removed from the public API. Import compat._ or migrate away.")
+ class CompatToken
+
/** @see [[compat]]
* @group Internal
*/
trait CompatApi {
+ /** @see [[CompatToken]] */
+ implicit val token = new CompatToken
+
/** @see [[InternalApi.typeTagToManifest]] */
@deprecated("Use `internal.typeTagToManifest` instead", "2.11.0")
def typeTagToManifest[T: ClassTag](mirror: Any, tag: Universe#TypeTag[T]): Manifest[T] =
@@ -1037,72 +1047,6 @@ trait Internals { self: Universe =>
def substituteThis(clazz: Symbol, to: Tree): Tree = internal.substituteThis(tree, clazz, to)
}
- /** Scala 2.10 compatibility enrichments for ClassDef. */
- implicit class CompatibleClassDefExtractor(dex: ClassDefExtractor) {
- /** @see [[InternalApi.classDef]] */
- @deprecated("Use `internal.classDef` instead", "2.11.0")
- def apply(sym: Symbol, impl: Template): ClassDef = internal.classDef(sym, impl)
- }
-
- /** Scala 2.10 compatibility enrichments for ModuleDef. */
- implicit class CompatibleModuleDefExtractor(dex: ModuleDefExtractor) {
- /** @see [[InternalApi.moduleDef]] */
- @deprecated("Use `internal.moduleDef` instead", "2.11.0")
- def apply(sym: Symbol, impl: Template): ModuleDef = internal.moduleDef(sym, impl)
- }
-
- /** Scala 2.10 compatibility enrichments for ValDef. */
- implicit class CompatibleValDefExtractor(dex: ValDefExtractor) {
- /** @see [[InternalApi.valDef]] */
- @deprecated("Use `internal.valDef` instead", "2.11.0")
- def apply(sym: Symbol, rhs: Tree): ValDef = internal.valDef(sym, rhs)
-
- /** @see [[InternalApi.valDef]] */
- @deprecated("Use `internal.valDef` instead", "2.11.0")
- def apply(sym: Symbol): ValDef = internal.valDef(sym)
- }
-
- /** Scala 2.10 compatibility enrichments for ValDef. */
- implicit class CompatibleDefDefExtractor(dex: DefDefExtractor) {
- /** @see [[InternalApi.defDef]] */
- @deprecated("Use `internal.defDef` instead", "2.11.0")
- def apply(sym: Symbol, mods: Modifiers, vparamss: List[List[ValDef]], rhs: Tree): DefDef = internal.defDef(sym, mods, vparamss, rhs)
-
- /** @see [[InternalApi.defDef]] */
- @deprecated("Use `internal.defDef` instead", "2.11.0")
- def apply(sym: Symbol, vparamss: List[List[ValDef]], rhs: Tree): DefDef = internal.defDef(sym, vparamss, rhs)
-
- /** @see [[InternalApi.defDef]] */
- @deprecated("Use `internal.defDef` instead", "2.11.0")
- def apply(sym: Symbol, mods: Modifiers, rhs: Tree): DefDef = internal.defDef(sym, mods, rhs)
-
- /** @see [[InternalApi.defDef]] */
- @deprecated("Use `internal.defDef` instead", "2.11.0")
- def apply(sym: Symbol, rhs: Tree): DefDef = internal.defDef(sym, rhs)
-
- /** @see [[InternalApi.defDef]] */
- @deprecated("Use `internal.defDef` instead", "2.11.0")
- def apply(sym: Symbol, rhs: List[List[Symbol]] => Tree): DefDef = internal.defDef(sym, rhs)
- }
-
- /** Scala 2.10 compatibility enrichments for TypeDef. */
- implicit class CompatibleTypeDefExtractor(dex: TypeDefExtractor) {
- /** @see [[InternalApi.typeDef]] */
- @deprecated("Use `internal.typeDef` instead", "2.11.0")
- def apply(sym: Symbol, rhs: Tree): TypeDef = internal.typeDef(sym, rhs)
-
- /** @see [[InternalApi.typeDef]] */
- @deprecated("Use `internal.typeDef` instead", "2.11.0")
- def apply(sym: Symbol): TypeDef = internal.typeDef(sym)
- }
-
- /** Scala 2.10 compatibility enrichments for LabelDef. */
- implicit class CompatibleLabelDefExtractor(dex: LabelDefExtractor) {
- /** @see [[InternalApi.labelDef]] */
- @deprecated("Use `internal.labelDef` instead", "2.11.0")
- def apply(sym: Symbol, params: List[Symbol], rhs: Tree): LabelDef = internal.labelDef(sym, params, rhs)
- }
-
/** Scala 2.10 compatibility enrichments for Tree. */
implicit class CompatibleSymbol(symbol: Symbol) {
@deprecated("This API is unreliable. Use `isPrivateThis` or `isProtectedThis` instead", "2.11.0")
@@ -1159,103 +1103,5 @@ trait Internals { self: Universe =>
@deprecated("Use `internal.deSkolemize` instead", "2.11.0")
def deSkolemize: Symbol = internal.deSkolemize(symbol)
}
-
- /** Scala 2.10 compatibility enrichments for ThisType. */
- implicit class CompatibleThisType(tex: ThisTypeExtractor) {
- /** @see [[InternalApi.thisType]] */
- @deprecated("Use `internal.thisType` instead")
- def apply(sym: Symbol): Type = internal.thisType(sym)
- }
-
- /** Scala 2.10 compatibility enrichments for SingleType. */
- implicit class CompatibleSingleType(tex: SingleTypeExtractor) {
- /** @see [[InternalApi.singleType]] */
- @deprecated("Use `ClassSymbol.thisPrefix` or `internal.singleType` instead")
- def apply(pre: Type, sym: Symbol): Type = internal.singleType(pre, sym)
- }
-
- /** Scala 2.10 compatibility enrichments for SuperType. */
- implicit class CompatibleSuperType(tex: SuperTypeExtractor) {
- /** @see [[InternalApi.superType]] */
- @deprecated("Use `ClassSymbol.superPrefix` or `internal.superType` instead")
- def apply(thistpe: Type, supertpe: Type): Type = internal.superType(thistpe, supertpe)
- }
-
- /** Scala 2.10 compatibility enrichments for ConstantType. */
- implicit class CompatibleConstantType(tex: ConstantTypeExtractor) {
- /** @see [[InternalApi.constantType]] */
- @deprecated("Use `value.tpe` or `internal.constantType` instead")
- def apply(value: Constant): ConstantType = internal.constantType(value)
- }
-
- /** Scala 2.10 compatibility enrichments for TypeRef. */
- implicit class CompatibleTypeRef(tex: TypeRefExtractor) {
- /** @see [[InternalApi.typeRef]] */
- @deprecated("Use `internal.typeRef` instead")
- def apply(pre: Type, sym: Symbol, args: List[Type]): Type = internal.typeRef(pre, sym, args)
- }
-
- /** Scala 2.10 compatibility enrichments for RefinedType. */
- implicit class CompatibleRefinedType(tex: RefinedTypeExtractor) {
- /** @see [[InternalApi.refinedType]] */
- @deprecated("Use `internal.refinedType` instead")
- def apply(parents: List[Type], decls: Scope): RefinedType = internal.refinedType(parents, decls)
- }
-
- /** Scala 2.10 compatibility enrichments for ClassInfoType. */
- implicit class CompatibleClassInfoType(tex: ClassInfoTypeExtractor) {
- /** @see [[InternalApi.classInfoType]] */
- @deprecated("Use `internal.classInfoType` instead")
- def apply(parents: List[Type], decls: Scope, typeSymbol: Symbol): ClassInfoType = internal.classInfoType(parents, decls, typeSymbol)
- }
-
- /** Scala 2.10 compatibility enrichments for MethodType. */
- implicit class CompatibleMethodType(tex: MethodTypeExtractor) {
- /** @see [[InternalApi.methodType]] */
- @deprecated("Use `internal.methodType` instead")
- def apply(params: List[Symbol], resultType: Type): MethodType = internal.methodType(params, resultType)
- }
-
- /** Scala 2.10 compatibility enrichments for NullaryMethodType. */
- implicit class CompatibleNullaryMethodType(tex: NullaryMethodTypeExtractor) {
- /** @see [[InternalApi.nullaryMethodType]] */
- @deprecated("Use `internal.nullaryMethodType` instead")
- def apply(resultType: Type): NullaryMethodType = internal.nullaryMethodType(resultType)
- }
-
- /** Scala 2.10 compatibility enrichments for PolyType. */
- implicit class CompatiblePolyType(tex: PolyTypeExtractor) {
- /** @see [[InternalApi.polyType]] */
- @deprecated("Use `internal.polyType` instead")
- def apply(typeParams: List[Symbol], resultType: Type): PolyType = internal.polyType(typeParams, resultType)
- }
-
- /** Scala 2.10 compatibility enrichments for ExistentialType. */
- implicit class CompatibleExistentialType(tex: ExistentialTypeExtractor) {
- /** @see [[InternalApi.existentialType]] */
- @deprecated("Use `internal.existentialType` instead")
- def apply(quantified: List[Symbol], underlying: Type): ExistentialType = internal.existentialType(quantified, underlying)
- }
-
- /** Scala 2.10 compatibility enrichments for AnnotatedType. */
- implicit class CompatibleAnnotatedType(tex: AnnotatedTypeExtractor) {
- /** @see [[InternalApi.annotatedType]] */
- @deprecated("Use `internal.annotatedType` instead")
- def apply(annotations: List[Annotation], underlying: Type): AnnotatedType = internal.annotatedType(annotations, underlying)
- }
-
- /** Scala 2.10 compatibility enrichments for TypeBounds. */
- implicit class CompatibleTypeBounds(tex: TypeBoundsExtractor) {
- /** @see [[InternalApi.typeBounds]] */
- @deprecated("Use `internal.typeBounds` instead")
- def apply(lo: Type, hi: Type): TypeBounds = internal.typeBounds(lo, hi)
- }
-
- /** Scala 2.10 compatibility enrichments for BoundedWildcardType. */
- implicit class CompatibleBoundedWildcardType(tex: BoundedWildcardTypeExtractor) {
- /** @see [[InternalApi.boundedWildcardType]] */
- @deprecated("Use `internal.boundedWildcardType` instead")
- def apply(bounds: TypeBounds): BoundedWildcardType = internal.boundedWildcardType(bounds)
- }
}
}
diff --git a/src/reflect/scala/reflect/api/Trees.scala b/src/reflect/scala/reflect/api/Trees.scala
index a42f6ab728..ff8926651b 100644
--- a/src/reflect/scala/reflect/api/Trees.scala
+++ b/src/reflect/scala/reflect/api/Trees.scala
@@ -386,6 +386,10 @@ trait Trees { self: Universe =>
abstract class ClassDefExtractor {
def apply(mods: Modifiers, name: TypeName, tparams: List[TypeDef], impl: Template): ClassDef
def unapply(classDef: ClassDef): Option[(Modifiers, TypeName, List[TypeDef], Template)]
+
+ /** @see [[InternalApi.classDef]] */
+ @deprecated("Use `internal.classDef` instead", "2.11.0")
+ def apply(sym: Symbol, impl: Template)(implicit token: CompatToken): ClassDef = internal.classDef(sym, impl)
}
/** The API that all class defs support
@@ -431,6 +435,10 @@ trait Trees { self: Universe =>
abstract class ModuleDefExtractor {
def apply(mods: Modifiers, name: TermName, impl: Template): ModuleDef
def unapply(moduleDef: ModuleDef): Option[(Modifiers, TermName, Template)]
+
+ /** @see [[InternalApi.moduleDef]] */
+ @deprecated("Use `internal.moduleDef` instead", "2.11.0")
+ def apply(sym: Symbol, impl: Template)(implicit token: CompatToken): ModuleDef = internal.moduleDef(sym, impl)
}
/** The API that all module defs support
@@ -507,6 +515,14 @@ trait Trees { self: Universe =>
abstract class ValDefExtractor {
def apply(mods: Modifiers, name: TermName, tpt: Tree, rhs: Tree): ValDef
def unapply(valDef: ValDef): Option[(Modifiers, TermName, Tree, Tree)]
+
+ /** @see [[InternalApi.valDef]] */
+ @deprecated("Use `internal.valDef` instead", "2.11.0")
+ def apply(sym: Symbol, rhs: Tree)(implicit token: CompatToken): ValDef = internal.valDef(sym, rhs)
+
+ /** @see [[InternalApi.valDef]] */
+ @deprecated("Use `internal.valDef` instead", "2.11.0")
+ def apply(sym: Symbol)(implicit token: CompatToken): ValDef = internal.valDef(sym)
}
/** The API that all val defs support
@@ -550,6 +566,26 @@ trait Trees { self: Universe =>
abstract class DefDefExtractor {
def apply(mods: Modifiers, name: TermName, tparams: List[TypeDef], vparamss: List[List[ValDef]], tpt: Tree, rhs: Tree): DefDef
def unapply(defDef: DefDef): Option[(Modifiers, TermName, List[TypeDef], List[List[ValDef]], Tree, Tree)]
+
+ /** @see [[InternalApi.defDef]] */
+ @deprecated("Use `internal.defDef` instead", "2.11.0")
+ def apply(sym: Symbol, mods: Modifiers, vparamss: List[List[ValDef]], rhs: Tree)(implicit token: CompatToken): DefDef = internal.defDef(sym, mods, vparamss, rhs)
+
+ /** @see [[InternalApi.defDef]] */
+ @deprecated("Use `internal.defDef` instead", "2.11.0")
+ def apply(sym: Symbol, vparamss: List[List[ValDef]], rhs: Tree)(implicit token: CompatToken): DefDef = internal.defDef(sym, vparamss, rhs)
+
+ /** @see [[InternalApi.defDef]] */
+ @deprecated("Use `internal.defDef` instead", "2.11.0")
+ def apply(sym: Symbol, mods: Modifiers, rhs: Tree)(implicit token: CompatToken): DefDef = internal.defDef(sym, mods, rhs)
+
+ /** @see [[InternalApi.defDef]] */
+ @deprecated("Use `internal.defDef` instead", "2.11.0")
+ def apply(sym: Symbol, rhs: Tree)(implicit token: CompatToken): DefDef = internal.defDef(sym, rhs)
+
+ /** @see [[InternalApi.defDef]] */
+ @deprecated("Use `internal.defDef` instead", "2.11.0")
+ def apply(sym: Symbol, rhs: List[List[Symbol]] => Tree)(implicit token: CompatToken): DefDef = internal.defDef(sym, rhs)
}
/** The API that all def defs support
@@ -602,6 +638,14 @@ trait Trees { self: Universe =>
abstract class TypeDefExtractor {
def apply(mods: Modifiers, name: TypeName, tparams: List[TypeDef], rhs: Tree): TypeDef
def unapply(typeDef: TypeDef): Option[(Modifiers, TypeName, List[TypeDef], Tree)]
+
+ /** @see [[InternalApi.typeDef]] */
+ @deprecated("Use `internal.typeDef` instead", "2.11.0")
+ def apply(sym: Symbol, rhs: Tree)(implicit token: CompatToken): TypeDef = internal.typeDef(sym, rhs)
+
+ /** @see [[InternalApi.typeDef]] */
+ @deprecated("Use `internal.typeDef` instead", "2.11.0")
+ def apply(sym: Symbol)(implicit token: CompatToken): TypeDef = internal.typeDef(sym)
}
/** The API that all type defs support
@@ -662,6 +706,10 @@ trait Trees { self: Universe =>
abstract class LabelDefExtractor {
def apply(name: TermName, params: List[Ident], rhs: Tree): LabelDef
def unapply(labelDef: LabelDef): Option[(TermName, List[Ident], Tree)]
+
+ /** @see [[InternalApi.labelDef]] */
+ @deprecated("Use `internal.labelDef` instead", "2.11.0")
+ def apply(sym: Symbol, params: List[Symbol], rhs: Tree)(implicit token: CompatToken): LabelDef = internal.labelDef(sym, params, rhs)
}
/** The API that all label defs support
diff --git a/src/reflect/scala/reflect/api/Types.scala b/src/reflect/scala/reflect/api/Types.scala
index d41b6724e6..cb83b73f3d 100644
--- a/src/reflect/scala/reflect/api/Types.scala
+++ b/src/reflect/scala/reflect/api/Types.scala
@@ -428,6 +428,10 @@ trait Types {
*/
abstract class ThisTypeExtractor {
def unapply(tpe: ThisType): Option[Symbol]
+
+ /** @see [[InternalApi.thisType]] */
+ @deprecated("Use `internal.thisType` instead", "2.11.0")
+ def apply(sym: Symbol)(implicit token: CompatToken): Type = internal.thisType(sym)
}
/** The API that all this types support.
@@ -463,6 +467,10 @@ trait Types {
*/
abstract class SingleTypeExtractor {
def unapply(tpe: SingleType): Option[(Type, Symbol)]
+
+ /** @see [[InternalApi.singleType]] */
+ @deprecated("Use `ClassSymbol.thisPrefix` or `internal.singleType` instead")
+ def apply(pre: Type, sym: Symbol)(implicit token: CompatToken): Type = internal.singleType(pre, sym)
}
/** The API that all single types support.
@@ -499,6 +507,10 @@ trait Types {
*/
abstract class SuperTypeExtractor {
def unapply(tpe: SuperType): Option[(Type, Type)]
+
+ /** @see [[InternalApi.superType]] */
+ @deprecated("Use `ClassSymbol.superPrefix` or `internal.superType` instead", "2.11.0")
+ def apply(thistpe: Type, supertpe: Type)(implicit token: CompatToken): Type = internal.superType(thistpe, supertpe)
}
/** The API that all super types support.
@@ -538,6 +550,10 @@ trait Types {
*/
abstract class ConstantTypeExtractor {
def unapply(tpe: ConstantType): Option[Constant]
+
+ /** @see [[InternalApi.constantType]] */
+ @deprecated("Use `value.tpe` or `internal.constantType` instead", "2.11.0")
+ def apply(value: Constant)(implicit token: CompatToken): ConstantType = internal.constantType(value)
}
/** The API that all constant types support.
@@ -577,6 +593,10 @@ trait Types {
*/
abstract class TypeRefExtractor {
def unapply(tpe: TypeRef): Option[(Type, Symbol, List[Type])]
+
+ /** @see [[InternalApi.typeRef]] */
+ @deprecated("Use `internal.typeRef` instead", "2.11.0")
+ def apply(pre: Type, sym: Symbol, args: List[Type])(implicit token: CompatToken): Type = internal.typeRef(pre, sym, args)
}
/** The API that all type refs support.
@@ -633,6 +653,10 @@ trait Types {
*/
abstract class RefinedTypeExtractor {
def unapply(tpe: RefinedType): Option[(List[Type], Scope)]
+
+ /** @see [[InternalApi.refinedType]] */
+ @deprecated("Use `internal.refinedType` instead", "2.11.0")
+ def apply(parents: List[Type], decls: Scope)(implicit token: CompatToken): RefinedType = internal.refinedType(parents, decls)
}
/** The API that all refined types support.
@@ -674,6 +698,10 @@ trait Types {
*/
abstract class ClassInfoTypeExtractor {
def unapply(tpe: ClassInfoType): Option[(List[Type], Scope, Symbol)]
+
+ /** @see [[InternalApi.classInfoType]] */
+ @deprecated("Use `internal.classInfoType` instead", "2.11.0")
+ def apply(parents: List[Type], decls: Scope, typeSymbol: Symbol)(implicit token: CompatToken): ClassInfoType = internal.classInfoType(parents, decls, typeSymbol)
}
/** The API that all class info types support.
@@ -719,6 +747,10 @@ trait Types {
*/
abstract class MethodTypeExtractor {
def unapply(tpe: MethodType): Option[(List[Symbol], Type)]
+
+ /** @see [[InternalApi.methodType]] */
+ @deprecated("Use `internal.methodType` instead", "2.11.0")
+ def apply(params: List[Symbol], resultType: Type)(implicit token: CompatToken): MethodType = internal.methodType(params, resultType)
}
/** The API that all method types support.
@@ -751,6 +783,10 @@ trait Types {
*/
abstract class NullaryMethodTypeExtractor {
def unapply(tpe: NullaryMethodType): Option[(Type)]
+
+ /** @see [[InternalApi.nullaryMethodType]] */
+ @deprecated("Use `internal.nullaryMethodType` instead", "2.11.0")
+ def apply(resultType: Type)(implicit token: CompatToken): NullaryMethodType = internal.nullaryMethodType(resultType)
}
/** The API that all nullary method types support.
@@ -781,6 +817,10 @@ trait Types {
*/
abstract class PolyTypeExtractor {
def unapply(tpe: PolyType): Option[(List[Symbol], Type)]
+
+ /** @see [[InternalApi.polyType]] */
+ @deprecated("Use `internal.polyType` instead", "2.11.0")
+ def apply(typeParams: List[Symbol], resultType: Type)(implicit token: CompatToken): PolyType = internal.polyType(typeParams, resultType)
}
/** The API that all polymorphic types support.
@@ -815,6 +855,10 @@ trait Types {
*/
abstract class ExistentialTypeExtractor {
def unapply(tpe: ExistentialType): Option[(List[Symbol], Type)]
+
+ /** @see [[InternalApi.existentialType]] */
+ @deprecated("Use `internal.existentialType` instead", "2.11.0")
+ def apply(quantified: List[Symbol], underlying: Type)(implicit token: CompatToken): ExistentialType = internal.existentialType(quantified, underlying)
}
/** The API that all existential types support.
@@ -849,6 +893,10 @@ trait Types {
*/
abstract class AnnotatedTypeExtractor {
def unapply(tpe: AnnotatedType): Option[(List[Annotation], Type)]
+
+ /** @see [[InternalApi.annotatedType]] */
+ @deprecated("Use `internal.annotatedType` instead", "2.11.0")
+ def apply(annotations: List[Annotation], underlying: Type)(implicit token: CompatToken): AnnotatedType = internal.annotatedType(annotations, underlying)
}
/** The API that all annotated types support.
@@ -889,6 +937,10 @@ trait Types {
*/
abstract class TypeBoundsExtractor {
def unapply(tpe: TypeBounds): Option[(Type, Type)]
+
+ /** @see [[InternalApi.typeBounds]] */
+ @deprecated("Use `internal.typeBounds` instead", "2.11.0")
+ def apply(lo: Type, hi: Type)(implicit token: CompatToken): TypeBounds = internal.typeBounds(lo, hi)
}
/** The API that all type bounds support.
@@ -938,6 +990,10 @@ trait Types {
*/
abstract class BoundedWildcardTypeExtractor {
def unapply(tpe: BoundedWildcardType): Option[TypeBounds]
+
+ /** @see [[InternalApi.boundedWildcardType]] */
+ @deprecated("Use `internal.boundedWildcardType` instead", "2.11.0")
+ def apply(bounds: TypeBounds)(implicit token: CompatToken): BoundedWildcardType = internal.boundedWildcardType(bounds)
}
/** The API that all this types support.
diff --git a/src/reflect/scala/reflect/internal/Trees.scala b/src/reflect/scala/reflect/internal/Trees.scala
index 42952e5d80..5b4b7fd2a4 100644
--- a/src/reflect/scala/reflect/internal/Trees.scala
+++ b/src/reflect/scala/reflect/internal/Trees.scala
@@ -296,11 +296,39 @@ trait Trees extends api.Trees {
case class ClassDef(mods: Modifiers, name: TypeName, tparams: List[TypeDef], impl: Template)
extends ImplDef with ClassDefApi
- object ClassDef extends ClassDefExtractor
+ object ClassDef extends ClassDefExtractor {
+ /** @param sym the class symbol
+ * @param impl the implementation template
+ * @return the class definition
+ */
+ def apply(sym: Symbol, impl: Template): ClassDef =
+ atPos(sym.pos) {
+ ClassDef(Modifiers(sym.flags),
+ sym.name.toTypeName,
+ sym.typeParams map TypeDef.apply,
+ impl) setSymbol sym
+ }
+
+ /** @param sym the class symbol
+ * @param body trees that constitute the body of the class
+ * @return the class definition
+ */
+ def apply(sym: Symbol, body: List[Tree]): ClassDef =
+ ClassDef(sym, Template(sym, body))
+ }
case class ModuleDef(mods: Modifiers, name: TermName, impl: Template)
extends ImplDef with ModuleDefApi
- object ModuleDef extends ModuleDefExtractor
+ object ModuleDef extends ModuleDefExtractor {
+ /**
+ * @param sym the class symbol
+ * @param impl the implementation template
+ */
+ def apply(sym: Symbol, impl: Template): ModuleDef =
+ atPos(sym.pos) {
+ ModuleDef(Modifiers(sym.flags), sym.name.toTermName, impl) setSymbol sym
+ }
+ }
abstract class ValOrDefDef extends MemberDef with ValOrDefDefApi {
def name: TermName
@@ -317,19 +345,37 @@ trait Trees extends api.Trees {
}
case class ValDef(mods: Modifiers, name: TermName, tpt: Tree, rhs: Tree) extends ValOrDefDef with ValDefApi
- object ValDef extends ValDefExtractor
+ object ValDef extends ValDefExtractor {
+ def apply(sym: Symbol): ValDef = newValDef(sym, EmptyTree)()
+ def apply(sym: Symbol, rhs: Tree): ValDef = newValDef(sym, rhs)()
+ }
case class DefDef(mods: Modifiers, name: TermName, tparams: List[TypeDef],
vparamss: List[List[ValDef]], tpt: Tree, rhs: Tree) extends ValOrDefDef with DefDefApi
- object DefDef extends DefDefExtractor
+ object DefDef extends DefDefExtractor {
+ def apply(sym: Symbol, rhs: Tree): DefDef = newDefDef(sym, rhs)()
+ def apply(sym: Symbol, vparamss: List[List[ValDef]], rhs: Tree): DefDef = newDefDef(sym, rhs)(vparamss = vparamss)
+ def apply(sym: Symbol, mods: Modifiers, rhs: Tree): DefDef = newDefDef(sym, rhs)(mods = mods)
+ def apply(sym: Symbol, mods: Modifiers, vparamss: List[List[ValDef]], rhs: Tree): DefDef = newDefDef(sym, rhs)(mods = mods, vparamss = vparamss)
+ def apply(sym: Symbol, rhs: List[List[Symbol]] => Tree): DefDef = newDefDef(sym, rhs(sym.info.paramss))()
+ }
case class TypeDef(mods: Modifiers, name: TypeName, tparams: List[TypeDef], rhs: Tree)
extends MemberDef with TypeDefApi
- object TypeDef extends TypeDefExtractor
+ object TypeDef extends TypeDefExtractor {
+ /** A TypeDef node which defines abstract type or type parameter for given `sym` */
+ def apply(sym: Symbol): TypeDef = newTypeDef(sym, TypeBoundsTree(sym))()
+ def apply(sym: Symbol, rhs: Tree): TypeDef = newTypeDef(sym, rhs)()
+ }
case class LabelDef(name: TermName, params: List[Ident], rhs: Tree)
extends DefTree with TermTree with LabelDefApi
- object LabelDef extends LabelDefExtractor
+ object LabelDef extends LabelDefExtractor {
+ def apply(sym: Symbol, params: List[Symbol], rhs: Tree): LabelDef =
+ atPos(sym.pos) {
+ LabelDef(sym.name.toTermName, params map Ident, rhs) setSymbol sym
+ }
+ }
case class ImportSelector(name: Name, namePos: Int, rename: Name, renamePos: Int) extends ImportSelectorApi
object ImportSelector extends ImportSelectorExtractor {
@@ -1007,25 +1053,6 @@ trait Trees extends api.Trees {
// ---- values and creators ---------------------------------------
- /** @param sym the class symbol
- * @param impl the implementation template
- * @return the class definition
- */
- def ClassDef(sym: Symbol, impl: Template): ClassDef =
- atPos(sym.pos) {
- ClassDef(Modifiers(sym.flags),
- sym.name.toTypeName,
- sym.typeParams map TypeDef,
- impl) setSymbol sym
- }
-
- /** @param sym the class symbol
- * @param body trees that constitute the body of the class
- * @return the class definition
- */
- def ClassDef(sym: Symbol, body: List[Tree]): ClassDef =
- ClassDef(sym, Template(sym, body))
-
/** @param sym the template's symbol
* @param body trees that constitute the body of the template
* @return the template
@@ -1038,15 +1065,6 @@ trait Trees extends api.Trees {
}
}
- /**
- * @param sym the class symbol
- * @param impl the implementation template
- */
- def ModuleDef(sym: Symbol, impl: Template): ModuleDef =
- atPos(sym.pos) {
- ModuleDef(Modifiers(sym.flags), sym.name.toTermName, impl) setSymbol sym
- }
-
trait CannotHaveAttrs extends Tree {
super.setPos(NoPosition)
super.setType(NoType)
@@ -1083,8 +1101,8 @@ trait Trees extends api.Trees {
def newDefDef(sym: Symbol, rhs: Tree)(
mods: Modifiers = Modifiers(sym.flags),
name: TermName = sym.name.toTermName,
- tparams: List[TypeDef] = sym.typeParams map TypeDef,
- vparamss: List[List[ValDef]] = mapParamss(sym)(ValDef),
+ tparams: List[TypeDef] = sym.typeParams map TypeDef.apply,
+ vparamss: List[List[ValDef]] = mapParamss(sym)(ValDef.apply),
tpt: Tree = TypeTreeMemberType(sym)
): DefDef = (
atPos(sym.pos)(DefDef(mods, name, tparams, vparamss, tpt, rhs)) setSymbol sym
@@ -1093,29 +1111,11 @@ trait Trees extends api.Trees {
def newTypeDef(sym: Symbol, rhs: Tree)(
mods: Modifiers = Modifiers(sym.flags),
name: TypeName = sym.name.toTypeName,
- tparams: List[TypeDef] = sym.typeParams map TypeDef
+ tparams: List[TypeDef] = sym.typeParams map TypeDef.apply
): TypeDef = (
atPos(sym.pos)(TypeDef(mods, name, tparams, rhs)) setSymbol sym
)
- def DefDef(sym: Symbol, rhs: Tree): DefDef = newDefDef(sym, rhs)()
- def DefDef(sym: Symbol, vparamss: List[List[ValDef]], rhs: Tree): DefDef = newDefDef(sym, rhs)(vparamss = vparamss)
- def DefDef(sym: Symbol, mods: Modifiers, rhs: Tree): DefDef = newDefDef(sym, rhs)(mods = mods)
- def DefDef(sym: Symbol, mods: Modifiers, vparamss: List[List[ValDef]], rhs: Tree): DefDef = newDefDef(sym, rhs)(mods = mods, vparamss = vparamss)
- def DefDef(sym: Symbol, rhs: List[List[Symbol]] => Tree): DefDef = newDefDef(sym, rhs(sym.info.paramss))()
-
- def ValDef(sym: Symbol): ValDef = newValDef(sym, EmptyTree)()
- def ValDef(sym: Symbol, rhs: Tree): ValDef = newValDef(sym, rhs)()
-
- /** A TypeDef node which defines abstract type or type parameter for given `sym` */
- def TypeDef(sym: Symbol): TypeDef = newTypeDef(sym, TypeBoundsTree(sym))()
- def TypeDef(sym: Symbol, rhs: Tree): TypeDef = newTypeDef(sym, rhs)()
-
- def LabelDef(sym: Symbol, params: List[Symbol], rhs: Tree): LabelDef =
- atPos(sym.pos) {
- LabelDef(sym.name.toTermName, params map Ident, rhs) setSymbol sym
- }
-
/** casedef shorthand */
def CaseDef(pat: Tree, body: Tree): CaseDef =
CaseDef(pat, EmptyTree, body)