summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/scala-compiler.jar.desired.sha12
-rw-r--r--lib/scala-library-src.jar.desired.sha12
-rw-r--r--lib/scala-library.jar.desired.sha12
-rw-r--r--src/android-library/scala/ScalaObject.scala13
-rw-r--r--src/compiler/scala/reflect/internal/Definitions.scala162
-rw-r--r--src/compiler/scala/reflect/internal/Importers.scala4
-rw-r--r--src/compiler/scala/reflect/internal/StdNames.scala1
-rw-r--r--src/compiler/scala/reflect/internal/SymbolTable.scala2
-rw-r--r--src/compiler/scala/reflect/internal/Symbols.scala6
-rw-r--r--src/compiler/scala/reflect/internal/TreeGen.scala1
-rw-r--r--src/compiler/scala/reflect/internal/TreeInfo.scala12
-rw-r--r--src/compiler/scala/reflect/internal/TreePrinters.scala5
-rw-r--r--src/compiler/scala/reflect/internal/Trees.scala32
-rw-r--r--src/compiler/scala/reflect/internal/Types.scala31
-rw-r--r--src/compiler/scala/reflect/internal/transform/Erasure.scala18
-rw-r--r--src/compiler/scala/reflect/runtime/JavaToScala.scala6
-rw-r--r--src/compiler/scala/reflect/runtime/ToolBoxes.scala2
-rw-r--r--src/compiler/scala/tools/cmd/gen/AnyVals.scala6
-rw-r--r--src/compiler/scala/tools/nsc/Global.scala55
-rw-r--r--src/compiler/scala/tools/nsc/ast/TreeInfo.scala11
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Parsers.scala30
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala1
-rw-r--r--src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala11
-rw-r--r--src/compiler/scala/tools/nsc/interpreter/MemberHandlers.scala2
-rw-r--r--src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala2
-rw-r--r--src/compiler/scala/tools/nsc/symtab/clr/TypeParser.scala8
-rw-r--r--src/compiler/scala/tools/nsc/transform/AddInterfaces.scala2
-rw-r--r--src/compiler/scala/tools/nsc/transform/Constructors.scala2
-rw-r--r--src/compiler/scala/tools/nsc/transform/Erasure.scala56
-rw-r--r--src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala168
-rw-r--r--src/compiler/scala/tools/nsc/transform/InlineErasure.scala9
-rw-r--r--src/compiler/scala/tools/nsc/transform/LiftCode.scala1
-rw-r--r--src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala6
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala4
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Contexts.scala3
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Namers.scala44
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/RefChecks.scala23
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala11
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala44
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Unapplies.scala3
-rw-r--r--src/compiler/scala/tools/nsc/util/ClassPath.scala2
-rw-r--r--src/detach/plugin/scala/tools/detach/Detach.scala5
-rw-r--r--src/library/scala/AnyVal.scala6
-rw-r--r--src/library/scala/Boolean.scala2
-rw-r--r--src/library/scala/Byte.scala2
-rw-r--r--src/library/scala/Char.scala2
-rw-r--r--src/library/scala/Double.scala2
-rw-r--r--src/library/scala/Float.scala2
-rw-r--r--src/library/scala/Int.scala2
-rw-r--r--src/library/scala/Long.scala2
-rw-r--r--src/library/scala/NotNull.scala2
-rw-r--r--src/library/scala/Proxy.scala10
-rw-r--r--src/library/scala/ScalaObject.scala13
-rw-r--r--src/library/scala/Short.scala2
-rw-r--r--src/library/scala/Unit.scala2
-rw-r--r--src/library/scala/collection/GenTraversableOnce.scala2
-rw-r--r--src/library/scala/collection/immutable/StringOps.scala2
-rw-r--r--src/library/scala/math/Ordered.scala2
-rw-r--r--src/library/scala/runtime/ScalaNumberProxy.scala2
-rw-r--r--src/library/scala/util/Properties.scala2
-rw-r--r--test/files/neg/anyval-children-2.check4
-rw-r--r--test/files/neg/anyval-children-2.scala1
-rw-r--r--test/files/neg/anyval-children.check26
-rw-r--r--test/files/neg/anyval-children.scala14
-rw-r--r--test/files/neg/anyval-sealed.check12
-rw-r--r--test/files/neg/anyval-sealed.flags1
-rw-r--r--test/files/neg/anyval-sealed.scala6
-rw-r--r--test/files/neg/override-object-no.check12
-rw-r--r--test/files/neg/t0699.check6
-rw-r--r--test/files/neg/t3222.check6
-rw-r--r--test/files/pos/anyval-children.flags1
-rw-r--r--test/files/pos/anyval-children.scala1
-rw-r--r--test/files/run/programmatic-main.check45
73 files changed, 678 insertions, 326 deletions
diff --git a/lib/scala-compiler.jar.desired.sha1 b/lib/scala-compiler.jar.desired.sha1
index 209189f444..2a4e218c86 100644
--- a/lib/scala-compiler.jar.desired.sha1
+++ b/lib/scala-compiler.jar.desired.sha1
@@ -1 +1 @@
-de9c0ef2ac2d13e2b56148ab2fe22de4ccdc34fc ?scala-compiler.jar
+728a5b26cd8ccef172383c49bdc07c8236de5fd0 ?scala-compiler.jar
diff --git a/lib/scala-library-src.jar.desired.sha1 b/lib/scala-library-src.jar.desired.sha1
index 81d1f677a5..739c62de6d 100644
--- a/lib/scala-library-src.jar.desired.sha1
+++ b/lib/scala-library-src.jar.desired.sha1
@@ -1 +1 @@
-d92a0fd350a661b4ba55f1aeea43a2ba5dec4629 ?scala-library-src.jar
+0530fbb6e4539bf66a76523915b097451b057ab9 ?scala-library-src.jar
diff --git a/lib/scala-library.jar.desired.sha1 b/lib/scala-library.jar.desired.sha1
index 30a8a5bbab..8cf9b47c77 100644
--- a/lib/scala-library.jar.desired.sha1
+++ b/lib/scala-library.jar.desired.sha1
@@ -1 +1 @@
-7fc8fd16bf0fe5cb25e9d43c614fe203fba397c5 ?scala-library.jar
+ea548864dfc6682d9b747ddf4f9651b686d36dcc ?scala-library.jar
diff --git a/src/android-library/scala/ScalaObject.scala b/src/android-library/scala/ScalaObject.scala
deleted file mode 100644
index f44116d1ce..0000000000
--- a/src/android-library/scala/ScalaObject.scala
+++ /dev/null
@@ -1,13 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala
-
-trait ScalaObject extends AnyRef
diff --git a/src/compiler/scala/reflect/internal/Definitions.scala b/src/compiler/scala/reflect/internal/Definitions.scala
index 8114be20d5..47c711e81c 100644
--- a/src/compiler/scala/reflect/internal/Definitions.scala
+++ b/src/compiler/scala/reflect/internal/Definitions.scala
@@ -21,16 +21,18 @@ trait Definitions extends reflect.api.StandardDefinitions {
* methods.
*/
private type PolyMethodCreator = List[Symbol] => (Option[List[Type]], Type)
-
- private def newClass(owner: Symbol, name: TypeName, parents: List[Type], flags: Long = 0L): Symbol = {
+
+ private def enterNewClass(owner: Symbol, name: TypeName, parents: List[Type], flags: Long = 0L): Symbol = {
val clazz = owner.newClassSymbol(name, NoPosition, flags)
clazz setInfoAndEnter ClassInfoType(parents, newScope, clazz)
}
private def newMethod(owner: Symbol, name: TermName, formals: List[Type], restpe: Type, flags: Long = 0L): Symbol = {
val msym = owner.newMethod(name.encode, NoPosition, flags)
val params = msym.newSyntheticValueParams(formals)
- msym setInfoAndEnter MethodType(params, restpe)
+ msym setInfo MethodType(params, restpe)
}
+ private def enterNewMethod(owner: Symbol, name: TermName, formals: List[Type], restpe: Type, flags: Long = 0L): Symbol =
+ owner.info.decls enter newMethod(owner, name, formals, restpe, flags)
// the scala value classes
trait ValueClassDefinitions {
@@ -102,7 +104,6 @@ trait Definitions extends reflect.api.StandardDefinitions {
def isGetClass(sym: Symbol) =
(sym.name == nme.getClass_) && (sym.paramss.isEmpty || sym.paramss.head.isEmpty)
- lazy val AnyValClass = valueCache(tpnme.AnyVal)
lazy val UnitClass = valueCache(tpnme.Unit)
lazy val ByteClass = valueCache(tpnme.Byte)
lazy val ShortClass = valueCache(tpnme.Short)
@@ -164,7 +165,7 @@ trait Definitions extends reflect.api.StandardDefinitions {
lazy val RuntimePackage = getRequiredModule("scala.runtime")
lazy val RuntimePackageClass = RuntimePackage.moduleClass
-
+
lazy val JavaLangEnumClass = getRequiredClass("java.lang.Enum")
// convenient one-argument parameter lists
@@ -176,10 +177,10 @@ trait Definitions extends reflect.api.StandardDefinitions {
private def booltype = BooleanClass.typeConstructor
private def inttype = IntClass.typeConstructor
private def stringtype = StringClass.typeConstructor
-
+
// Java types
def javaTypeName(jclazz: Class[_]): TypeName = newTypeName(jclazz.getName)
-
+
def javaTypeToValueClass(jtype: Class[_]): Symbol = jtype match {
case java.lang.Void.TYPE => UnitClass
case java.lang.Byte.TYPE => ByteClass
@@ -205,13 +206,42 @@ trait Definitions extends reflect.api.StandardDefinitions {
case _ => null
}
+ private def fixupAsAnyTrait(clazz: Symbol): Symbol = {
+ clazz setInfo fixupAsAnyTrait(clazz.info)
+ clazz
+ }
+
+ private def fixupAsAnyTrait(tpe: Type): Type = tpe match {
+ case ClassInfoType(parents, decls, clazz) =>
+ if (parents.head.typeSymbol == AnyClass) tpe
+ else {
+ assert(parents.head.typeSymbol == ObjectClass, parents)
+ ClassInfoType(AnyClass.tpe :: parents.tail, decls, clazz)
+ }
+ case PolyType(tparams, restpe) =>
+ PolyType(tparams, fixupAsAnyTrait(restpe))
+// case _ => tpe
+ }
+
// top types
- lazy val AnyClass = newClass(ScalaPackageClass, tpnme.Any, Nil, ABSTRACT)
+ lazy val AnyClass = enterNewClass(ScalaPackageClass, tpnme.Any, Nil, ABSTRACT)
lazy val AnyRefClass = newAlias(ScalaPackageClass, tpnme.AnyRef, ObjectClass.typeConstructor)
lazy val ObjectClass = getClass(sn.Object)
lazy val AnyCompanionClass = getRequiredClass("scala.AnyCompanion") initFlags (SEALED | ABSTRACT | TRAIT)
lazy val AnyValCompanionClass = getRequiredClass("scala.AnyValCompanion") initFlags (SEALED | ABSTRACT | TRAIT)
+ private var oldValueScheme = true
+
+ lazy val AnyValClass = ScalaPackageClass.info member tpnme.AnyVal orElse {
+// println("new anyval")
+ oldValueScheme = true
+ val anyval = enterNewClass(ScalaPackageClass, tpnme.AnyVal, anyparam, 0L)
+ val av_constr = anyval.newClassConstructor(NoPosition)
+ anyval.info.decls enter av_constr
+ anyval
+ }
+ lazy val AnyVal_getClass = enterNewMethod(AnyValClass, nme.getClass_, Nil, getClassReturnType(AnyValClass.tpe))
+
// bottom types
lazy val RuntimeNothingClass = getClass(fulltpnme.RuntimeNothing)
lazy val RuntimeNullClass = getClass(fulltpnme.RuntimeNull)
@@ -244,7 +274,6 @@ trait Definitions extends reflect.api.StandardDefinitions {
lazy val UninitializedErrorClass = getRequiredClass("scala.UninitializedFieldError")
// fundamental reference classes
- lazy val ScalaObjectClass = getMember(ScalaPackageClass, tpnme.ScalaObject)
lazy val PartialFunctionClass = getRequiredClass("scala.PartialFunction")
lazy val AbstractPartialFunctionClass = getRequiredClass("scala.runtime.AbstractPartialFunction")
lazy val SymbolClass = getRequiredClass("scala.Symbol")
@@ -272,7 +301,7 @@ trait Definitions extends reflect.api.StandardDefinitions {
def Predef_identity = getMember(PredefModule, nme.identity)
def Predef_conforms = getMember(PredefModule, nme.conforms)
def Predef_wrapRefArray = getMember(PredefModule, nme.wrapRefArray)
-
+
/** Is `sym` a member of Predef with the given name?
* Note: DON't replace this by sym == Predef_conforms/etc, as Predef_conforms is a `def`
* which does a member lookup (it can't be a lazy val because we might reload Predef
@@ -311,10 +340,10 @@ trait Definitions extends reflect.api.StandardDefinitions {
// .setInfo(UnitClass.tpe)
lazy val TypeConstraintClass = getRequiredClass("scala.annotation.TypeConstraint")
- lazy val SingletonClass = newClass(ScalaPackageClass, tpnme.Singleton, anyparam, ABSTRACT | TRAIT | FINAL)
+ lazy val SingletonClass = enterNewClass(ScalaPackageClass, tpnme.Singleton, anyparam, ABSTRACT | TRAIT | FINAL)
lazy val SerializableClass = getRequiredClass("scala.Serializable")
lazy val JavaSerializableClass = getClass(sn.JavaSerializable)
- lazy val ComparableClass = getRequiredClass("java.lang.Comparable")
+ lazy val ComparableClass = fixupAsAnyTrait(getRequiredClass("java.lang.Comparable"))
lazy val JavaCloneableClass = getRequiredClass("java.lang.Cloneable")
lazy val RemoteInterfaceClass = getRequiredClass("java.rmi.Remote")
lazy val RemoteExceptionClass = getRequiredClass("java.rmi.RemoteException")
@@ -424,7 +453,7 @@ trait Definitions extends reflect.api.StandardDefinitions {
case m: ClassManifest[_] =>
val sym = manifestToSymbol(m)
val args = m.typeArguments
-
+
if ((sym eq NoSymbol) || args.isEmpty) sym.tpe
else appliedType(sym.typeConstructor, args map manifestToType)
case _ =>
@@ -434,7 +463,7 @@ trait Definitions extends reflect.api.StandardDefinitions {
def manifestToSymbol(m: ClassManifest[_]): Symbol = m match {
case x: scala.reflect.AnyValManifest[_] =>
getMember(ScalaPackageClass, newTypeName("" + x))
- case _ =>
+ case _ =>
val name = m.erasure.getName
if (name endsWith nme.MODULE_SUFFIX_STRING)
getModuleIfDefined(name stripSuffix nme.MODULE_SUFFIX_STRING)
@@ -494,7 +523,7 @@ trait Definitions extends reflect.api.StandardDefinitions {
case DoubleClass => nme.wrapDoubleArray
case BooleanClass => nme.wrapBooleanArray
case UnitClass => nme.wrapUnitArray
- case _ =>
+ case _ =>
if ((elemtp <:< AnyRefClass.tpe) && !isPhantomClass(elemtp.typeSymbol)) nme.wrapRefArray
else nme.genericWrapArray
}
@@ -638,14 +667,14 @@ trait Definitions extends reflect.api.StandardDefinitions {
case _ => false
})
}
-
+
// members of class scala.Any
- lazy val Any_== = newMethod(AnyClass, nme.EQ, anyparam, booltype, FINAL)
- lazy val Any_!= = newMethod(AnyClass, nme.NE, anyparam, booltype, FINAL)
- lazy val Any_equals = newMethod(AnyClass, nme.equals_, anyparam, booltype)
- lazy val Any_hashCode = newMethod(AnyClass, nme.hashCode_, Nil, inttype)
- lazy val Any_toString = newMethod(AnyClass, nme.toString_, Nil, stringtype)
- lazy val Any_## = newMethod(AnyClass, nme.HASHHASH, Nil, inttype, FINAL)
+ lazy val Any_== = enterNewMethod(AnyClass, nme.EQ, anyparam, booltype, FINAL)
+ lazy val Any_!= = enterNewMethod(AnyClass, nme.NE, anyparam, booltype, FINAL)
+ lazy val Any_equals = enterNewMethod(AnyClass, nme.equals_, anyparam, booltype)
+ lazy val Any_hashCode = enterNewMethod(AnyClass, nme.hashCode_, Nil, inttype)
+ lazy val Any_toString = enterNewMethod(AnyClass, nme.toString_, Nil, stringtype)
+ lazy val Any_## = enterNewMethod(AnyClass, nme.HASHHASH, Nil, inttype, FINAL)
// Any_getClass requires special handling. The return type is determined on
// a per-call-site basis as if the function being called were actually:
@@ -656,22 +685,55 @@ trait Definitions extends reflect.api.StandardDefinitions {
// Since getClass is not actually a polymorphic method, this requires compiler
// participation. At the "Any" level, the return type is Class[_] as it is in
// java.lang.Object. Java also special cases the return type.
- lazy val Any_getClass = newMethod(AnyClass, nme.getClass_, Nil, getMember(ObjectClass, nme.getClass_).tpe.resultType, DEFERRED)
+ lazy val Any_getClass = enterNewMethod(AnyClass, nme.getClass_, Nil, getMember(ObjectClass, nme.getClass_).tpe.resultType, DEFERRED)
lazy val Any_isInstanceOf = newT1NullaryMethod(AnyClass, nme.isInstanceOf_, FINAL)(_ => booltype)
lazy val Any_asInstanceOf = newT1NullaryMethod(AnyClass, nme.asInstanceOf_, FINAL)(_.typeConstructor)
+ // A type function from T => Class[U], used to determine the return
+ // type of getClass calls. The returned type is:
+ //
+ // 1. If T is a value type, Class[T].
+ // 2. If T is a phantom type (Any or AnyVal), Class[_].
+ // 3. If T is a local class, Class[_ <: |T|].
+ // 4. Otherwise, Class[_ <: T].
+ //
+ // Note: AnyVal cannot be Class[_ <: AnyVal] because if the static type of the
+ // receiver is AnyVal, it implies the receiver is boxed, so the correct
+ // class object is that of java.lang.Integer, not Int.
+ //
+ // TODO: If T is final, return type could be Class[T]. Should it?
+ def getClassReturnType(tp: Type): Type = {
+ val sym = tp.typeSymbol
+
+ if (phase.erasedTypes) ClassClass.tpe
+ else if (isValueClass(sym)) ClassType(tp.widen)
+ else {
+ val eparams = typeParamsToExistentials(ClassClass, ClassClass.typeParams)
+ val upperBound = (
+ if (isPhantomClass(sym)) AnyClass.tpe
+ else if (sym.isLocalClass) erasure.intersectionDominator(tp.parents)
+ else tp.widen
+ )
+
+ existentialAbstraction(
+ eparams,
+ ClassType(eparams.head setInfo TypeBounds.upper(upperBound) tpe)
+ )
+ }
+ }
+
// members of class java.lang.{ Object, String }
- lazy val Object_## = newMethod(ObjectClass, nme.HASHHASH, Nil, inttype, FINAL)
- lazy val Object_== = newMethod(ObjectClass, nme.EQ, anyrefparam, booltype, FINAL)
- lazy val Object_!= = newMethod(ObjectClass, nme.NE, anyrefparam, booltype, FINAL)
- lazy val Object_eq = newMethod(ObjectClass, nme.eq, anyrefparam, booltype, FINAL)
- lazy val Object_ne = newMethod(ObjectClass, nme.ne, anyrefparam, booltype, FINAL)
+ lazy val Object_## = enterNewMethod(ObjectClass, nme.HASHHASH, Nil, inttype, FINAL)
+ lazy val Object_== = enterNewMethod(ObjectClass, nme.EQ, anyrefparam, booltype, FINAL)
+ lazy val Object_!= = enterNewMethod(ObjectClass, nme.NE, anyrefparam, booltype, FINAL)
+ lazy val Object_eq = enterNewMethod(ObjectClass, nme.eq, anyrefparam, booltype, FINAL)
+ lazy val Object_ne = enterNewMethod(ObjectClass, nme.ne, anyrefparam, booltype, FINAL)
lazy val Object_isInstanceOf = newT1NoParamsMethod(ObjectClass, nme.isInstanceOf_Ob, FINAL | SYNTHETIC)(_ => booltype)
lazy val Object_asInstanceOf = newT1NoParamsMethod(ObjectClass, nme.asInstanceOf_Ob, FINAL | SYNTHETIC)(_.typeConstructor)
- lazy val Object_synchronized = newPolyMethod(1, ObjectClass, nme.synchronized_, FINAL)(tps =>
+ lazy val Object_synchronized = newPolyMethod(1, ObjectClass, nme.synchronized_, FINAL)(tps =>
(Some(List(tps.head.typeConstructor)), tps.head.typeConstructor)
)
- lazy val String_+ = newMethod(StringClass, nme.raw.PLUS, anyparam, stringtype, FINAL)
+ lazy val String_+ = enterNewMethod(StringClass, nme.raw.PLUS, anyparam, stringtype, FINAL)
def Object_getClass = getMember(ObjectClass, nme.getClass_)
def Object_clone = getMember(ObjectClass, nme.clone_)
@@ -756,7 +818,7 @@ trait Definitions extends reflect.api.StandardDefinitions {
)
lazy val AnnotationDefaultAttr: Symbol = {
- val attr = newClass(RuntimePackageClass, tpnme.AnnotationDefaultATTR, List(AnnotationClass.typeConstructor))
+ val attr = enterNewClass(RuntimePackageClass, tpnme.AnnotationDefaultATTR, List(AnnotationClass.typeConstructor))
// This attribute needs a constructor so that modifiers in parsed Java code make sense
attr.info.decls enter attr.newClassConstructor(NoPosition)
attr
@@ -776,10 +838,10 @@ trait Definitions extends reflect.api.StandardDefinitions {
while (result.isAliasType) result = result.info.typeSymbol
result
}
-
+
def getRequiredModule(fullname: String): Symbol =
getModule(newTermNameCached(fullname))
- def getRequiredClass(fullname: String): Symbol =
+ def getRequiredClass(fullname: String): Symbol =
getClass(newTypeNameCached(fullname))
def getClassIfDefined(fullname: String): Symbol =
@@ -828,15 +890,15 @@ trait Definitions extends reflect.api.StandardDefinitions {
private def newAlias(owner: Symbol, name: TypeName, alias: Type): Symbol =
owner.newAliasType(name) setInfoAndEnter alias
-
+
private def specialPolyClass(name: TypeName, flags: Long)(parentFn: Symbol => Type): Symbol = {
- val clazz = newClass(ScalaPackageClass, name, Nil)
+ val clazz = enterNewClass(ScalaPackageClass, name, Nil)
val tparam = clazz.newSyntheticTypeParam("T0", flags)
val parents = List(AnyRefClass.tpe, parentFn(tparam))
-
- clazz setInfo polyType(List(tparam), ClassInfoType(parents, newScope, clazz))
+
+ clazz setInfo GenPolyType(List(tparam), ClassInfoType(parents, newScope, clazz))
}
-
+
def newPolyMethod(typeParamCount: Int, owner: Symbol, name: TermName, flags: Long)(createFn: PolyMethodCreator): Symbol = {
val msym = owner.newMethod(name.encode, NoPosition, flags)
val tparams = msym.newSyntheticTypeParams(typeParamCount)
@@ -847,7 +909,7 @@ trait Definitions extends reflect.api.StandardDefinitions {
msym setInfoAndEnter polyType(tparams, mtpe)
}
-
+
/** T1 means one type parameter.
*/
def newT1NullaryMethod(owner: Symbol, name: TermName, flags: Long)(createFn: Symbol => Type): Symbol = {
@@ -870,6 +932,12 @@ trait Definitions extends reflect.api.StandardDefinitions {
private lazy val scalaValueClassesSet = ScalaValueClasses.toSet
private lazy val boxedValueClassesSet = boxedClass.values.toSet + BoxedUnitClass
+ /** Now that AnyVal is unsealing we need less ambiguous names
+ * for when we need to distinguish the Nine Original AnyVals
+ * from the heathen masses.
+ */
+ def isPrimitiveValueClass(sym: Symbol) = scalaValueClassesSet(sym)
+
/** Is symbol a value class? */
def isValueClass(sym: Symbol) = scalaValueClassesSet(sym)
def isNonUnitValueClass(sym: Symbol) = (sym != UnitClass) && isValueClass(sym)
@@ -953,7 +1021,7 @@ trait Definitions extends reflect.api.StandardDefinitions {
RootClass.info.decls enter EmptyPackage
RootClass.info.decls enter RootPackage
-
+
val forced = List( // force initialization of every symbol that is entered as a side effect
AnnotationDefaultAttr, // #2264
RepeatedParamClass,
@@ -983,12 +1051,18 @@ trait Definitions extends reflect.api.StandardDefinitions {
Object_synchronized,
Object_isInstanceOf,
Object_asInstanceOf,
- String_+
+ //AnyVal_getClass,
+ String_+,
+ ComparableClass
)
- /** Removing the anyref parent they acquire from having a source file.
+ /* Removing the anyref parent they acquire from having a source file.
*/
- setParents(AnyValClass, anyparam)
+ if (oldValueScheme) {
+ setParents(AnyValClass, List(NotNullClass.tpe, AnyClass.tpe))
+ } else {
+ AnyVal_getClass // force it!
+ }
ScalaValueClasses foreach { sym =>
setParents(sym, anyvalparam)
}
@@ -1005,7 +1079,7 @@ trait Definitions extends reflect.api.StandardDefinitions {
// tparam => resultType, which is the resultType of PolyType, i.e. the result type after applying the
// type parameter =-> a MethodType in this case
// TODO: set type bounds manually (-> MulticastDelegate), see newTypeParam
- val newCaller = newMethod(DelegateClass, name, paramTypes, delegateType, FINAL | STATIC)
+ val newCaller = enterNewMethod(DelegateClass, name, paramTypes, delegateType, FINAL | STATIC)
// val newCaller = newPolyMethod(DelegateClass, name,
// tparam => MethodType(paramTypes, tparam.typeConstructor)) setFlag (FINAL | STATIC)
Delegate_scalaCallers = Delegate_scalaCallers ::: List(newCaller)
diff --git a/src/compiler/scala/reflect/internal/Importers.scala b/src/compiler/scala/reflect/internal/Importers.scala
index 6c843e6f15..b36191b025 100644
--- a/src/compiler/scala/reflect/internal/Importers.scala
+++ b/src/compiler/scala/reflect/internal/Importers.scala
@@ -70,7 +70,7 @@ trait Importers { self: SymbolTable =>
case from.PolyType(_, res) => res
case result => result
}
- s setInfo polyType(mytypeParams, importType(result))
+ s setInfo GenPolyType(mytypeParams, importType(result))
s setAnnotations (sym.annotations map importAnnotationInfo)
}
}
@@ -157,7 +157,7 @@ trait Importers { self: SymbolTable =>
val myclazz = importSymbol(clazz)
val myscope = if (myclazz.isPackageClass) newPackageScope(myclazz) else newScope
val myclazzTpe = ClassInfoType(parents map importType, myscope, myclazz)
- myclazz setInfo polyType(myclazz.typeParams, myclazzTpe) // needed so that newly created symbols find their scope
+ myclazz setInfo GenPolyType(myclazz.typeParams, myclazzTpe) // needed so that newly created symbols find their scope
decls foreach importSymbol // will enter itself into myclazz
myclazzTpe
case from.RefinedType(parents, decls) =>
diff --git a/src/compiler/scala/reflect/internal/StdNames.scala b/src/compiler/scala/reflect/internal/StdNames.scala
index b1a24c0be2..c3a7dc23f3 100644
--- a/src/compiler/scala/reflect/internal/StdNames.scala
+++ b/src/compiler/scala/reflect/internal/StdNames.scala
@@ -143,7 +143,6 @@ trait StdNames extends NameManglers { self: SymbolTable =>
final val Object: NameType = "Object"
final val PartialFunction: NameType = "PartialFunction"
final val Product: NameType = "Product"
- final val ScalaObject: NameType = "ScalaObject"
final val Serializable: NameType = "Serializable"
final val Singleton: NameType = "Singleton"
final val String: NameType = "String"
diff --git a/src/compiler/scala/reflect/internal/SymbolTable.scala b/src/compiler/scala/reflect/internal/SymbolTable.scala
index fb827b0658..2e799f914a 100644
--- a/src/compiler/scala/reflect/internal/SymbolTable.scala
+++ b/src/compiler/scala/reflect/internal/SymbolTable.scala
@@ -164,7 +164,7 @@ abstract class SymbolTable extends api.Universe
}
// enter decls of parent classes
for (p <- container.parentSymbols) {
- if (p != definitions.ObjectClass && p != definitions.ScalaObjectClass) {
+ if (p != definitions.ObjectClass) {
openPackageModule(p, dest)
}
}
diff --git a/src/compiler/scala/reflect/internal/Symbols.scala b/src/compiler/scala/reflect/internal/Symbols.scala
index e777491300..415b32958d 100644
--- a/src/compiler/scala/reflect/internal/Symbols.scala
+++ b/src/compiler/scala/reflect/internal/Symbols.scala
@@ -489,6 +489,8 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
// class C extends D( { class E { ... } ... } ). Here, E is a class local to a constructor
final def isClassLocalToConstructor = isClass && hasFlag(INCONSTRUCTOR)
+ final def isInlineClass = isClass && hasAnnotation(ScalaInlineClass)
+
final def isAnonymousClass = isClass && (name containsName tpnme.ANON_CLASS_NAME)
final def isAnonymousFunction = isSynthetic && (name containsName tpnme.ANON_FUN_NAME)
final def isAnonOrRefinementClass = isAnonymousClass || isRefinementClass
@@ -2477,7 +2479,7 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
final override def isAbstractType = false
final override def isAliasType = false
- override def existentialBound = polyType(this.typeParams, TypeBounds.upper(this.classBound))
+ override def existentialBound = GenPolyType(this.typeParams, TypeBounds.upper(this.classBound))
override def sourceFile =
if (owner.isPackageClass) source
@@ -2707,7 +2709,7 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
/** An exception for cyclic references of symbol definitions */
case class CyclicReference(sym: Symbol, info: Type)
extends TypeError("illegal cyclic reference involving " + sym) {
- // printStackTrace() // debug
+ if (settings.debug.value) printStackTrace()
}
case class InvalidCompanions(sym1: Symbol, sym2: Symbol) extends Throwable(
diff --git a/src/compiler/scala/reflect/internal/TreeGen.scala b/src/compiler/scala/reflect/internal/TreeGen.scala
index e537c6b83f..d0c5bc8e5b 100644
--- a/src/compiler/scala/reflect/internal/TreeGen.scala
+++ b/src/compiler/scala/reflect/internal/TreeGen.scala
@@ -12,7 +12,6 @@ abstract class TreeGen {
def scalaDot(name: Name) = Select(Ident(nme.scala_) setSymbol ScalaPackage, name)
def scalaAnyRefConstr = scalaDot(tpnme.AnyRef)
def scalaUnitConstr = scalaDot(tpnme.Unit)
- def scalaScalaObjectConstr = scalaDot(tpnme.ScalaObject)
def productConstr = scalaDot(tpnme.Product)
def serializableConstr = scalaDot(tpnme.Serializable)
diff --git a/src/compiler/scala/reflect/internal/TreeInfo.scala b/src/compiler/scala/reflect/internal/TreeInfo.scala
index e3ee39d2a0..ecd31c784d 100644
--- a/src/compiler/scala/reflect/internal/TreeInfo.scala
+++ b/src/compiler/scala/reflect/internal/TreeInfo.scala
@@ -440,15 +440,6 @@ abstract class TreeInfo {
EmptyTree
}
- /** Is the tree Predef, scala.Predef, or _root_.scala.Predef?
- */
- def isPredefExpr(t: Tree) = t match {
- case Ident(nme.Predef) => true
- case Select(Ident(nme.scala_), nme.Predef) => true
- case Select(Select(Ident(nme.ROOTPKG), nme.scala_), nme.Predef) => true
- case _ => false
- }
-
/** Does list of trees start with a definition of
* a class of module with given name (ignoring imports)
*/
@@ -468,7 +459,7 @@ abstract class TreeInfo {
// Top-level definition whose leading imports include Predef.
def containsLeadingPredefImport(defs: List[Tree]): Boolean = defs match {
case PackageDef(_, defs1) :: _ => containsLeadingPredefImport(defs1)
- case Import(expr, _) :: rest => isPredefExpr(expr) || containsLeadingPredefImport(rest)
+ case Import(expr, _) :: rest => isReferenceToPredef(expr) || containsLeadingPredefImport(rest)
case _ => false
}
@@ -479,7 +470,6 @@ abstract class TreeInfo {
}
( isUnitInScala(body, nme.Predef)
- || isUnitInScala(body, tpnme.ScalaObject)
|| containsLeadingPredefImport(List(body)))
}
diff --git a/src/compiler/scala/reflect/internal/TreePrinters.scala b/src/compiler/scala/reflect/internal/TreePrinters.scala
index 63e4c9f1fa..e7ba0c793d 100644
--- a/src/compiler/scala/reflect/internal/TreePrinters.scala
+++ b/src/compiler/scala/reflect/internal/TreePrinters.scala
@@ -245,6 +245,10 @@ trait TreePrinters extends api.TreePrinters { self: SymbolTable =>
case Template(parents, self, body) =>
val currentOwner1 = currentOwner
if (tree.symbol != NoSymbol) currentOwner = tree.symbol.owner
+ if (parents exists isReferenceToAnyVal) {
+ print("AnyVal")
+ }
+ else {
printRow(parents, " with ")
if (!body.isEmpty) {
if (self.name != nme.WILDCARD) {
@@ -256,6 +260,7 @@ trait TreePrinters extends api.TreePrinters { self: SymbolTable =>
}
printColumn(body, "", ";", "}")
}
+ }
currentOwner = currentOwner1
case Block(stats, expr) =>
diff --git a/src/compiler/scala/reflect/internal/Trees.scala b/src/compiler/scala/reflect/internal/Trees.scala
index ca7801ac9d..0004311647 100644
--- a/src/compiler/scala/reflect/internal/Trees.scala
+++ b/src/compiler/scala/reflect/internal/Trees.scala
@@ -11,6 +11,18 @@ import api.Modifier
trait Trees extends api.Trees { self: SymbolTable =>
+ // Belongs in TreeInfo but then I can't reach it from TreePrinters.
+ def isReferenceToScalaMember(t: Tree, Id: Name) = t match {
+ case Ident(Id) => true
+ case Select(Ident(nme.scala_), Id) => true
+ case Select(Select(Ident(nme.ROOTPKG), nme.scala_), Id) => true
+ case _ => false
+ }
+ /** Is the tree Predef, scala.Predef, or _root_.scala.Predef?
+ */
+ def isReferenceToPredef(t: Tree) = isReferenceToScalaMember(t, nme.Predef)
+ def isReferenceToAnyVal(t: Tree) = isReferenceToScalaMember(t, tpnme.AnyVal)
+
// --- modifiers implementation ---------------------------------------
/** @param privateWithin the qualifier for a private (a type name)
@@ -122,11 +134,14 @@ trait Trees extends api.Trees { self: SymbolTable =>
}
}
- def substTreeSyms(pairs: (Symbol, Symbol)*): Tree = {
- val list = pairs.toList
- val subst = new TreeSymSubstituter(list map (_._1), list map (_._2))
- subst(tree)
- }
+ def substTreeSyms(pairs: (Symbol, Symbol)*): Tree =
+ substTreeSyms(pairs.map(_._1).toList, pairs.map(_._2).toList)
+
+ def substTreeSyms(from: List[Symbol], to: List[Symbol]): Tree =
+ new TreeSymSubstituter(from, to)(tree)
+
+ def substTreeThis(clazz: Symbol, to: Tree): Tree = new ThisSubstituter(clazz, to) transform tree
+
def shallowDuplicate: Tree = new ShallowDuplicator(tree) transform tree
def shortClass: String = tree.getClass.getName split "[.$]" last
@@ -338,6 +353,13 @@ trait Trees extends api.Trees { self: SymbolTable =>
override def toString = substituterString("Symbol", "Tree", from, to)
}
+ class ThisSubstituter(clazz: Symbol, to: => Tree) extends Transformer {
+ override def transform(tree: Tree) = tree match {
+ case This(_) if tree.symbol == clazz => to
+ case _ => super.transform(tree)
+ }
+ }
+
class TypeMapTreeSubstituter(val typeMap: TypeMap) extends Traverser {
override def traverse(tree: Tree) {
if (tree.tpe ne null)
diff --git a/src/compiler/scala/reflect/internal/Types.scala b/src/compiler/scala/reflect/internal/Types.scala
index 4e842c05da..3ed6544613 100644
--- a/src/compiler/scala/reflect/internal/Types.scala
+++ b/src/compiler/scala/reflect/internal/Types.scala
@@ -65,6 +65,8 @@ import util.Statistics._
// inst is the instantiation and constr is a list of bounds.
case DeBruijnIndex(level, index)
// for dependent method types: a type referring to a method parameter.
+ case ErasedInlineType(tp)
+ // only used during erasure of inline classes.
*/
trait Types extends api.Types { self: SymbolTable =>
@@ -1417,7 +1419,7 @@ trait Types extends api.Types { self: SymbolTable =>
}
protected def defineBaseTypeSeqOfCompoundType(tpe: CompoundType) = {
- val period = tpe.baseTypeSeqPeriod;
+ val period = tpe.baseTypeSeqPeriod
if (period != currentPeriod) {
tpe.baseTypeSeqPeriod = currentPeriod
if (!isValidForBaseClasses(period)) {
@@ -3067,6 +3069,15 @@ trait Types extends api.Types { self: SymbolTable =>
"De Bruijn "+kind+"("+(pnames mkString ",")+";"+(ptypes mkString ",")+";"+restpe+")"
}
}
+
+ abstract case class ErasedInlineType(sym: Symbol) extends Type
+
+ final class UniqueErasedInlineType(sym: Symbol) extends ErasedInlineType(sym) with UniqueType
+
+ object ErasedInlineType {
+ def apply(sym: Symbol): Type =
+ unique(new UniqueErasedInlineType(sym))
+ }
/** A class representing an as-yet unevaluated type.
*/
@@ -3260,7 +3271,7 @@ trait Types extends api.Types { self: SymbolTable =>
case _ => abort(debugString(tycon))
}
- /** A creator for type parameterizations that strips empty type parameter lists.
+ /** A creator and extractor for type parameterizations that strips empty type parameter lists.
* Use this factory method to indicate the type has kind * (it's a polymorphic value)
* until we start tracking explicit kinds equivalent to typeFun (except that the latter requires tparams nonEmpty).
*
@@ -3269,9 +3280,18 @@ trait Types extends api.Types { self: SymbolTable =>
* can we instead say this is the canonical creator for polyTypes which
* may or may not be poly? (It filched the standard "canonical creator" name.)
*/
- def polyType(tparams: List[Symbol], tpe: Type): Type =
+ object GenPolyType {
+ def apply(tparams: List[Symbol], tpe: Type): Type =
if (tparams nonEmpty) typeFun(tparams, tpe)
else tpe // it's okay to be forgiving here
+ def unapply(tpe: Type): Option[(List[Symbol], Type)] = tpe match {
+ case PolyType(tparams, restpe) => Some(tparams, restpe)
+ case _ => Some(List(), tpe)
+ }
+ }
+
+ @deprecated("use GenPolyType(...) instead")
+ def polyType(params: List[Symbol], tpe: Type): Type = GenPolyType(params, tpe)
/** A creator for anonymous type functions, where the symbol for the type function still needs to be created.
*
@@ -3723,6 +3743,7 @@ trait Types extends api.Types { self: SymbolTable =>
case WildcardType => tp
case NoType => tp
case NoPrefix => tp
+ case ErasedSingleType(sym) => tp
*/
case _ =>
tp
@@ -6392,7 +6413,9 @@ trait Types extends api.Types { self: SymbolTable =>
// but that would be a big change. Left for further refactoring.
/** An exception for cyclic references from which we can recover */
case class RecoverableCyclicReference(sym: Symbol)
- extends TypeError("illegal cyclic reference involving " + sym)
+ extends TypeError("illegal cyclic reference involving " + sym) {
+ if (settings.debug.value) printStackTrace()
+ }
class NoCommonType(tps: List[Type]) extends Throwable(
"lub/glb of incompatible types: " + tps.mkString("", " and ", "")) with ControlThrowable
diff --git a/src/compiler/scala/reflect/internal/transform/Erasure.scala b/src/compiler/scala/reflect/internal/transform/Erasure.scala
index d59fc6d564..4775541855 100644
--- a/src/compiler/scala/reflect/internal/transform/Erasure.scala
+++ b/src/compiler/scala/reflect/internal/transform/Erasure.scala
@@ -63,6 +63,13 @@ trait Erasure {
if (cls.owner.isClass) cls.owner.tpe else pre // why not cls.isNestedClass?
}
+ protected def unboxInlineType(clazz: Symbol): Type =
+ clazz.primaryConstructor.info.params.head.tpe
+
+ protected def eraseInlineClassRef(clazz: Symbol): Type = {
+ scalaErasure(unboxInlineType(clazz))
+ }
+
abstract class ErasureMap extends TypeMap {
def mergeParents(parents: List[Type]): Type
@@ -80,6 +87,7 @@ trait Erasure {
else if (sym == AnyClass || sym == AnyValClass || sym == SingletonClass || sym == NotNullClass) erasedTypeRef(ObjectClass)
else if (sym == UnitClass) erasedTypeRef(BoxedUnitClass)
else if (sym.isRefinementClass) apply(mergeParents(tp.parents))
+ //else if (sym.isInlineClass) eraseInlineClassRef(sym)
else if (sym.isClass) typeRef(apply(rebindInnerClass(pre, sym)), sym, List()) // #2585
else apply(sym.info) // alias type or abstract type
case PolyType(tparams, restpe) =>
@@ -101,7 +109,7 @@ trait Erasure {
ClassInfoType(
if (clazz == ObjectClass || isValueClass(clazz)) Nil
else if (clazz == ArrayClass) List(erasedTypeRef(ObjectClass))
- else removeDoubleObject(parents map this),
+ else removeLaterObjects(parents map this),
decls, clazz)
case _ =>
mapOver(tp)
@@ -220,11 +228,9 @@ trait Erasure {
typeRef(erasure(sym, sym.owner.tpe), sym, List())
/** Remove duplicate references to class Object in a list of parent classes */
- private def removeDoubleObject(tps: List[Type]): List[Type] = tps match {
- case List() => List()
- case tp :: tps1 =>
- if (tp.typeSymbol == ObjectClass) tp :: tps1.filter(_.typeSymbol != ObjectClass)
- else tp :: removeDoubleObject(tps1)
+ private def removeLaterObjects(tps: List[Type]): List[Type] = tps match {
+ case tp :: rest => tp :: (rest filter (_.typeSymbol != ObjectClass))
+ case _ => tps
}
/** The symbol's erased info. This is the type's erasure, except for the following symbols:
diff --git a/src/compiler/scala/reflect/runtime/JavaToScala.scala b/src/compiler/scala/reflect/runtime/JavaToScala.scala
index 4c49c0221f..89fd6bab64 100644
--- a/src/compiler/scala/reflect/runtime/JavaToScala.scala
+++ b/src/compiler/scala/reflect/runtime/JavaToScala.scala
@@ -186,7 +186,7 @@ trait JavaToScala extends ConversionUtil { self: SymbolTable =>
} finally {
parentsLevel -= 1
}
- clazz setInfo polyType(tparams, new ClassInfoType(parents, newScope, clazz))
+ clazz setInfo GenPolyType(tparams, new ClassInfoType(parents, newScope, clazz))
if (module != NoSymbol) {
module.moduleClass setInfo new ClassInfoType(List(), newScope, module.moduleClass)
}
@@ -534,7 +534,7 @@ trait JavaToScala extends ConversionUtil { self: SymbolTable =>
}
private def setMethType(meth: Symbol, tparams: List[Symbol], paramtpes: List[Type], restpe: Type) = {
- meth setInfo polyType(tparams, MethodType(meth.owner.newSyntheticValueParams(paramtpes map objToAny), restpe))
+ meth setInfo GenPolyType(tparams, MethodType(meth.owner.newSyntheticValueParams(paramtpes map objToAny), restpe))
}
/**
@@ -572,7 +572,7 @@ trait JavaToScala extends ConversionUtil { self: SymbolTable =>
val tparams = jconstr.getTypeParameters.toList map createTypeParameter
val paramtpes = jconstr.getGenericParameterTypes.toList map typeToScala
setMethType(constr, tparams, paramtpes, clazz.tpe)
- constr setInfo polyType(tparams, MethodType(clazz.newSyntheticValueParams(paramtpes), clazz.tpe))
+ constr setInfo GenPolyType(tparams, MethodType(clazz.newSyntheticValueParams(paramtpes), clazz.tpe))
copyAnnotations(constr, jconstr)
constr
}
diff --git a/src/compiler/scala/reflect/runtime/ToolBoxes.scala b/src/compiler/scala/reflect/runtime/ToolBoxes.scala
index 6e671ae06e..70a3061fc7 100644
--- a/src/compiler/scala/reflect/runtime/ToolBoxes.scala
+++ b/src/compiler/scala/reflect/runtime/ToolBoxes.scala
@@ -59,7 +59,7 @@ trait ToolBoxes extends { self: Universe =>
def wrapInObject(expr: Tree, fvs: List[Symbol]): ModuleDef = {
val obj = EmptyPackageClass.newModule(nextWrapperModuleName())
- val minfo = ClassInfoType(List(ObjectClass.tpe, ScalaObjectClass.tpe), newScope, obj.moduleClass)
+ val minfo = ClassInfoType(List(ObjectClass.tpe), newScope, obj.moduleClass)
obj.moduleClass setInfo minfo
obj setInfo obj.moduleClass.tpe
val meth = obj.moduleClass.newMethod(newTermName(wrapperMethodName))
diff --git a/src/compiler/scala/tools/cmd/gen/AnyVals.scala b/src/compiler/scala/tools/cmd/gen/AnyVals.scala
index 8f82c997db..ab4a4a4402 100644
--- a/src/compiler/scala/tools/cmd/gen/AnyVals.scala
+++ b/src/compiler/scala/tools/cmd/gen/AnyVals.scala
@@ -182,7 +182,7 @@ trait AnyValReps {
def classLines: List[String]
def objectLines: List[String]
def commonClassLines = List(
- "def getClass(): Class[@name@]"
+ "override def getClass(): Class[@name@]"
)
def lcname = name.toLowerCase
@@ -429,7 +429,7 @@ def &(x: Boolean): Boolean = sys.error("stub")
*/
def ^(x: Boolean): Boolean = sys.error("stub")
-def getClass(): Class[Boolean] = sys.error("stub")
+override def getClass(): Class[Boolean] = sys.error("stub")
""".trim.lines.toList
def objectLines = interpolate(allCompanions).lines.toList
@@ -443,7 +443,7 @@ def getClass(): Class[Boolean] = sys.error("stub")
*/
"""
def classLines = List(
- """def getClass(): Class[Unit] = sys.error("stub")"""
+ """override def getClass(): Class[Unit] = sys.error("stub")"""
)
def objectLines = interpolate(allCompanions).lines.toList
diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala
index 797ed7e047..8e5ca2156a 100644
--- a/src/compiler/scala/tools/nsc/Global.scala
+++ b/src/compiler/scala/tools/nsc/Global.scala
@@ -436,66 +436,72 @@ class Global(var currentSettings: Settings, var reporter: Reporter) extends Symb
val global: Global.this.type = Global.this
} with Analyzer
+ object extensionMethods extends {
+ val global: Global.this.type = Global.this
+ val runsAfter = List("typer")
+ val runsRightAfter = None
+ } with ExtensionMethods
+
// phaseName = "superaccessors"
object superAccessors extends {
val global: Global.this.type = Global.this
- val runsAfter = List[String]("typer")
+ val runsAfter = List("typer")
val runsRightAfter = None
} with SuperAccessors
// phaseName = "pickler"
object pickler extends {
val global: Global.this.type = Global.this
- val runsAfter = List[String]("superaccessors")
+ val runsAfter = List("superaccessors")
val runsRightAfter = None
} with Pickler
// phaseName = "refchecks"
override object refChecks extends {
val global: Global.this.type = Global.this
- val runsAfter = List[String]("pickler")
+ val runsAfter = List("pickler")
val runsRightAfter = None
} with RefChecks
// phaseName = "liftcode"
object liftcode extends {
val global: Global.this.type = Global.this
- val runsAfter = List[String]("refchecks")
+ val runsAfter = List("refchecks")
val runsRightAfter = None
} with LiftCode
// phaseName = "uncurry"
override object uncurry extends {
val global: Global.this.type = Global.this
- val runsAfter = List[String]("refchecks", "liftcode")
+ val runsAfter = List("refchecks", "liftcode")
val runsRightAfter = None
} with UnCurry
// phaseName = "tailcalls"
object tailCalls extends {
val global: Global.this.type = Global.this
- val runsAfter = List[String]("uncurry")
+ val runsAfter = List("uncurry")
val runsRightAfter = None
} with TailCalls
// phaseName = "explicitouter"
object explicitOuter extends {
val global: Global.this.type = Global.this
- val runsAfter = List[String]("tailcalls")
+ val runsAfter = List("tailcalls")
val runsRightAfter = None
} with ExplicitOuter
// phaseName = "specialize"
object specializeTypes extends {
val global: Global.this.type = Global.this
- val runsAfter = List[String]("")
+ val runsAfter = List("")
val runsRightAfter = Some("tailcalls")
} with SpecializeTypes
// phaseName = "erasure"
override object erasure extends {
val global: Global.this.type = Global.this
- val runsAfter = List[String]("explicitouter")
+ val runsAfter = List("explicitouter")
val runsRightAfter = Some("explicitouter")
} with Erasure
@@ -503,84 +509,84 @@ class Global(var currentSettings: Settings, var reporter: Reporter) extends Symb
object lazyVals extends {
final val FLAGS_PER_WORD = 32
val global: Global.this.type = Global.this
- val runsAfter = List[String]("erasure")
+ val runsAfter = List("erasure")
val runsRightAfter = None
} with LazyVals
// phaseName = "lambdalift"
object lambdaLift extends {
val global: Global.this.type = Global.this
- val runsAfter = List[String]("lazyvals")
+ val runsAfter = List("lazyvals")
val runsRightAfter = None
} with LambdaLift
// phaseName = "constructors"
object constructors extends {
val global: Global.this.type = Global.this
- val runsAfter = List[String]("lambdalift")
+ val runsAfter = List("lambdalift")
val runsRightAfter = None
} with Constructors
// phaseName = "flatten"
object flatten extends {
val global: Global.this.type = Global.this
- val runsAfter = List[String]("constructors")
+ val runsAfter = List("constructors")
val runsRightAfter = None
} with Flatten
// phaseName = "mixin"
object mixer extends {
val global: Global.this.type = Global.this
- val runsAfter = List[String]("flatten", "constructors")
+ val runsAfter = List("flatten", "constructors")
val runsRightAfter = None
} with Mixin
// phaseName = "cleanup"
object cleanup extends {
val global: Global.this.type = Global.this
- val runsAfter = List[String]("mixin")
+ val runsAfter = List("mixin")
val runsRightAfter = None
} with CleanUp
// phaseName = "icode"
object genicode extends {
val global: Global.this.type = Global.this
- val runsAfter = List[String]("cleanup")
+ val runsAfter = List("cleanup")
val runsRightAfter = None
} with GenICode
// phaseName = "inliner"
object inliner extends {
val global: Global.this.type = Global.this
- val runsAfter = List[String]("icode")
+ val runsAfter = List("icode")
val runsRightAfter = None
} with Inliners
// phaseName = "inlineExceptionHandlers"
object inlineExceptionHandlers extends {
val global: Global.this.type = Global.this
- val runsAfter = List[String]("inliner")
+ val runsAfter = List("inliner")
val runsRightAfter = None
} with InlineExceptionHandlers
// phaseName = "closelim"
object closureElimination extends {
val global: Global.this.type = Global.this
- val runsAfter = List[String]("inlineExceptionHandlers")
+ val runsAfter = List("inlineExceptionHandlers")
val runsRightAfter = None
} with ClosureElimination
// phaseName = "dce"
object deadCode extends {
val global: Global.this.type = Global.this
- val runsAfter = List[String]("closelim")
+ val runsAfter = List("closelim")
val runsRightAfter = None
} with DeadCodeElimination
// phaseName = "jvm"
object genJVM extends {
val global: Global.this.type = Global.this
- val runsAfter = List[String]("dce")
+ val runsAfter = List("dce")
val runsRightAfter = None
} with GenJVM
@@ -596,7 +602,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter) extends Symb
object terminal extends {
val global: Global.this.type = Global.this
val phaseName = "terminal"
- val runsAfter = List[String]("jvm", "msil")
+ val runsAfter = List("jvm", "msil")
val runsRightAfter = None
} with SubComponent {
private var cache: Option[GlobalPhase] = None
@@ -650,6 +656,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter) extends Symb
analyzer.packageObjects -> "load package objects",
analyzer.typerFactory -> "the meat and potatoes: type the trees",
superAccessors -> "add super accessors in traits and nested classes",
+ extensionMethods -> "add extension methods for inline classes",
pickler -> "serialize symbol tables",
refChecks -> "reference/override checking, translate nested objects",
liftcode -> "reify trees",
@@ -1024,6 +1031,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter) extends Symb
val namerPhase = phaseNamed("namer")
// packageobjects
val typerPhase = phaseNamed("typer")
+ val inlineclassesPhase = phaseNamed("inlineclasses")
// superaccessors
val picklerPhase = phaseNamed("pickler")
val refchecksPhase = phaseNamed("refchecks")
@@ -1353,7 +1361,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter) extends Symb
/**
* Re-orders the source files to
- * 1. ScalaObject
+ * 1. This Space Intentionally Left Blank
* 2. LowPriorityImplicits / EmbeddedControls (i.e. parents of Predef)
* 3. the rest
*
@@ -1381,7 +1389,6 @@ class Global(var currentSettings: Settings, var reporter: Reporter) extends Symb
def rank(f: SourceFile) = {
if (f.file.container.name != "scala") goLast
else f.file.name match {
- case "ScalaObject.scala" => 1
case "LowPriorityImplicits.scala" => 2
case "StandardEmbeddings.scala" => 2
case "EmbeddedControls.scala" => 2
diff --git a/src/compiler/scala/tools/nsc/ast/TreeInfo.scala b/src/compiler/scala/tools/nsc/ast/TreeInfo.scala
index b16b3c89a0..81a6659b3c 100644
--- a/src/compiler/scala/tools/nsc/ast/TreeInfo.scala
+++ b/src/compiler/scala/tools/nsc/ast/TreeInfo.scala
@@ -6,6 +6,7 @@
package scala.tools.nsc
package ast
+import reflect.internal.HasFlags
import reflect.internal.Flags._
import symtab._
@@ -41,4 +42,14 @@ abstract class TreeInfo extends reflect.internal.TreeInfo {
case ClassDef(_, `name`, _, _) :: Nil => true
case _ => super.firstDefinesClassOrObject(trees, name)
}
+
+ def isInterface(mods: HasFlags, body: List[Tree]) =
+ mods.hasTraitFlag && (body forall isInterfaceMember)
+
+ def isAllowedInAnyTrait(stat: Tree): Boolean = stat match {
+ case _: ValDef => false
+ case Import(_, _) | EmptyTree => true
+ case _: DefTree => true
+ case _ => false
+ }
}
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
index fe6dcc9138..40e7d88a3b 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
@@ -38,7 +38,7 @@ trait ParsersCommon extends ScannersCommon {
def freshTypeName(prefix: String): TypeName
def deprecationWarning(off: Int, msg: String): Unit
def accept(token: Int): Int
-
+
/** Methods inParensOrError and similar take a second argument which, should
* the next token not be the expected opener (e.g. LPAREN) will be returned
* instead of the contents of the groupers. However in all cases accept(LPAREN)
@@ -290,11 +290,11 @@ self =>
inScalaPackage = false
currentPackage = ""
}
- private lazy val anyValNames: Set[Name] = tpnme.ScalaValueNames.toSet + tpnme.AnyVal
+ private lazy val primitiveNames: Set[Name] = tpnme.ScalaValueNames.toSet
private def inScalaRootPackage = inScalaPackage && currentPackage == "scala"
private def isScalaArray(name: Name) = inScalaRootPackage && name == tpnme.Array
- private def isAnyValType(name: Name) = inScalaRootPackage && anyValNames(name)
+ private def isPrimitiveType(name: Name) = inScalaRootPackage && primitiveNames(name)
def parseStartRule: () => Tree
@@ -392,7 +392,7 @@ self =>
// object Main
def moduleName = newTermName(ScriptRunner scriptMain settings)
- def moduleBody = Template(List(scalaScalaObjectConstr), emptyValDef, List(emptyInit, mainDef))
+ def moduleBody = Template(List(scalaAnyRefConstr), emptyValDef, List(emptyInit, mainDef))
def moduleDef = ModuleDef(NoMods, moduleName, moduleBody)
// package <empty> { ... }
@@ -1141,7 +1141,7 @@ self =>
private def interpolatedString(): Tree = atPos(in.offset) {
val start = in.offset
val interpolator = in.name
-
+
val partsBuf = new ListBuffer[Tree]
val exprBuf = new ListBuffer[Tree]
in.nextToken()
@@ -1153,7 +1153,7 @@ self =>
}
}
if (in.token == STRINGLIT) partsBuf += literal()
-
+
val t1 = atPos(o2p(start)) { Ident(nme.StringContext) }
val t2 = atPos(start) { Apply(t1, partsBuf.toList) }
t2 setPos t2.pos.makeTransparent
@@ -2753,14 +2753,22 @@ self =>
val tstart0 = if (body.isEmpty && in.lastOffset < tstart) in.lastOffset else tstart
atPos(tstart0) {
- if (isAnyValType(name)) {
- val parent = if (name == tpnme.AnyVal) tpnme.Any else tpnme.AnyVal
- Template(List(scalaDot(parent)), self, body)
+ if (isPrimitiveType(name)) {
+ Template(List(scalaDot(tpnme.AnyVal)), self, body)
+ }
+ else if (parents0 exists isReferenceToAnyVal) {
+ // @inline and other restrictions enforced in refchecks
+ Template(parents0, self, body)
+ }
+ else if (name == tpnme.AnyVal) {
+ Template(List(scalaDot(tpnme.Any)), self, body)
}
else {
val parents = (
- if (!isInterface(mods, body) && !isScalaArray(name)) parents0 :+ scalaScalaObjectConstr
- else if (parents0.isEmpty) List(scalaAnyRefConstr)
+ if (parents0.isEmpty) List(scalaAnyRefConstr)
+ /*if (!isInterface(mods, body) && !isScalaArray(name))
+ parents0 /* :+ scalaScalaObjectConstr*/
+ else*/
else parents0
) ++ caseParents()
Template(parents, self, constrMods, vparamss, argss, body, o2p(tstart))
diff --git a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala
index 13f608ed4e..906932f591 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala
@@ -31,7 +31,6 @@ abstract class TreeBuilder {
def scalaDot(name: Name) = gen.scalaDot(name)
def scalaAnyRefConstr = gen.scalaAnyRefConstr
def scalaUnitConstr = gen.scalaUnitConstr
- def scalaScalaObjectConstr = gen.scalaScalaObjectConstr
def productConstr = gen.productConstr
def productConstrN(n: Int) = scalaDot(newTypeName("Product" + n))
def serializableConstr = gen.serializableConstr
diff --git a/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala b/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala
index 7eb8c393f3..ec9f705f5a 100644
--- a/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala
+++ b/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala
@@ -20,7 +20,7 @@ class ModelFactory(val global: Global, val settings: doc.Settings) {
thisFactory: ModelFactory with CommentFactory with TreeFactory =>
import global._
- import definitions.{ ObjectClass, ScalaObjectClass, RootPackage, EmptyPackage, NothingClass, AnyClass, AnyValClass, AnyRefClass }
+ import definitions.{ ObjectClass, RootPackage, EmptyPackage, NothingClass, AnyClass, AnyValClass, AnyRefClass }
private var droppedPackages = 0
def templatesCount = templatesCache.size - droppedPackages
@@ -42,7 +42,7 @@ class ModelFactory(val global: Global, val settings: doc.Settings) {
memberSym.isOmittablePrefix || (closestPackage(memberSym) == closestPackage(templateSym))
}
- private lazy val noSubclassCache = Set(AnyClass, AnyRefClass, ObjectClass, ScalaObjectClass)
+ private lazy val noSubclassCache = Set(AnyClass, AnyRefClass, ObjectClass)
/** */
def makeModel: Option[Universe] = {
@@ -217,13 +217,12 @@ class ModelFactory(val global: Global, val settings: doc.Settings) {
}
def parentType = {
if (sym.isPackage || sym == AnyClass) None else {
- val tps =
- (sym.tpe.parents filter (_ != ScalaObjectClass.tpe)) map { _.asSeenFrom(sym.thisType, sym) }
+ val tps = sym.tpe.parents map { _.asSeenFrom(sym.thisType, sym) }
Some(makeType(RefinedType(tps, EmptyScope), inTpl))
}
}
val linearization: List[(TemplateEntity, TypeEntity)] = {
- sym.ancestors filter (_ != ScalaObjectClass) map { ancestor =>
+ sym.ancestors map { ancestor =>
val typeEntity = makeType(sym.info.baseType(ancestor), this)
val tmplEntity = makeTemplate(ancestor) match {
case tmpl: DocTemplateImpl => tmpl registerSubClass this ; tmpl
@@ -316,7 +315,7 @@ class ModelFactory(val global: Global, val settings: doc.Settings) {
def normalizeTemplate(aSym: Symbol): Symbol = aSym match {
case null | EmptyPackage | NoSymbol =>
normalizeTemplate(RootPackage)
- case ScalaObjectClass | ObjectClass =>
+ case ObjectClass =>
normalizeTemplate(AnyRefClass)
case _ if aSym.isPackageObject =>
aSym
diff --git a/src/compiler/scala/tools/nsc/interpreter/MemberHandlers.scala b/src/compiler/scala/tools/nsc/interpreter/MemberHandlers.scala
index c742ab89c0..37dd032135 100644
--- a/src/compiler/scala/tools/nsc/interpreter/MemberHandlers.scala
+++ b/src/compiler/scala/tools/nsc/interpreter/MemberHandlers.scala
@@ -182,7 +182,7 @@ trait MemberHandlers {
// TODO: Need to track these specially to honor Predef masking attempts,
// because they must be the leading imports in the code generated for each
// line. We can use the same machinery as Contexts now, anyway.
- def isPredefImport = treeInfo.isPredefExpr(expr)
+ def isPredefImport = isReferenceToPredef(expr)
// wildcard imports, e.g. import foo._
private def selectorWild = selectors filter (_.name == nme.USCOREkw)
diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
index 9c0670e981..d8db62a408 100644
--- a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
+++ b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
@@ -841,7 +841,7 @@ abstract class ClassfileParser {
}
ClassInfoType(parents.toList, instanceDefs, sym)
}
- polyType(ownTypeParams, tpe)
+ GenPolyType(ownTypeParams, tpe)
} // sigToType
class TypeParamsType(override val typeParams: List[Symbol]) extends LazyType {
diff --git a/src/compiler/scala/tools/nsc/symtab/clr/TypeParser.scala b/src/compiler/scala/tools/nsc/symtab/clr/TypeParser.scala
index e11a5a4ad9..736d1c78a3 100644
--- a/src/compiler/scala/tools/nsc/symtab/clr/TypeParser.scala
+++ b/src/compiler/scala/tools/nsc/symtab/clr/TypeParser.scala
@@ -224,14 +224,14 @@ abstract class TypeParser {
if (canBeTakenAddressOf) {
clazzBoxed.setInfo( if (ownTypeParams.isEmpty) classInfoAsInMetadata
- else polyType(ownTypeParams, classInfoAsInMetadata) )
+ else GenPolyType(ownTypeParams, classInfoAsInMetadata) )
clazzBoxed.setFlag(flags)
val rawValueInfoType = ClassInfoType(definitions.anyvalparam, instanceDefs, clazz)
clazz.setInfo( if (ownTypeParams.isEmpty) rawValueInfoType
- else polyType(ownTypeParams, rawValueInfoType) )
+ else GenPolyType(ownTypeParams, rawValueInfoType) )
} else {
clazz.setInfo( if (ownTypeParams.isEmpty) classInfoAsInMetadata
- else polyType(ownTypeParams, classInfoAsInMetadata) )
+ else GenPolyType(ownTypeParams, classInfoAsInMetadata) )
}
// TODO I don't remember if statics.setInfo and staticModule.setInfo should also know about type params
@@ -480,7 +480,7 @@ abstract class TypeParser {
val mtype = methodType(method, rettype);
if (mtype == null) return;
/* START CLR generics (snippet 4) */
- val mInfo = if (method.IsGeneric) polyType(newMethodTParams, mtype(methodSym))
+ val mInfo = if (method.IsGeneric) GenPolyType(newMethodTParams, mtype(methodSym))
else mtype(methodSym)
/* END CLR generics (snippet 4) */
/* START CLR non-generics (snippet 4)
diff --git a/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala b/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala
index e01bbccf13..89dfbfd317 100644
--- a/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala
+++ b/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala
@@ -298,7 +298,7 @@ abstract class AddInterfaces extends InfoTransform {
}
val mixinConstructorCalls: List[Tree] = {
for (mc <- clazz.mixinClasses.reverse
- if mc.hasFlag(lateINTERFACE) && mc != ScalaObjectClass)
+ if mc.hasFlag(lateINTERFACE))
yield mixinConstructorCall(implClass(mc))
}
(tree: @unchecked) match {
diff --git a/src/compiler/scala/tools/nsc/transform/Constructors.scala b/src/compiler/scala/tools/nsc/transform/Constructors.scala
index d1c71faf1e..256f13b3fb 100644
--- a/src/compiler/scala/tools/nsc/transform/Constructors.scala
+++ b/src/compiler/scala/tools/nsc/transform/Constructors.scala
@@ -445,7 +445,7 @@ abstract class Constructors extends Transform with ast.TreeDSL {
localTyper.typed {
atPos(impl.pos) {
val closureClass = clazz.newClass(nme.delayedInitArg.toTypeName, impl.pos, SYNTHETIC | FINAL)
- val closureParents = List(AbstractFunctionClass(0).tpe, ScalaObjectClass.tpe)
+ val closureParents = List(AbstractFunctionClass(0).tpe)
closureClass setInfoAndEnter new ClassInfoType(closureParents, newScope, closureClass)
diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala
index fe479a5375..30bfdbaf5b 100644
--- a/src/compiler/scala/tools/nsc/transform/Erasure.scala
+++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala
@@ -31,39 +31,6 @@ abstract class Erasure extends AddInterfaces
// -------- erasure on types --------------------------------------------------------
- // A type function from T => Class[U], used to determine the return
- // type of getClass calls. The returned type is:
- //
- // 1. If T is a value type, Class[T].
- // 2. If T is a phantom type (Any or AnyVal), Class[_].
- // 3. If T is a local class, Class[_ <: |T|].
- // 4. Otherwise, Class[_ <: T].
- //
- // Note: AnyVal cannot be Class[_ <: AnyVal] because if the static type of the
- // receiver is AnyVal, it implies the receiver is boxed, so the correct
- // class object is that of java.lang.Integer, not Int.
- //
- // TODO: If T is final, return type could be Class[T]. Should it?
- def getClassReturnType(tp: Type): Type = {
- val sym = tp.typeSymbol
-
- if (phase.erasedTypes) ClassClass.tpe
- else if (isValueClass(sym)) ClassType(tp.widen)
- else {
- val eparams = typeParamsToExistentials(ClassClass, ClassClass.typeParams)
- val upperBound = (
- if (isPhantomClass(sym)) AnyClass.tpe
- else if (sym.isLocalClass) intersectionDominator(tp.parents)
- else tp.widen
- )
-
- existentialAbstraction(
- eparams,
- ClassType(eparams.head setInfo TypeBounds.upper(upperBound) tpe)
- )
- }
- }
-
// convert a numeric with a toXXX method
def numericConversion(tree: Tree, numericSym: Symbol): Tree = {
val mname = newTermName("to" + numericSym.name)
@@ -602,7 +569,7 @@ abstract class Erasure extends AddInterfaces
Console.println("exception when typing " + tree)
Console.println(er.msg + " in file " + context.owner.sourceFile)
er.printStackTrace
- abort()
+ abort("unrecoverable error")
case ex: Exception =>
//if (settings.debug.value)
try Console.println("exception when typing " + tree)
@@ -931,6 +898,10 @@ abstract class Erasure extends AddInterfaces
tree
case Apply(fn, args) =>
+ def qualifier = fn match {
+ case Select(qual, _) => qual
+ case TypeApply(Select(qual, _), _) => qual
+ }
if (fn.symbol == Any_asInstanceOf)
(fn: @unchecked) match {
case TypeApply(Select(qual, _), List(targ)) =>
@@ -980,20 +951,13 @@ abstract class Erasure extends AddInterfaces
}
case _ => tree
}
- }
- else {
- def doDynamic(fn: Tree, qual: Tree): Tree = {
- if (fn.symbol.owner.isRefinementClass && !fn.symbol.isOverridingSymbol)
- ApplyDynamic(qual, args) setSymbol fn.symbol setPos tree.pos
- else tree
- }
- fn match {
- case Select(qual, _) => doDynamic(fn, qual)
- case TypeApply(fni@Select(qual, _), _) => doDynamic(fni, qual)// type parameters are irrelevant in case of dynamic call
- case _ =>
+ } else if (fn.symbol.owner.isRefinementClass && !fn.symbol.isOverridingSymbol) {
+ ApplyDynamic(qualifier, args) setSymbol fn.symbol setPos tree.pos
+ } else if (fn.symbol.owner.isInlineClass && extensionMethods.hasExtension(fn.symbol)) {
+ Apply(gen.mkAttributedRef(extensionMethods.extensionMethod(fn.symbol)), qualifier :: args)
+ } else {
tree
}
- }
case Select(qual, name) =>
val owner = tree.symbol.owner
diff --git a/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala b/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala
new file mode 100644
index 0000000000..c308a3633e
--- /dev/null
+++ b/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala
@@ -0,0 +1,168 @@
+/* NSC -- new Scala compiler
+ * Copyright 2005-2011 LAMP/EPFL
+ * @author Gilles Dubochet
+ * @author Martin Odersky
+ */
+
+package scala.tools.nsc
+package transform
+
+import symtab._
+import Flags._
+import scala.collection.{ mutable, immutable }
+import scala.collection.mutable
+import scala.tools.nsc.util.FreshNameCreator
+import scala.runtime.ScalaRunTime.{ isAnyVal, isTuple }
+import sun.tools.tree.OrExpression
+
+/**
+ * Perform Step 1 in the inline classes SIP
+ *
+ * @author Martin Odersky
+ * @version 2.10
+ */
+abstract class ExtensionMethods extends Transform with TypingTransformers {
+
+ import global._ // the global environment
+ import definitions._ // standard classes and methods
+ import typer.{ typed, atOwner } // methods to type trees
+
+ /** the following two members override abstract members in Transform */
+ val phaseName: String = "extmethods"
+
+ def newTransformer(unit: CompilationUnit): Transformer =
+ new Extender(unit)
+
+ def hasExtension(sym: Symbol) =
+ !sym.isParamAccessor && !sym.isConstructor
+
+ /** Generate stream of possible names for the extension version of given instance method `imeth`.
+ * If the method is not overloaded, this stream consists of just "extension$imeth".
+ * If the method is overloaded, the stream has as first element "extensionX$imeth", where X is the
+ * index of imeth in the sequence of overloaded alternatives with the same name. This choice will
+ * always be picked as the name of the generated extension method.
+ * After this first choice, all other possible indices in the range of 0 until the number
+ * of overloaded alternatives are returned. The secondary choices are used to find a matching method
+ * in `extensionMethod` if the first name has the wrong type. We thereby gain a level of insensitivity
+ * of how overloaded types are ordered between phases and picklings.
+ */
+ private def extensionNames(imeth: Symbol): Stream[Name] =
+ imeth.owner.info.decl(imeth.name).tpe match {
+ case OverloadedType(_, alts) =>
+ val index = alts indexOf imeth
+ assert(index >= 0, alts+" does not contain "+imeth)
+ def altName(index: Int) = newTermName("extension"+index+"$"+imeth.name)
+ altName(index) #:: ((0 until alts.length).toStream filter (index !=) map altName)
+ case tpe =>
+ assert(tpe != NoType, imeth.name+" not found in "+imeth.owner+"'s decls: "+imeth.owner.info.decls)
+ Stream(newTermName("extension$"+imeth.name))
+ }
+
+ /** Return the extension method that corresponds to given instance method `meth`.
+ */
+ def extensionMethod(imeth: Symbol): Symbol = atPhase(currentRun.refchecksPhase) {
+ val companionInfo = imeth.owner.companionModule.info
+ val candidates = extensionNames(imeth) map (companionInfo.decl(_))
+ val matching = candidates filter (alt => normalize(alt.tpe, imeth.owner) matches imeth.tpe)
+ assert(matching.nonEmpty, "no extension method found for "+imeth+" among "+candidates+"/"+extensionNames(imeth))
+ matching.head
+ }
+
+ private def normalize(stpe: Type, clazz: Symbol): Type = stpe match {
+ case PolyType(tparams, restpe) =>
+ GenPolyType(tparams dropRight clazz.typeParams.length, normalize(restpe, clazz))
+ case MethodType(tparams, restpe) =>
+ restpe
+ case _ =>
+ stpe
+ }
+
+ class Extender(unit: CompilationUnit) extends TypingTransformer(unit) {
+
+ private val extensionDefs = mutable.Map[Symbol, mutable.ListBuffer[Tree]]()
+
+ def extensionMethInfo(extensionMeth: Symbol, origInfo: Type, clazz: Symbol): Type = {
+ var newTypeParams = cloneSymbolsAtOwner(clazz.typeParams, extensionMeth)
+ val thisParamType = appliedType(clazz.typeConstructor, newTypeParams map (_.tpe))
+ val thisParam = extensionMeth.newValueParameter(nme.SELF, extensionMeth.pos) setInfo thisParamType
+ def transform(clonedType: Type): Type = clonedType match {
+ case MethodType(params, restpe) =>
+ // I assume it was a bug that this was dropping params...
+ MethodType(thisParam :: params, clonedType)
+ case NullaryMethodType(restpe) =>
+ MethodType(List(thisParam), restpe)
+ }
+ val GenPolyType(tparams, restpe) = origInfo cloneInfo extensionMeth
+ GenPolyType(tparams ::: newTypeParams, transform(restpe))
+ }
+
+ private def allParams(tpe: Type): List[Symbol] = tpe match {
+ case MethodType(params, res) => params ::: allParams(res)
+ case _ => List()
+ }
+
+ override def transform(tree: Tree): Tree = {
+ tree match {
+ case Template(_, _, _) =>
+ if (currentOwner.isInlineClass) {
+ extensionDefs(currentOwner.companionModule) = new mutable.ListBuffer[Tree]
+ super.transform(tree)
+ }
+ else tree
+ case DefDef(mods, name, tparams, vparamss, tpt, rhs)
+ if currentOwner.isInlineClass && hasExtension(tree.symbol) =>
+ val companion = currentOwner.companionModule
+ val origMeth = tree.symbol
+ val extensionName = extensionNames(origMeth).head
+ val extensionMeth = companion.moduleClass.newMethod(extensionName, origMeth.pos, origMeth.flags & ~OVERRIDE | FINAL)
+ .setAnnotations(origMeth.annotations)
+ companion.info.decls.enter(extensionMeth)
+ val newInfo = extensionMethInfo(extensionMeth, origMeth.info, currentOwner)
+ extensionMeth setInfo newInfo
+ log("Inline class %s spawns extension method.\n Old: %s\n New: %s".format(
+ currentOwner,
+ origMeth.defString,
+ extensionMeth.defString)) // extensionMeth.defStringSeenAs(origInfo
+
+ def thisParamRef = gen.mkAttributedIdent(extensionMeth.info.params.head setPos extensionMeth.pos)
+ val GenPolyType(extensionTpeParams, extensionMono) = extensionMeth.info
+ val origTpeParams = origMeth.typeParams ::: currentOwner.typeParams
+ val extensionBody = rhs
+ .substTreeSyms(origTpeParams, extensionTpeParams)
+ .substTreeSyms(vparamss.flatten map (_.symbol), allParams(extensionMono).tail)
+ .substTreeThis(currentOwner, thisParamRef)
+ .changeOwner((origMeth, extensionMeth))
+ extensionDefs(companion) += atPos(tree.pos) { DefDef(extensionMeth, extensionBody) }
+ val extensionCallPrefix = Apply(
+ gen.mkTypeApply(gen.mkAttributedRef(companion), extensionMeth, origTpeParams map (_.tpe)),
+ List(This(currentOwner)))
+ val extensionCall = atOwner(origMeth) {
+ localTyper.typed {
+ atPos(rhs.pos) {
+ (extensionCallPrefix /: vparamss) {
+ case (fn, params) => Apply(fn, params map (param => Ident(param.symbol)))
+ }
+ }
+ }
+ }
+ treeCopy.DefDef(tree, mods, name, tparams, vparamss, tpt, extensionCall)
+ case _ =>
+ super.transform(tree)
+ }
+ }
+
+ override def transformStats(stats: List[Tree], exprOwner: Symbol): List[Tree] =
+ super.transformStats(stats, exprOwner) map {
+ case stat @ ModuleDef(mods, name, tmpl @ Template(parents, self, body)) =>
+ extensionDefs.remove(stat.symbol) match {
+ case Some(buf) =>
+ val extensionDefs = buf.toList map { mdef => atOwner(stat.symbol) { localTyper.typed(mdef) }}
+ treeCopy.ModuleDef(stat, mods, name, treeCopy.Template(tmpl, parents, self, body ++ buf))
+ case None =>
+ stat
+ }
+ case stat =>
+ stat
+ }
+ }
+}
diff --git a/src/compiler/scala/tools/nsc/transform/InlineErasure.scala b/src/compiler/scala/tools/nsc/transform/InlineErasure.scala
new file mode 100644
index 0000000000..0af3cf732f
--- /dev/null
+++ b/src/compiler/scala/tools/nsc/transform/InlineErasure.scala
@@ -0,0 +1,9 @@
+package scala.tools.nsc
+package transform
+
+trait InlineErasure { self: Erasure =>
+
+ import global._
+ import definitions._
+
+} \ No newline at end of file
diff --git a/src/compiler/scala/tools/nsc/transform/LiftCode.scala b/src/compiler/scala/tools/nsc/transform/LiftCode.scala
index d0ed92f8ba..8affea56a2 100644
--- a/src/compiler/scala/tools/nsc/transform/LiftCode.scala
+++ b/src/compiler/scala/tools/nsc/transform/LiftCode.scala
@@ -1,6 +1,7 @@
/* NSC -- new Scala compiler
* Copyright 2005-2011 LAMP/EPFL
* @author Gilles Dubochet
+ * @author Martin Odersky
*/
package scala.tools.nsc
diff --git a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
index 4012d08e42..c1265b39d7 100644
--- a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
+++ b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
@@ -556,7 +556,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
" => " + sClass.defStringSeenAs(sClass.typeOfThis)
)
}
- polyType(newClassTParams, ClassInfoType(parents ::: extraSpecializedMixins, decls1, sClass))
+ GenPolyType(newClassTParams, ClassInfoType(parents ::: extraSpecializedMixins, decls1, sClass))
}
atPhase(phase.next)(sClass setInfo specializedInfoType)
@@ -787,7 +787,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
// the cloneInfo is necessary so that method parameter symbols are cloned at the new owner
val methodType = sym.info.resultType.instantiateTypeParams(keys ++ tps, vals ++ tps1.map(_.tpe)).cloneInfo(specMember)
- specMember setInfo polyType(tps1, methodType)
+ specMember setInfo GenPolyType(tps1, methodType)
debuglog("expanded member: " + sym + ": " + sym.info +
" -> " + specMember +
@@ -1091,7 +1091,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
)
val newScope = newScopeWith(specializeClass(clazz, typeEnv(clazz)) ++ specialOverrides(clazz): _*)
// If tparams.isEmpty, this is just the ClassInfoType.
- polyType(tparams, ClassInfoType(parents1, newScope, clazz))
+ GenPolyType(tparams, ClassInfoType(parents1, newScope, clazz))
case _ =>
tpe
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala
index 6ee09d064f..68bc80ffc4 100644
--- a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala
@@ -534,7 +534,7 @@ trait ContextErrors {
NormalTypeError(parent, "illegal inheritance from final "+mixin)
def ParentSealedInheritanceError(parent: Tree, psym: Symbol) =
- NormalTypeError(parent, "illegal inheritance from sealed " + psym + ": " + context.unit.source.file.canonicalPath + " != " + psym.sourceFile.canonicalPath)
+ NormalTypeError(parent, "illegal inheritance from sealed " + psym )
def ParentSelfTypeConformanceError(parent: Tree, selfType: Type) =
NormalTypeError(parent,
@@ -765,7 +765,7 @@ trait ContextErrors {
def PolymorphicExpressionInstantiationError(tree: Tree, undetparams: List[Symbol], pt: Type) =
issueNormalTypeError(tree,
"polymorphic expression cannot be instantiated to expected type" +
- foundReqMsg(polyType(undetparams, skipImplicit(tree.tpe)), pt))
+ foundReqMsg(GenPolyType(undetparams, skipImplicit(tree.tpe)), pt))
//checkCheckable
def TypePatternOrIsInstanceTestError(tree: Tree, tp: Type) =
diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
index 740acbd10f..b5afd681d2 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
@@ -43,8 +43,7 @@ trait Contexts { self: Analyzer =>
* - if option `-Yno-imports` is given, nothing is imported
* - if the unit is java defined, only `java.lang` is imported
* - if option `-Yno-predef` is given, if the unit body has an import of Predef
- * among its leading imports, or if the tree is [[scala.ScalaObject]]
- * or [[scala.Predef]], `Predef` is not imported.
+ * among its leading imports, or if the tree is [[scala.Predef]], `Predef` is not imported.
*/
protected def rootImports(unit: CompilationUnit): List[Symbol] = {
import definitions._
diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
index 0ff2b418f4..7bb9ab2fc9 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
@@ -113,7 +113,7 @@ trait Namers extends MethodSynthesis {
private def contextFile = context.unit.source.file
private def typeErrorHandler[T](tree: Tree, alt: T): PartialFunction[Throwable, T] = {
case ex: TypeError =>
- // H@ need to ensure that we handle only cyclic references
+ // H@ need to ensure that we handle only cyclic references
TypeSigError(tree, ex)
alt
}
@@ -296,7 +296,7 @@ trait Namers extends MethodSynthesis {
val pos = tree.pos
val isParameter = tree.mods.isParameter
val flags = tree.mods.flags & mask
-
+
tree match {
case TypeDef(_, _, _, _) if isParameter => owner.newTypeParameter(name.toTypeName, pos, flags)
case TypeDef(_, _, _, _) => owner.newTypeSymbol(name.toTypeName, pos, flags)
@@ -836,6 +836,7 @@ trait Namers extends MethodSynthesis {
}
val parents = typer.parentTypes(templ) map checkParent
+
enterSelf(templ.self)
val decls = newScope
@@ -886,7 +887,7 @@ trait Namers extends MethodSynthesis {
val tparams0 = typer.reenterTypeParams(tparams)
val resultType = templateSig(impl)
- polyType(tparams0, resultType)
+ GenPolyType(tparams0, resultType)
}
private def methodSig(ddef: DefDef, mods: Modifiers, tparams: List[TypeDef],
@@ -929,7 +930,7 @@ trait Namers extends MethodSynthesis {
// DEPMETTODO: check not needed when they become on by default
checkDependencies(restpe)
- polyType(
+ GenPolyType(
tparamSyms, // deSkolemized symbols -- TODO: check that their infos don't refer to method args?
if (vparamSymss.isEmpty) NullaryMethodType(restpe)
// vparamss refer (if they do) to skolemized tparams
@@ -1183,7 +1184,7 @@ trait Namers extends MethodSynthesis {
// However, separate compilation requires the symbol info to be
// loaded to do this check, but loading the info will probably
// lead to spurious cyclic errors. So omit the check.
- polyType(tparamSyms, tp)
+ GenPolyType(tparamSyms, tp)
}
/** Given a case class
@@ -1247,8 +1248,12 @@ trait Namers extends MethodSynthesis {
if (sym.isModule) annotate(sym.moduleClass)
def getSig = tree match {
- case ClassDef(_, _, tparams, impl) =>
- createNamer(tree).classSig(tparams, impl)
+ case cdef @ ClassDef(_, _, tparams, impl) =>
+ val clazz = tree.symbol
+ val result = createNamer(tree).classSig(tparams, impl)
+ clazz setInfo result
+ if (clazz.isInlineClass) ensureCompanionObject(cdef)
+ result
case ModuleDef(_, _, impl) =>
val clazz = sym.moduleClass
@@ -1304,6 +1309,22 @@ trait Namers extends MethodSynthesis {
}
}
+ def includeParent(tpe: Type, parent: Symbol): Type = tpe match {
+ case PolyType(tparams, restpe) =>
+ PolyType(tparams, includeParent(restpe, parent))
+ case ClassInfoType(parents, decls, clazz) =>
+ if (parents exists (_.typeSymbol == parent)) tpe
+ else ClassInfoType(parents :+ parent.tpe, decls, clazz)
+ case _ =>
+ tpe
+ }
+
+ def ensureParent(clazz: Symbol, parent: Symbol) = {
+ val info0 = clazz.info
+ val info1 = includeParent(info0, parent)
+ if (info0 ne info1) clazz setInfo info1
+ }
+
class LogTransitions[S](onEnter: S => String, onExit: S => String) {
val enabled = settings.debug.value
@inline final def apply[T](entity: S)(body: => T): T = {
@@ -1381,6 +1402,13 @@ trait Namers extends MethodSynthesis {
if (sym.info.typeSymbol == FunctionClass(0) && sym.isValueParameter && sym.owner.isCaseClass)
fail(ByNameParameter)
+ if (sym.isClass && sym.hasAnnotation(ScalaInlineClass) && !phase.erasedTypes) {
+ if (!sym.isSubClass(AnyValClass))
+ ensureParent(sym, NotNullClass)
+
+ sym setFlag FINAL
+ }
+
if (sym.isDeferred) {
// Is this symbol type always allowed the deferred flag?
def symbolAllowsDeferred = (
@@ -1407,7 +1435,7 @@ trait Namers extends MethodSynthesis {
checkNoConflict(PRIVATE, PROTECTED)
// checkNoConflict(PRIVATE, OVERRIDE) // this one leads to bad error messages like #4174, so catch in refchecks
// checkNoConflict(PRIVATE, FINAL) // can't do this because FINAL also means compile-time constant
- checkNoConflict(ABSTRACT, FINAL)
+ // checkNoConflict(ABSTRACT, FINAL) // this one gives a bad error for non-@inline classes which extend AnyVal
// @PP: I added this as a sanity check because these flags are supposed to be
// converted to ABSOVERRIDE before arriving here.
checkNoConflict(ABSTRACT, OVERRIDE)
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
index fa4664b34f..21c1b8aa11 100644
--- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
@@ -683,8 +683,10 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R
if (abstractErrors.nonEmpty)
unit.error(clazz.pos, abstractErrorMessage)
- } else if (clazz.isTrait) {
- // prevent abstract methods in interfaces that override final members in Object; see #4431
+ }
+ else if (clazz.isTrait && !(clazz isSubClass AnyValClass)) {
+ // For non-AnyVal classes, prevent abstract methods in interfaces that override
+ // final members in Object; see #4431
for (decl <- clazz.info.decls.iterator) {
val overridden = decl.overriddenSymbol(ObjectClass)
if (overridden.isFinal)
@@ -1112,7 +1114,7 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R
// warn only if they have no common supertype below Object
else {
val common = global.lub(List(actual.tpe, receiver.tpe))
- if (common.typeSymbol == ScalaObjectClass || (ObjectClass.tpe <:< common))
+ if (ObjectClass.tpe <:< common)
unrelatedTypes()
}
}
@@ -1526,6 +1528,19 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R
)
case _ => ()
}
+
+ // verify classes extending AnyVal meet the requirements
+ // (whatever those are to be, but at least: @inline annotation)
+ private def checkAnyValSubclass(clazz: Symbol) = {
+ if ((clazz isSubClass AnyValClass) && (clazz ne AnyValClass) && !isPrimitiveValueClass(clazz)) {
+ if (!clazz.hasAnnotation(ScalaInlineClass))
+ unit.error(clazz.pos, "Only @inline classes are allowed to extend AnyVal")
+ if (clazz.isTrait)
+ unit.error(clazz.pos, "Only @inline classes (not traits) are allowed to extend AnyVal")
+ if (clazz.tpe <:< AnyRefClass.tpe)
+ unit.error(clazz.pos, "Classes which extend AnyVal may not have an ancestor which inherits AnyRef")
+ }
+ }
override def transform(tree: Tree): Tree = {
val savedLocalTyper = localTyper
@@ -1561,6 +1576,8 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R
checkOverloadedRestrictions(currentOwner)
val bridges = addVarargBridges(currentOwner)
checkAllOverrides(currentOwner)
+ checkAnyValSubclass(currentOwner)
+
if (bridges.nonEmpty) treeCopy.Template(tree, parents, self, body ::: bridges)
else tree
diff --git a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala
index 4ea21b1c44..3ee5bf601d 100644
--- a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala
@@ -47,6 +47,17 @@ trait SyntheticMethods extends ast.TreeDSL {
newTyper( if (reporter.hasErrors) context makeSilent false else context )
)
import synthesizer._
+
+ if (clazz0 isSubClass AnyValClass) return {
+ if (clazz0.info member nme.getClass_ isDeferred) {
+ val getClassMethod = createMethod(nme.getClass_, getClassReturnType(clazz.tpe)) { sym =>
+ // XXX dummy implementation for now
+ NULL
+ }
+ treeCopy.Template(templ, templ.parents, templ.self, templ.body :+ getClassMethod)
+ }
+ else templ
+ }
val originalAccessors = clazz.caseFieldAccessors
// private ones will have been renamed -- make sure they are entered
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index d039515320..f6cc71c0ca 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -156,7 +156,7 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser {
case ErrorType =>
fun
}
-
+
def inferView(tree: Tree, from: Type, to: Type, reportAmbiguous: Boolean): Tree =
inferView(tree, from, to, reportAmbiguous, true)
@@ -276,7 +276,7 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser {
}
tp match {
case TypeRef(pre, sym, args) =>
- checkNotLocked(sym) &&
+ checkNotLocked(sym) &&
((!sym.isNonClassType) || checkNonCyclic(pos, appliedType(pre.memberInfo(sym), args), sym))
// @M! info for a type ref to a type parameter now returns a polytype
// @M was: checkNonCyclic(pos, pre.memberInfo(sym).subst(sym.typeParams, args), sym)
@@ -945,7 +945,7 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser {
adaptType()
else if (inExprModeButNot(mode, FUNmode) && tree.symbol != null && tree.symbol.isMacro && !tree.isDef) {
val tree1 = expandMacro(tree)
- if (tree1.isErroneous) tree1 else typed(tree1, mode, pt)
+ if (tree1.isErroneous) tree1 else typed(tree1, mode, pt)
} else if ((mode & (PATTERNmode | FUNmode)) == (PATTERNmode | FUNmode))
adaptConstrPattern()
else if (inAllModes(mode, EXPRmode | FUNmode) &&
@@ -1090,7 +1090,7 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser {
// Note: implicit arguments are still inferred (this kind of "chaining" is allowed)
)
}
-
+
def adaptToMember(qual: Tree, searchTemplate: Type): Tree =
adaptToMember(qual, searchTemplate, true, true)
def adaptToMember(qual: Tree, searchTemplate: Type, reportAmbiguous: Boolean): Tree =
@@ -1105,12 +1105,12 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser {
}
inferView(qual, qual.tpe, searchTemplate, reportAmbiguous, saveErrors) match {
case EmptyTree => qual
- case coercion =>
+ case coercion =>
if (settings.logImplicitConv.value)
unit.echo(qual.pos,
"applied implicit conversion from %s to %s = %s".format(
qual.tpe, searchTemplate, coercion.symbol.defString))
-
+
typedQualifier(atPos(qual.pos)(new ApplyImplicitView(coercion, List(qual))))
}
}
@@ -1211,6 +1211,8 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser {
supertpt = TypeTree(supertpt1.tpe.parents.head) setPos supertpt.pos.focus
}
}
+ if (supertpt.tpe.typeSymbol == AnyClass && firstParent.isTrait && firstParent != AnyValClass)
+ supertpt.tpe = AnyRefClass.tpe
// Determine
// - supertparams: Missing type parameters from supertype
@@ -1342,13 +1344,12 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser {
if (psym.isFinal)
pending += ParentFinalInheritanceError(parent, psym)
- if (psym.isSealed && !phase.erasedTypes) {
- // AnyVal is sealed, but we have to let the value classes through manually
- if (context.unit.source.file == psym.sourceFile || isValueClass(context.owner))
+ if (psym.isSealed && !phase.erasedTypes)
+ if (context.unit.source.file == psym.sourceFile)
psym addChild context.owner
else
pending += ParentSealedInheritanceError(parent, psym)
- }
+
if (!(selfType <:< parent.tpe.typeOfThis) &&
!phase.erasedTypes &&
!context.owner.isSynthetic && // don't check synthetic concrete classes for virtuals (part of DEVIRTUALIZE)
@@ -1414,6 +1415,10 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser {
_.typedTemplate(cdef.impl, parentTypes(cdef.impl))
}
val impl2 = finishMethodSynthesis(impl1, clazz, context)
+ if (clazz.isTrait && clazz.info.parents.nonEmpty && clazz.info.parents.head.typeSymbol == AnyClass)
+ for (stat <- impl2.body)
+ if (!treeInfo.isAllowedInAnyTrait(stat))
+ unit.error(stat.pos, "this statement is not allowed in trait extending from class Any: "+stat)
if ((clazz != ClassfileAnnotationClass) &&
(clazz isNonBottomSubClass ClassfileAnnotationClass))
restrictionWarning(cdef.pos, unit,
@@ -2896,10 +2901,10 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser {
def packSymbols(hidden: List[Symbol], tp: Type): Type =
if (hidden.isEmpty) tp
else existentialTransform(hidden, tp)(existentialAbstraction)
-
+
def isReferencedFrom(ctx: Context, sym: Symbol): Boolean =
- ctx.owner.isTerm &&
- (ctx.scope.exists { dcl => dcl.isInitialized && (dcl.info contains sym) }) ||
+ ctx.owner.isTerm &&
+ (ctx.scope.exists { dcl => dcl.isInitialized && (dcl.info contains sym) }) ||
{
var ctx1 = ctx.outer
while ((ctx1 != NoContext) && (ctx1.scope eq ctx.scope)) ctx1 = ctx1.outer
@@ -3062,7 +3067,7 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser {
// as we don't know which alternative to choose... here we do
map2Conserve(args, tparams) {
//@M! the polytype denotes the expected kind
- (arg, tparam) => typedHigherKindedType(arg, mode, polyType(tparam.typeParams, AnyClass.tpe))
+ (arg, tparam) => typedHigherKindedType(arg, mode, GenPolyType(tparam.typeParams, AnyClass.tpe))
}
} else // @M: there's probably something wrong when args.length != tparams.length... (triggered by bug #320)
// Martin, I'm using fake trees, because, if you use args or arg.map(typedType),
@@ -3830,7 +3835,7 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser {
&& qual.tpe.typeSymbol.isPublic
)
if (isRefinableGetClass)
- selection setType MethodType(Nil, erasure.getClassReturnType(qual.tpe))
+ selection setType MethodType(Nil, getClassReturnType(qual.tpe))
else
selection
}
@@ -3886,7 +3891,7 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser {
reallyExists(sym) &&
((mode & PATTERNmode | FUNmode) != (PATTERNmode | FUNmode) || !sym.isSourceMethod || sym.hasFlag(ACCESSOR))
}
-
+
if (defSym == NoSymbol) {
var defEntry: ScopeEntry = null // the scope entry of defSym, if defined in a local scope
@@ -4074,7 +4079,7 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser {
// if symbol hasn't been fully loaded, can't check kind-arity
else map2Conserve(args, tparams) { (arg, tparam) =>
//@M! the polytype denotes the expected kind
- typedHigherKindedType(arg, mode, polyType(tparam.typeParams, AnyClass.tpe))
+ typedHigherKindedType(arg, mode, GenPolyType(tparam.typeParams, AnyClass.tpe))
}
val argtypes = args1 map (_.tpe)
@@ -4282,7 +4287,7 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser {
// @M maybe the well-kindedness check should be done when checking the type arguments conform to the type parameters' bounds?
val args1 = if (sameLength(args, tparams)) map2Conserve(args, tparams) {
//@M! the polytype denotes the expected kind
- (arg, tparam) => typedHigherKindedType(arg, mode, polyType(tparam.typeParams, AnyClass.tpe))
+ (arg, tparam) => typedHigherKindedType(arg, mode, GenPolyType(tparam.typeParams, AnyClass.tpe))
} else {
//@M this branch is correctly hit for an overloaded polymorphic type. It also has to handle erroneous cases.
// Until the right alternative for an overloaded method is known, be very liberal,
@@ -4377,7 +4382,7 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser {
case ReferenceToBoxed(idt @ Ident(_)) =>
val id1 = typed1(idt, mode, pt) match { case id: Ident => id }
- treeCopy.ReferenceToBoxed(tree, id1) setType AnyRefClass.tpe
+ treeCopy.ReferenceToBoxed(tree, id1) setType AnyRefClass.tpe
case Literal(value) =>
tree setType (
@@ -4609,6 +4614,7 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser {
// AnyRef, but the AnyRef type alias is entered after the scala package is
// loaded and completed, so that ScalaObject is unpickled while AnyRef is not
// yet defined )
+ // !!! TODO - revisit now that ScalaObject is gone.
result setType(restpe)
} else { // must not normalize: type application must be (bounds-)checked (during RefChecks), see #2208
// during uncurry (after refchecks), all types are normalized
diff --git a/src/compiler/scala/tools/nsc/typechecker/Unapplies.scala b/src/compiler/scala/tools/nsc/typechecker/Unapplies.scala
index 19b8632ed7..b8bc0946c1 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Unapplies.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Unapplies.scala
@@ -151,11 +151,10 @@ trait Unapplies extends ast.TreeDSL
}
def companionModuleDef(cdef: ClassDef, parents: List[Tree] = Nil, body: List[Tree] = Nil): ModuleDef = atPos(cdef.pos.focus) {
- val allParents = parents :+ gen.scalaScalaObjectConstr
ModuleDef(
Modifiers(cdef.mods.flags & AccessFlags | SYNTHETIC, cdef.mods.privateWithin),
cdef.name.toTermName,
- Template(allParents, emptyValDef, NoMods, Nil, List(Nil), body, cdef.impl.pos.focus))
+ Template(parents, emptyValDef, NoMods, Nil, List(Nil), body, cdef.impl.pos.focus))
}
private val caseMods = Modifiers(SYNTHETIC | CASE)
diff --git a/src/compiler/scala/tools/nsc/util/ClassPath.scala b/src/compiler/scala/tools/nsc/util/ClassPath.scala
index 622b4db2a2..ce10ee34a2 100644
--- a/src/compiler/scala/tools/nsc/util/ClassPath.scala
+++ b/src/compiler/scala/tools/nsc/util/ClassPath.scala
@@ -23,7 +23,7 @@ import java.net.MalformedURLException
* @author Stepan Koltsov
*/
object ClassPath {
- def scalaLibrary = locate[ScalaObject]
+ def scalaLibrary = locate[Option[_]]
def scalaCompiler = locate[Global]
def infoFor[T](value: T) = info(value.getClass)
diff --git a/src/detach/plugin/scala/tools/detach/Detach.scala b/src/detach/plugin/scala/tools/detach/Detach.scala
index fee2c5a273..546041844e 100644
--- a/src/detach/plugin/scala/tools/detach/Detach.scala
+++ b/src/detach/plugin/scala/tools/detach/Detach.scala
@@ -734,7 +734,7 @@ abstract class Detach extends PluginComponent
proxyOwner.newClass(clazz.pos, encode(clazz.name.decode + PROXY_SUFFIX))
iface.sourceFile = clazz.sourceFile
iface setFlag (ABSTRACT | TRAIT | INTERFACE) // Java interface
- val iparents = List(ObjectClass.tpe, RemoteClass.tpe, ScalaObjectClass.tpe)
+ val iparents = List(ObjectClass.tpe, RemoteClass.tpe)
iface setInfo ClassInfoType(iparents, newScope, iface)
// methods must throw RemoteException
iface addAnnotation remoteAnnotationInfo
@@ -744,8 +744,7 @@ abstract class Detach extends PluginComponent
iclaz.sourceFile = clazz.sourceFile
iclaz setFlag (SYNTHETIC | FINAL)
// Variant 1: rebind/unbind
- val cparents = List(UnicastRemoteObjectClass.tpe, iface.tpe,
- UnreferencedClass.tpe, ScalaObjectClass.tpe)
+ val cparents = List(UnicastRemoteObjectClass.tpe, iface.tpe, UnreferencedClass.tpe)
// Variant 2: un-/exportObject
//val cparents = List(ObjectClass.tpe, iface.tpe,
// UnreferencedClass.tpe, ScalaObjectClass.tpe)
diff --git a/src/library/scala/AnyVal.scala b/src/library/scala/AnyVal.scala
index cd2c04dbd8..ed32fb7302 100644
--- a/src/library/scala/AnyVal.scala
+++ b/src/library/scala/AnyVal.scala
@@ -25,4 +25,8 @@ package scala
* The ''integer types'' include the subrange types as well as [[scala.Int]] and [[scala.Long]].
* The ''floating point types'' are [[scala.Float]] and [[scala.Double]].
*/
-sealed trait AnyVal
+trait AnyVal extends NotNull {
+// disabled for now to make the standard build go through.
+// Once we have a new strap we can uncomment this and delete the AnyVal_getClass entry in Definitions.
+// def getClass(): Class[_ <: AnyVal] = ???
+}
diff --git a/src/library/scala/Boolean.scala b/src/library/scala/Boolean.scala
index 0adcde3aba..5078e59d28 100644
--- a/src/library/scala/Boolean.scala
+++ b/src/library/scala/Boolean.scala
@@ -107,7 +107,7 @@ final class Boolean extends AnyVal {
*/
def ^(x: Boolean): Boolean = sys.error("stub")
- def getClass(): Class[Boolean] = sys.error("stub")
+ override def getClass(): Class[Boolean] = sys.error("stub")
}
object Boolean extends AnyValCompanion {
diff --git a/src/library/scala/Byte.scala b/src/library/scala/Byte.scala
index 4923cc9786..f9c5f6003e 100644
--- a/src/library/scala/Byte.scala
+++ b/src/library/scala/Byte.scala
@@ -590,7 +590,7 @@ final class Byte extends AnyVal {
*/
def %(x: Double): Double = sys.error("stub")
- def getClass(): Class[Byte] = sys.error("stub")
+ override def getClass(): Class[Byte] = sys.error("stub")
}
object Byte extends AnyValCompanion {
diff --git a/src/library/scala/Char.scala b/src/library/scala/Char.scala
index b4e6445899..3d459782cd 100644
--- a/src/library/scala/Char.scala
+++ b/src/library/scala/Char.scala
@@ -590,7 +590,7 @@ final class Char extends AnyVal {
*/
def %(x: Double): Double = sys.error("stub")
- def getClass(): Class[Char] = sys.error("stub")
+ override def getClass(): Class[Char] = sys.error("stub")
}
object Char extends AnyValCompanion {
diff --git a/src/library/scala/Double.scala b/src/library/scala/Double.scala
index 68a1a01299..01414265c4 100644
--- a/src/library/scala/Double.scala
+++ b/src/library/scala/Double.scala
@@ -356,7 +356,7 @@ final class Double extends AnyVal {
*/
def %(x: Double): Double = sys.error("stub")
- def getClass(): Class[Double] = sys.error("stub")
+ override def getClass(): Class[Double] = sys.error("stub")
}
object Double extends AnyValCompanion {
diff --git a/src/library/scala/Float.scala b/src/library/scala/Float.scala
index 709d73d408..ff5b3cb112 100644
--- a/src/library/scala/Float.scala
+++ b/src/library/scala/Float.scala
@@ -356,7 +356,7 @@ final class Float extends AnyVal {
*/
def %(x: Double): Double = sys.error("stub")
- def getClass(): Class[Float] = sys.error("stub")
+ override def getClass(): Class[Float] = sys.error("stub")
}
object Float extends AnyValCompanion {
diff --git a/src/library/scala/Int.scala b/src/library/scala/Int.scala
index 519a0486ac..316bbced2d 100644
--- a/src/library/scala/Int.scala
+++ b/src/library/scala/Int.scala
@@ -590,7 +590,7 @@ final class Int extends AnyVal {
*/
def %(x: Double): Double = sys.error("stub")
- def getClass(): Class[Int] = sys.error("stub")
+ override def getClass(): Class[Int] = sys.error("stub")
}
object Int extends AnyValCompanion {
diff --git a/src/library/scala/Long.scala b/src/library/scala/Long.scala
index 9c7a803f08..ce8618c22a 100644
--- a/src/library/scala/Long.scala
+++ b/src/library/scala/Long.scala
@@ -590,7 +590,7 @@ final class Long extends AnyVal {
*/
def %(x: Double): Double = sys.error("stub")
- def getClass(): Class[Long] = sys.error("stub")
+ override def getClass(): Class[Long] = sys.error("stub")
}
object Long extends AnyValCompanion {
diff --git a/src/library/scala/NotNull.scala b/src/library/scala/NotNull.scala
index d47d47a83e..f90b95c789 100644
--- a/src/library/scala/NotNull.scala
+++ b/src/library/scala/NotNull.scala
@@ -6,8 +6,6 @@
** |/ **
\* */
-
-
package scala
/**
diff --git a/src/library/scala/Proxy.scala b/src/library/scala/Proxy.scala
index 383ff5b3bb..16c3c3fa56 100644
--- a/src/library/scala/Proxy.scala
+++ b/src/library/scala/Proxy.scala
@@ -22,13 +22,15 @@ package scala
* @author Matthias Zenger
* @version 1.0, 26/04/2004
*/
-trait Proxy {
+trait Proxy extends Any {
def self: Any
override def hashCode: Int = self.hashCode
override def equals(that: Any): Boolean = that match {
- case null => false
- case x: AnyRef => (x eq this) || (x eq self.asInstanceOf[AnyRef]) || (x equals self)
+ case null => false
+ case _ =>
+ val x = that.asInstanceOf[AnyRef]
+ (x eq this.asInstanceOf[AnyRef]) || (x eq self.asInstanceOf[AnyRef]) || (x equals self)
}
override def toString = "" + self
}
@@ -36,7 +38,7 @@ trait Proxy {
object Proxy {
/** A proxy which exposes the type it is proxying for via a type parameter.
*/
- trait Typed[T] extends Proxy {
+ trait Typed[T] extends /*Any with */Proxy {
def self: T
}
}
diff --git a/src/library/scala/ScalaObject.scala b/src/library/scala/ScalaObject.scala
deleted file mode 100644
index 8da0ab2cba..0000000000
--- a/src/library/scala/ScalaObject.scala
+++ /dev/null
@@ -1,13 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala
-
-trait ScalaObject extends java.lang.Object
diff --git a/src/library/scala/Short.scala b/src/library/scala/Short.scala
index a9210d3555..5664c3b44c 100644
--- a/src/library/scala/Short.scala
+++ b/src/library/scala/Short.scala
@@ -590,7 +590,7 @@ final class Short extends AnyVal {
*/
def %(x: Double): Double = sys.error("stub")
- def getClass(): Class[Short] = sys.error("stub")
+ override def getClass(): Class[Short] = sys.error("stub")
}
object Short extends AnyValCompanion {
diff --git a/src/library/scala/Unit.scala b/src/library/scala/Unit.scala
index 57970b021b..f6ed0121ab 100644
--- a/src/library/scala/Unit.scala
+++ b/src/library/scala/Unit.scala
@@ -17,7 +17,7 @@ package scala
* method which is declared `void`.
*/
final class Unit extends AnyVal {
- def getClass(): Class[Unit] = sys.error("stub")
+ override def getClass(): Class[Unit] = sys.error("stub")
}
object Unit extends AnyValCompanion {
diff --git a/src/library/scala/collection/GenTraversableOnce.scala b/src/library/scala/collection/GenTraversableOnce.scala
index 305f8d768d..18b1a96155 100644
--- a/src/library/scala/collection/GenTraversableOnce.scala
+++ b/src/library/scala/collection/GenTraversableOnce.scala
@@ -41,7 +41,7 @@ package scala.collection
* @author Aleksandar Prokopec
* @since 2.9
*/
-trait GenTraversableOnce[+A] {
+trait GenTraversableOnce[+A] extends AnyRef {
def foreach[U](f: A => U): Unit
diff --git a/src/library/scala/collection/immutable/StringOps.scala b/src/library/scala/collection/immutable/StringOps.scala
index 8612357db9..09cbd247e9 100644
--- a/src/library/scala/collection/immutable/StringOps.scala
+++ b/src/library/scala/collection/immutable/StringOps.scala
@@ -28,7 +28,7 @@ import mutable.StringBuilder
* @define Coll StringOps
* @define coll string
*/
-final class StringOps(override val repr: String) extends StringLike[String] {
+final class StringOps(override val repr: String) extends AnyRef with StringLike[String] {
override protected[this] def thisCollection: WrappedString = new WrappedString(repr)
override protected[this] def toCollection(repr: String): WrappedString = new WrappedString(repr)
diff --git a/src/library/scala/math/Ordered.scala b/src/library/scala/math/Ordered.scala
index 53d618db63..4397f14c94 100644
--- a/src/library/scala/math/Ordered.scala
+++ b/src/library/scala/math/Ordered.scala
@@ -50,7 +50,7 @@ package scala.math
* @author Martin Odersky
* @version 1.1, 2006-07-24
*/
-trait Ordered[A] extends java.lang.Comparable[A] {
+trait Ordered[A] extends /*Any with*/ java.lang.Comparable[A] {
/** Result of comparing `this` with operand `that`.
*
diff --git a/src/library/scala/runtime/ScalaNumberProxy.scala b/src/library/scala/runtime/ScalaNumberProxy.scala
index 09e1611dcd..bd19e099e0 100644
--- a/src/library/scala/runtime/ScalaNumberProxy.scala
+++ b/src/library/scala/runtime/ScalaNumberProxy.scala
@@ -64,7 +64,7 @@ abstract class FractionalProxy[T : Fractional] extends ScalaNumberProxy[T] with
def to(end: T, step: T): NumericRange.Inclusive[T] = NumericRange.inclusive(self, end, step)
}
-trait OrderedProxy[T] extends Typed[T] with Ordered[T] {
+trait OrderedProxy[T] extends Ordered[T] with Typed[T] {
protected def ord: Ordering[T]
def compare(y: T) = ord.compare(self, y)
diff --git a/src/library/scala/util/Properties.scala b/src/library/scala/util/Properties.scala
index 22de5544a8..df1c68ced4 100644
--- a/src/library/scala/util/Properties.scala
+++ b/src/library/scala/util/Properties.scala
@@ -15,7 +15,7 @@ import java.util.jar.Attributes.{ Name => AttributeName }
/** Loads `library.properties` from the jar. */
object Properties extends PropertiesTrait {
protected def propCategory = "library"
- protected def pickJarBasedOn = classOf[ScalaObject]
+ protected def pickJarBasedOn = classOf[Option[_]]
/** Scala manifest attributes.
*/
diff --git a/test/files/neg/anyval-children-2.check b/test/files/neg/anyval-children-2.check
new file mode 100644
index 0000000000..cb327faeeb
--- /dev/null
+++ b/test/files/neg/anyval-children-2.check
@@ -0,0 +1,4 @@
+anyval-children-2.scala:1: error: Only @inline classes (not traits) are allowed to extend AnyVal
+@inline trait NotOkDingus1 extends AnyVal // fail
+ ^
+one error found
diff --git a/test/files/neg/anyval-children-2.scala b/test/files/neg/anyval-children-2.scala
new file mode 100644
index 0000000000..4034eb22dd
--- /dev/null
+++ b/test/files/neg/anyval-children-2.scala
@@ -0,0 +1 @@
+@inline trait NotOkDingus1 extends AnyVal // fail
diff --git a/test/files/neg/anyval-children.check b/test/files/neg/anyval-children.check
new file mode 100644
index 0000000000..cbb5a2b1d1
--- /dev/null
+++ b/test/files/neg/anyval-children.check
@@ -0,0 +1,26 @@
+anyval-children.scala:7: error: illegal inheritance; superclass Bippy
+ is not a subclass of the superclass Object
+ of the mixin trait ScalaObject
+class NotOkBippy1 extends Bippy // fail
+ ^
+anyval-children.scala:9: error: illegal inheritance; superclass Bippy
+ is not a subclass of the superclass Object
+ of the mixin trait Immutable
+class NotOkBippy2 extends Bippy with Immutable //fail
+ ^
+anyval-children.scala:9: error: illegal inheritance; superclass Bippy
+ is not a subclass of the superclass Object
+ of the mixin trait ScalaObject
+class NotOkBippy2 extends Bippy with Immutable //fail
+ ^
+anyval-children.scala:11: error: illegal inheritance; superclass Bippy
+ is not a subclass of the superclass Object
+ of the mixin trait Immutable
+@inline class NotOkBippy3 extends Bippy with Immutable //fail
+ ^
+anyval-children.scala:11: error: illegal inheritance; superclass Bippy
+ is not a subclass of the superclass Object
+ of the mixin trait ScalaObject
+@inline class NotOkBippy3 extends Bippy with Immutable //fail
+ ^
+5 errors found
diff --git a/test/files/neg/anyval-children.scala b/test/files/neg/anyval-children.scala
new file mode 100644
index 0000000000..5a6109f786
--- /dev/null
+++ b/test/files/neg/anyval-children.scala
@@ -0,0 +1,14 @@
+class Bippy extends AnyVal // fail
+
+@inline class NotOkDingus2 extends Immutable with AnyVal // fail
+
+@inline object NotOkDingus3 extends AnyVal // fail
+
+class NotOkBippy1 extends Bippy // fail
+
+class NotOkBippy2 extends Bippy with Immutable //fail
+
+@inline class NotOkBippy3 extends Bippy with Immutable //fail
+
+
+@inline class OkBippy extends AnyVal // ok
diff --git a/test/files/neg/anyval-sealed.check b/test/files/neg/anyval-sealed.check
deleted file mode 100644
index 48a457b496..0000000000
--- a/test/files/neg/anyval-sealed.check
+++ /dev/null
@@ -1,12 +0,0 @@
-anyval-sealed.scala:2: error: match is not exhaustive!
-missing combination Byte
-missing combination Char
-missing combination Double
-missing combination Float
-missing combination Long
-missing combination Short
-missing combination Unit
-
- def f(x: AnyVal) = x match {
- ^
-one error found
diff --git a/test/files/neg/anyval-sealed.flags b/test/files/neg/anyval-sealed.flags
deleted file mode 100644
index 85d8eb2ba2..0000000000
--- a/test/files/neg/anyval-sealed.flags
+++ /dev/null
@@ -1 +0,0 @@
--Xfatal-warnings
diff --git a/test/files/neg/anyval-sealed.scala b/test/files/neg/anyval-sealed.scala
deleted file mode 100644
index 232a183479..0000000000
--- a/test/files/neg/anyval-sealed.scala
+++ /dev/null
@@ -1,6 +0,0 @@
-class A {
- def f(x: AnyVal) = x match {
- case _: Boolean => 1
- case _: Int => 2
- }
-} \ No newline at end of file
diff --git a/test/files/neg/override-object-no.check b/test/files/neg/override-object-no.check
index 6e028d0add..f9fb37381b 100644
--- a/test/files/neg/override-object-no.check
+++ b/test/files/neg/override-object-no.check
@@ -1,13 +1,13 @@
override-object-no.scala:14: error: overriding object Bar in trait Foo with object Bar in trait Foo2:
an overriding object must conform to the overridden object's class bound;
- found : case1.Bippy with ScalaObject
- required: case1.Bippy with case1.Bippo with ScalaObject
+ found : case1.Bippy
+ required: case1.Bippy with case1.Bippo
override object Bar extends Bippy { // err
^
override-object-no.scala:21: error: overriding object Bar in trait Quux1 with object Bar in trait Quux2:
an overriding object must conform to the overridden object's class bound;
- found : Object with ScalaObject{def g: String}
- required: Object with ScalaObject{def g: Int}
+ found : Object{def g: String}
+ required: Object{def g: Int}
trait Quux2 extends Quux1 { override object Bar { def g = "abc" } } // err
^
override-object-no.scala:25: error: overriding object Bar in trait Quux3 of type object Quux4.this.Bar;
@@ -16,8 +16,8 @@ override-object-no.scala:25: error: overriding object Bar in trait Quux3 of type
^
override-object-no.scala:43: error: overriding object A in class Foo with object A in class P2:
an overriding object must conform to the overridden object's class bound;
- found : case2.Bar[List[String]] with ScalaObject
- required: case2.Bar[Traversable[String]] with ScalaObject
+ found : case2.Bar[List[String]]
+ required: case2.Bar[Traversable[String]]
override object A extends Bar[List[String]] // err
^
four errors found
diff --git a/test/files/neg/t0699.check b/test/files/neg/t0699.check
index 45d3e849cc..c944da8c10 100644
--- a/test/files/neg/t0699.check
+++ b/test/files/neg/t0699.check
@@ -1,10 +1,10 @@
-B.scala:2: error: illegal inheritance from sealed trait T: t0699/B.scala != t0699/A.scala
+B.scala:2: error: illegal inheritance from sealed trait T
trait T1 extends A.T
^
-B.scala:3: error: illegal inheritance from sealed class C: t0699/B.scala != t0699/A.scala
+B.scala:3: error: illegal inheritance from sealed class C
trait T2 extends A.C
^
-B.scala:4: error: illegal inheritance from sealed class C: t0699/B.scala != t0699/A.scala
+B.scala:4: error: illegal inheritance from sealed class C
class C1 extends A.C
^
three errors found
diff --git a/test/files/neg/t3222.check b/test/files/neg/t3222.check
index e724024f45..b1e1e50448 100644
--- a/test/files/neg/t3222.check
+++ b/test/files/neg/t3222.check
@@ -1,7 +1,7 @@
-t3222.scala:4: error: not found: type D
- def foo(@throws(classOf[D]) x: Int) {}
- ^
t3222.scala:1: error: not found: type B
@throws(classOf[B])
^
+t3222.scala:4: error: not found: type D
+ def foo(@throws(classOf[D]) x: Int) {}
+ ^
two errors found
diff --git a/test/files/pos/anyval-children.flags b/test/files/pos/anyval-children.flags
new file mode 100644
index 0000000000..80fce051e6
--- /dev/null
+++ b/test/files/pos/anyval-children.flags
@@ -0,0 +1 @@
+-Ystop-after:erasure \ No newline at end of file
diff --git a/test/files/pos/anyval-children.scala b/test/files/pos/anyval-children.scala
new file mode 100644
index 0000000000..4ef10a094f
--- /dev/null
+++ b/test/files/pos/anyval-children.scala
@@ -0,0 +1 @@
+@inline class Bippy extends AnyVal \ No newline at end of file
diff --git a/test/files/run/programmatic-main.check b/test/files/run/programmatic-main.check
index 4aeb3ab60c..a24de79b8a 100644
--- a/test/files/run/programmatic-main.check
+++ b/test/files/run/programmatic-main.check
@@ -4,26 +4,27 @@
namer 2 resolve names, attach symbols to named trees
packageobjects 3 load package objects
typer 4 the meat and potatoes: type the trees
- superaccessors 5 add super accessors in traits and nested classes
- pickler 6 serialize symbol tables
- refchecks 7 reference/override checking, translate nested objects
- liftcode 8 reify trees
- uncurry 9 uncurry, translate function values to anonymous classes
- tailcalls 10 replace tail calls by jumps
- specialize 11 @specialized-driven class and method specialization
- explicitouter 12 this refs to outer pointers, translate patterns
- erasure 13 erase types, add interfaces for traits
- lazyvals 14 allocate bitmaps, translate lazy vals into lazified defs
- lambdalift 15 move nested functions to top level
- constructors 16 move field definitions into constructors
- flatten 17 eliminate inner classes
- mixin 18 mixin composition
- cleanup 19 platform-specific cleanups, generate reflective calls
- icode 20 generate portable intermediate code
- inliner 21 optimization: do inlining
-inlineExceptionHandlers 22 optimization: inline exception handlers
- closelim 23 optimization: eliminate uncalled closures
- dce 24 optimization: eliminate dead code
- jvm 25 generate JVM bytecode
- terminal 26 The last phase in the compiler chain
+ extmethods 5 add extension methods for inline classes
+ superaccessors 6 add super accessors in traits and nested classes
+ pickler 7 serialize symbol tables
+ refchecks 8 reference/override checking, translate nested objects
+ liftcode 9 reify trees
+ uncurry 10 uncurry, translate function values to anonymous classes
+ tailcalls 11 replace tail calls by jumps
+ specialize 12 @specialized-driven class and method specialization
+ explicitouter 13 this refs to outer pointers, translate patterns
+ erasure 14 erase types, add interfaces for traits
+ lazyvals 15 allocate bitmaps, translate lazy vals into lazified defs
+ lambdalift 16 move nested functions to top level
+ constructors 17 move field definitions into constructors
+ flatten 18 eliminate inner classes
+ mixin 19 mixin composition
+ cleanup 20 platform-specific cleanups, generate reflective calls
+ icode 21 generate portable intermediate code
+ inliner 22 optimization: do inlining
+inlineExceptionHandlers 23 optimization: inline exception handlers
+ closelim 24 optimization: eliminate uncalled closures
+ dce 25 optimization: eliminate dead code
+ jvm 26 generate JVM bytecode
+ terminal 27 The last phase in the compiler chain