summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/msil.jar.desired.sha12
-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.scala185
-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.scala9
-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.scala90
-rw-r--r--src/compiler/scala/reflect/internal/pickling/UnPickler.scala1
-rw-r--r--src/compiler/scala/reflect/internal/transform/Erasure.scala20
-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/reflect/runtime/Universe.scala6
-rw-r--r--src/compiler/scala/tools/cmd/gen/AnyVals.scala6
-rw-r--r--src/compiler/scala/tools/nsc/Global.scala53
-rw-r--r--src/compiler/scala/tools/nsc/ast/Reifiers.scala1
-rw-r--r--src/compiler/scala/tools/nsc/ast/TreeInfo.scala11
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Parsers.scala36
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala11
-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/transform/AddInterfaces.scala20
-rw-r--r--src/compiler/scala/tools/nsc/transform/Constructors.scala15
-rw-r--r--src/compiler/scala/tools/nsc/transform/Erasure.scala61
-rw-r--r--src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala169
-rw-r--r--src/compiler/scala/tools/nsc/transform/InlineErasure.scala9
-rw-r--r--src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala6
-rw-r--r--src/compiler/scala/tools/nsc/transform/UnCurry.scala2
-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.scala55
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/RefChecks.scala28
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala11
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala79
-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/Equals.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.scala4
-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/GenIterableLike.scala2
-rw-r--r--src/library/scala/collection/GenSeqLike.scala2
-rw-r--r--src/library/scala/collection/GenTraversableLike.scala2
-rw-r--r--src/library/scala/collection/GenTraversableOnce.scala2
-rw-r--r--src/library/scala/collection/IterableLike.scala2
-rw-r--r--src/library/scala/collection/Parallelizable.scala2
-rw-r--r--src/library/scala/collection/SeqLike.scala4
-rw-r--r--src/library/scala/collection/TraversableLike.scala3
-rw-r--r--src/library/scala/collection/TraversableOnce.scala5
-rwxr-xr-xsrc/library/scala/collection/generic/FilterMonadic.scala2
-rwxr-xr-xsrc/library/scala/collection/generic/HasNewBuilder.scala2
-rw-r--r--src/library/scala/collection/immutable/StringOps.scala2
-rw-r--r--src/library/scala/collection/mutable/ArrayBuilder.scala2
-rw-r--r--src/library/scala/collection/mutable/ListBuffer.scala4
-rw-r--r--src/library/scala/math/Equiv.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/buildmanager/t2556_3/t2556_3.check4
-rw-r--r--test/files/lib/scalacheck.jar.desired.sha12
-rw-r--r--test/files/neg/anyval-anyref-parent.check4
-rw-r--r--test/files/neg/anyval-anyref-parent.scala7
-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.check23
-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/t0764.check2
-rw-r--r--test/files/neg/t2641.check6
-rw-r--r--test/files/neg/t3222.check6
-rw-r--r--test/files/neg/t3691.check4
-rw-r--r--test/files/neg/t464-neg.check4
-rw-r--r--test/files/neg/t4877.check2
-rw-r--r--test/files/neg/t5060.check4
-rw-r--r--test/files/neg/t664.check4
-rw-r--r--test/files/neg/variances.check2
-rw-r--r--test/files/pos/anyval-children.flags1
-rw-r--r--test/files/pos/anyval-children.scala1
-rw-r--r--test/files/pos/t1050.scala2
-rw-r--r--test/files/pos/trait-parents.scala16
-rw-r--r--test/files/presentation/callcc-interpreter.check4
-rw-r--r--test/files/run/primitive-sigs-2.check2
-rw-r--r--test/files/run/programmatic-main.check43
-rw-r--r--test/files/run/repl-parens.check2
-rw-r--r--test/files/run/t4172.check2
-rw-r--r--test/files/run/t4891.check1
-rw-r--r--test/files/scalap/abstractClass/result.test2
-rw-r--r--test/files/scalap/abstractMethod/result.test2
-rw-r--r--test/files/scalap/caseClass/result.test2
-rw-r--r--test/files/scalap/caseObject/result.test2
-rw-r--r--test/files/scalap/cbnParam/result.test2
-rw-r--r--test/files/scalap/classPrivate/result.test6
-rw-r--r--test/files/scalap/classWithExistential/result.test4
-rw-r--r--test/files/scalap/classWithSelfAnnotation/result.test2
-rw-r--r--test/files/scalap/covariantParam/result.test2
-rw-r--r--test/files/scalap/implicitParam/result.test2
-rw-r--r--test/files/scalap/packageObject/result.test2
-rw-r--r--test/files/scalap/paramClauses/result.test2
-rw-r--r--test/files/scalap/paramNames/result.test2
-rw-r--r--test/files/scalap/sequenceParam/result.test2
-rw-r--r--test/files/scalap/simpleClass/result.test2
-rw-r--r--test/files/scalap/traitObject/result.test4
-rw-r--r--test/files/scalap/typeAnnotations/result.test4
-rw-r--r--test/files/scalap/valAndVar/result.test2
-rw-r--r--test/files/scalap/wildcardType/result.test2
-rw-r--r--test/files/speclib/instrumented.jar.desired.sha12
-rw-r--r--test/scaladoc/scala/html/HtmlFactoryTest.scala42
131 files changed, 919 insertions, 483 deletions
diff --git a/lib/msil.jar.desired.sha1 b/lib/msil.jar.desired.sha1
index 7dd6b5d66b..ac09965566 100644
--- a/lib/msil.jar.desired.sha1
+++ b/lib/msil.jar.desired.sha1
@@ -1 +1 @@
-58f64cd00399c724e7d526e5bdcbce3e2b79f78b ?msil.jar
+046beeda12838b9ad34306caad71a523d06b1f31 ?msil.jar
diff --git a/lib/scala-compiler.jar.desired.sha1 b/lib/scala-compiler.jar.desired.sha1
index 209189f444..79f6de5e27 100644
--- a/lib/scala-compiler.jar.desired.sha1
+++ b/lib/scala-compiler.jar.desired.sha1
@@ -1 +1 @@
-de9c0ef2ac2d13e2b56148ab2fe22de4ccdc34fc ?scala-compiler.jar
+40f87533e0d03ad04ca632119286d347ee54d8ae ?scala-compiler.jar
diff --git a/lib/scala-library-src.jar.desired.sha1 b/lib/scala-library-src.jar.desired.sha1
index 81d1f677a5..cfb865f1e8 100644
--- a/lib/scala-library-src.jar.desired.sha1
+++ b/lib/scala-library-src.jar.desired.sha1
@@ -1 +1 @@
-d92a0fd350a661b4ba55f1aeea43a2ba5dec4629 ?scala-library-src.jar
+4a34794dd9a45cd2e8603de559f565535e7aa74b ?scala-library-src.jar
diff --git a/lib/scala-library.jar.desired.sha1 b/lib/scala-library.jar.desired.sha1
index 30a8a5bbab..28a2c586a0 100644
--- a/lib/scala-library.jar.desired.sha1
+++ b/lib/scala-library.jar.desired.sha1
@@ -1 +1 @@
-7fc8fd16bf0fe5cb25e9d43c614fe203fba397c5 ?scala-library.jar
+3516dc2e17bf72b1e4bc665e59f6b7ec51cba48d ?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 e05ac1087b..4d465ca4a0 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,33 @@ trait Definitions extends reflect.api.StandardDefinitions {
case _ => null
}
+ 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)
+ lazy val AnyValClass = ScalaPackageClass.info member tpnme.AnyVal orElse {
+ val anyval = enterNewClass(ScalaPackageClass, tpnme.AnyVal, List(AnyClass.tpe, NotNullClass.tpe), ABSTRACT)
+ 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 +265,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 +292,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 +331,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 = getRequiredClass("java.lang.Comparable") modifyInfo fixupAsAnyTrait
lazy val JavaCloneableClass = getRequiredClass("java.lang.Cloneable")
lazy val RemoteInterfaceClass = getRequiredClass("java.rmi.Remote")
lazy val RemoteExceptionClass = getRequiredClass("java.rmi.RemoteException")
@@ -421,7 +441,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 _ =>
@@ -431,7 +451,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)
@@ -491,7 +511,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 +658,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 +676,89 @@ 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)
+ )
+ }
+ }
+
+ /** Remove references to class Object (other than the head) in a list of parents */
+ def removeLaterObjects(tps: List[Type]): List[Type] = tps match {
+ case Nil => Nil
+ case x :: xs => x :: xs.filterNot(_.typeSymbol == ObjectClass)
+ }
+ /** Remove all but one reference to class Object from a list of parents. */
+ def removeRedundantObjects(tps: List[Type]): List[Type] = tps match {
+ case Nil => Nil
+ case x :: xs =>
+ if (x.typeSymbol == ObjectClass)
+ x :: xs.filterNot(_.typeSymbol == ObjectClass)
+ else
+ x :: removeRedundantObjects(xs)
+ }
+ /** Order a list of types with non-trait classes before others. */
+ def classesFirst(tps: List[Type]): List[Type] = {
+ val (classes, others) = tps partition (t => t.typeSymbol.isClass && !t.typeSymbol.isTrait)
+ if (classes.isEmpty || others.isEmpty || (tps startsWith classes)) tps
+ else classes ::: others
+ }
+ /** The following transformations applied to a list of parents.
+ * If any parent is a class/trait, all parents which normalize to
+ * Object are discarded. Otherwise, all parents which normalize
+ * to Object except the first one found are discarded.
+ */
+ def normalizedParents(parents: List[Type]): List[Type] = {
+ if (parents exists (t => (t.typeSymbol ne ObjectClass) && t.typeSymbol.isClass))
+ parents filterNot (_.typeSymbol eq ObjectClass)
+ else
+ removeRedundantObjects(parents)
+ }
+ def parentsString(parents: List[Type]) =
+ normalizedParents(parents) mkString " with "
+
// 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 +843,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 +863,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 +915,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 +934,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 +957,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 +1046,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,16 +1076,10 @@ trait Definitions extends reflect.api.StandardDefinitions {
Object_synchronized,
Object_isInstanceOf,
Object_asInstanceOf,
- String_+
+ String_+,
+ ComparableClass
)
- /** Removing the anyref parent they acquire from having a source file.
- */
- setParents(AnyValClass, anyparam)
- ScalaValueClasses foreach { sym =>
- setParents(sym, anyvalparam)
- }
-
isInitialized = true
} //init
@@ -1005,7 +1092,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 c170eb334f..1d6696a082 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 8e63e3a63c..6093b0962f 100644
--- a/src/compiler/scala/reflect/internal/Symbols.scala
+++ b/src/compiler/scala/reflect/internal/Symbols.scala
@@ -499,6 +499,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
@@ -2484,7 +2486,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
@@ -2714,7 +2716,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..def1350187 100644
--- a/src/compiler/scala/reflect/internal/TreeGen.scala
+++ b/src/compiler/scala/reflect/internal/TreeGen.scala
@@ -10,11 +10,10 @@ abstract class TreeGen {
def rootId(name: Name) = Select(Ident(nme.ROOTPKG), name)
def rootScalaDot(name: Name) = Select(rootId(nme.scala_) setSymbol ScalaPackage, name)
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)
+ def scalaAnyRefConstr = scalaDot(tpnme.AnyRef) setSymbol AnyRefClass
+ def scalaUnitConstr = scalaDot(tpnme.Unit) setSymbol UnitClass
+ def productConstr = scalaDot(tpnme.Product) setSymbol ProductRootClass
+ def serializableConstr = scalaDot(tpnme.Serializable) setSymbol SerializableClass
def scalaFunctionConstr(argtpes: List[Tree], restpe: Tree, abstractFun: Boolean = false): Tree = {
val cls = if (abstractFun)
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 e484faff2e..371618ad79 100644
--- a/src/compiler/scala/reflect/internal/TreePrinters.scala
+++ b/src/compiler/scala/reflect/internal/TreePrinters.scala
@@ -242,6 +242,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) {
@@ -253,6 +257,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 6ce6a7fac0..4ae8b0d5ac 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
@@ -329,6 +344,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 cd44b700c1..c283f0259b 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 =>
@@ -409,6 +411,11 @@ trait Types extends api.Types { self: SymbolTable =>
* inherited by typerefs, singleton types, and refinement types,
* The empty list for all other types */
def parents: List[Type] = List()
+
+ /** For a class with nonEmpty parents, the first parent.
+ * Otherwise some specific fixed top type.
+ */
+ def firstParent = if (parents.nonEmpty) parents.head else ObjectClass.tpe
/** For a typeref or single-type, the prefix of the normalized type (@see normalize).
* NoType for all other types. */
@@ -1411,14 +1418,14 @@ trait Types extends api.Types { self: SymbolTable =>
// override def isNullable: Boolean =
// parents forall (p => p.isNullable && !p.typeSymbol.isAbstractType);
- override def safeToString: String =
- parents.mkString(" with ") +
+ override def safeToString: String = parentsString(parents) + (
(if (settings.debug.value || parents.isEmpty || (decls.elems ne null))
decls.mkString("{", "; ", "}") else "")
+ )
}
protected def defineBaseTypeSeqOfCompoundType(tpe: CompoundType) = {
- val period = tpe.baseTypeSeqPeriod;
+ val period = tpe.baseTypeSeqPeriod
if (period != currentPeriod) {
tpe.baseTypeSeqPeriod = currentPeriod
if (!isValidForBaseClasses(period)) {
@@ -1476,7 +1483,7 @@ trait Types extends api.Types { self: SymbolTable =>
else {
//Console.println("computing base classes of " + typeSymbol + " at phase " + phase);//DEBUG
// optimized, since this seems to be performance critical
- val superclazz = tpe.parents.head
+ val superclazz = tpe.firstParent
var mixins = tpe.parents.tail
val sbcs = superclazz.baseClasses
var bcs = sbcs
@@ -1523,7 +1530,7 @@ trait Types extends api.Types { self: SymbolTable =>
)
override def typeParams =
- if (isHigherKinded) parents.head.typeParams
+ if (isHigherKinded) firstParent.typeParams
else super.typeParams
//@M may result in an invalid type (references to higher-order args become dangling )
@@ -2141,12 +2148,12 @@ trait Types extends api.Types { self: SymbolTable =>
)
else ""
)
+
private def finishPrefix(rest: String) = (
if (sym.isPackageClass) packagePrefix + rest
else if (sym.isModuleClass) objectPrefix + rest
else if (!sym.isInitialized) rest
- else if (sym.isAnonymousClass && !phase.erasedTypes)
- thisInfo.parents.mkString("", " with ", refinementString)
+ else if (sym.isAnonymousClass && !phase.erasedTypes) parentsString(thisInfo.parents) + refinementString
else if (sym.isRefinementClass) "" + thisInfo
else rest
)
@@ -3068,6 +3075,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.
*/
@@ -3215,11 +3231,21 @@ trait Types extends api.Types { self: SymbolTable =>
* comment or in the code?
*/
def intersectionType(tps: List[Type], owner: Symbol): Type = tps match {
- case List(tp) =>
- tp
- case _ =>
- refinedType(tps, owner)
-/*
+ case tp :: Nil => tp
+ case _ => refinedType(tps, owner)
+ }
+ /** A creator for intersection type where intersections of a single type are
+ * replaced by the type itself.
+ */
+ def intersectionType(tps: List[Type]): Type = tps match {
+ case tp :: Nil => tp
+ case _ => refinedType(tps, commonOwner(tps))
+ }
+
+/**** This implementation to merge parents was checked in in commented-out
+ form and has languished unaltered for five years. I think we should
+ use it or lose it.
+
def merge(tps: List[Type]): List[Type] = tps match {
case tp :: tps1 =>
val tps1a = tps1 filter (_.typeSymbol.==(tp.typeSymbol))
@@ -3234,14 +3260,6 @@ trait Types extends api.Types { self: SymbolTable =>
}
refinedType(merge(tps), owner)
*/
- }
-
- /** A creator for intersection type where intersections of a single type are
- * replaced by the type itself. */
- def intersectionType(tps: List[Type]): Type = tps match {
- case List(tp) => tp
- case _ => refinedType(tps, commonOwner(tps))
- }
/** A creator for type applications */
def appliedType(tycon: Type, args: List[Type]): Type =
@@ -3261,7 +3279,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).
*
@@ -3270,9 +3288,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.
*
@@ -3724,6 +3751,7 @@ trait Types extends api.Types { self: SymbolTable =>
case WildcardType => tp
case NoType => tp
case NoPrefix => tp
+ case ErasedSingleType(sym) => tp
*/
case _ =>
tp
@@ -4484,9 +4512,7 @@ trait Types extends api.Types { self: SymbolTable =>
else {
commonOwnerMap.clear()
tps foreach (commonOwnerMap traverse _)
- val result = if (commonOwnerMap.result ne null) commonOwnerMap.result else NoSymbol
- debuglog(tps.mkString("commonOwner(", ", ", ") == " + result))
- result
+ if (commonOwnerMap.result ne null) commonOwnerMap.result else NoSymbol
}
}
@@ -5384,8 +5410,7 @@ trait Types extends api.Types { self: SymbolTable =>
case NullClass =>
tp2 match {
case TypeRef(_, sym2, _) =>
- sym2.isClass && (sym2 isNonBottomSubClass ObjectClass) &&
- !(tp2.normalize.typeSymbol isNonBottomSubClass NotNullClass)
+ containsNull(sym2)
case _ =>
isSingleType(tp2) && tp1 <:< tp2.widen
}
@@ -5416,6 +5441,11 @@ trait Types extends api.Types { self: SymbolTable =>
firstTry
}
+ private def containsNull(sym: Symbol): Boolean =
+ sym.isClass && sym != NothingClass &&
+ !(sym isNonBottomSubClass AnyValClass) &&
+ !(sym isNonBottomSubClass NotNullClass)
+
/** Are `tps1` and `tps2` lists of equal length such that all elements
* of `tps1` conform to corresponding elements of `tps2`?
*/
@@ -5427,7 +5457,7 @@ trait Types extends api.Types { self: SymbolTable =>
*/
def specializesSym(tp: Type, sym: Symbol): Boolean =
tp.typeSymbol == NothingClass ||
- tp.typeSymbol == NullClass && (sym.owner isSubClass ObjectClass) ||
+ tp.typeSymbol == NullClass && containsNull(sym.owner) ||
(tp.nonPrivateMember(sym.name).alternatives exists
(alt => sym == alt || specializesSym(tp.narrow, alt, sym.owner.thisType, sym)))
@@ -6393,7 +6423,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/pickling/UnPickler.scala b/src/compiler/scala/reflect/internal/pickling/UnPickler.scala
index b21b33e138..92ac9b1426 100644
--- a/src/compiler/scala/reflect/internal/pickling/UnPickler.scala
+++ b/src/compiler/scala/reflect/internal/pickling/UnPickler.scala
@@ -229,6 +229,7 @@ abstract class UnPickler /*extends reflect.generic.UnPickler*/ {
// (3) Try as a nested object symbol.
nestedObjectSymbol orElse {
// (4) Otherwise, fail.
+ //System.err.println("missing "+name+" in "+owner+"/"+owner.id+" "+owner.info.decls)
adjust(errorMissingRequirement(name, owner))
}
}
diff --git a/src/compiler/scala/reflect/internal/transform/Erasure.scala b/src/compiler/scala/reflect/internal/transform/Erasure.scala
index d59fc6d564..7c360e1f25 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)
@@ -217,15 +225,7 @@ trait Erasure {
/** Type reference after erasure */
def erasedTypeRef(sym: Symbol): Type =
- 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)
- }
+ typeRef(erasure(sym, sym.owner.tpe), sym, Nil)
/** 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 c09022e535..b12d84b34f 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/reflect/runtime/Universe.scala b/src/compiler/scala/reflect/runtime/Universe.scala
index c786bb86c5..d1d9855860 100644
--- a/src/compiler/scala/reflect/runtime/Universe.scala
+++ b/src/compiler/scala/reflect/runtime/Universe.scala
@@ -37,6 +37,12 @@ class Universe extends SymbolTable {
type Position = String // source file?
val NoPosition = ""
+ definitions.AnyValClass // force it.
+
// establish root association to avoid cyclic dependency errors later
classToScala(classOf[java.lang.Object]).initialize
+
+// println("initializing definitions")
+ definitions.init()
+
}
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 18735cafe2..281a2eb49b 100644
--- a/src/compiler/scala/tools/nsc/Global.scala
+++ b/src/compiler/scala/tools/nsc/Global.scala
@@ -438,59 +438,65 @@ 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 = "uncurry"
override object uncurry extends {
val global: Global.this.type = Global.this
- val runsAfter = List[String]("refchecks")
+ val runsAfter = List("refchecks")
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
@@ -498,84 +504,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
@@ -591,7 +597,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
@@ -645,6 +651,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",
uncurry -> "uncurry, translate function values to anonymous classes",
@@ -1018,6 +1025,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")
@@ -1347,7 +1355,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
*
@@ -1375,7 +1383,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/Reifiers.scala b/src/compiler/scala/tools/nsc/ast/Reifiers.scala
index 105d2cb62b..c05475d50c 100644
--- a/src/compiler/scala/tools/nsc/ast/Reifiers.scala
+++ b/src/compiler/scala/tools/nsc/ast/Reifiers.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/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..c2b4dc32b6 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,16 +2753,24 @@ 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 (inScalaPackage && name == tpnme.AnyVal) {
+ // Not a well-formed constructor, has to be finished later - see note
+ // regarding AnyVal constructor in AddInterfaces.
+ val constructor = DefDef(NoMods, nme.CONSTRUCTOR, Nil, List(Nil), TypeTree(), Block(Nil, Literal(Constant())))
+ Template(parents0, self, constructor :: body)
+ }
+ else if (isPrimitiveType(name))
+ Template(List(scalaAnyValConstr), self, body)
+ else if (parents0 exists isReferenceToAnyVal) {
+ // @inline and other restrictions enforced in refchecks
+ Template(parents0, self, body)
}
else {
- val parents = (
- if (!isInterface(mods, body) && !isScalaArray(name)) parents0 :+ scalaScalaObjectConstr
- else if (parents0.isEmpty) List(scalaAnyRefConstr)
- else parents0
- ) ++ caseParents()
+ val casePs = caseParents()
+ val parents = parents0 match {
+ case Nil if casePs.isEmpty => List(scalaAnyRefConstr)
+ case _ => parents0 ++ casePs
+ }
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..40389466e2 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala
@@ -29,12 +29,13 @@ abstract class TreeBuilder {
def rootId(name: Name) = gen.rootId(name)
def rootScalaDot(name: Name) = gen.rootScalaDot(name)
def scalaDot(name: Name) = gen.scalaDot(name)
- def scalaAnyRefConstr = gen.scalaAnyRefConstr
- def scalaUnitConstr = gen.scalaUnitConstr
- def scalaScalaObjectConstr = gen.scalaScalaObjectConstr
- def productConstr = gen.productConstr
+ def scalaAnyRefConstr = scalaDot(tpnme.AnyRef)
+ def scalaAnyValConstr = scalaDot(tpnme.AnyVal)
+ def scalaAnyConstr = scalaDot(tpnme.Any)
+ def scalaUnitConstr = scalaDot(tpnme.Unit)
+ def productConstr = scalaDot(tpnme.Product)
def productConstrN(n: Int) = scalaDot(newTypeName("Product" + n))
- def serializableConstr = gen.serializableConstr
+ def serializableConstr = scalaDot(tpnme.Serializable)
def convertToTypeName(t: Tree) = gen.convertToTypeName(t)
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 a8083d7a2d..ed89acd9e8 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/transform/AddInterfaces.scala b/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala
index e01bbccf13..e7759f1d7e 100644
--- a/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala
+++ b/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala
@@ -298,15 +298,25 @@ 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 {
+ tree match {
case Block(stats, expr) =>
// needs `hasSymbol` check because `supercall` could be a block (named / default args)
- val (presuper, supercall :: rest) = stats span (t => t.hasSymbolWhich(_ hasFlag PRESUPER))
- // assert(supercall.symbol.isClassConstructor, supercall)
- treeCopy.Block(tree, presuper ::: (supercall :: mixinConstructorCalls ::: rest), expr)
+ stats span (t => t.hasSymbolWhich(_ hasFlag PRESUPER)) match {
+ case (presuper, supercall :: rest) =>
+ stats span (t => t.hasSymbolWhich(_ hasFlag PRESUPER))
+ treeCopy.Block(tree, presuper ::: (supercall :: mixinConstructorCalls ::: rest), expr)
+ case (Nil, Nil) =>
+ assert(clazz eq AnyValClass, clazz)
+ // AnyVal constructor - have to provide a real body so the
+ // jvm doesn't throw a VerifyError. But we can't add the
+ // body until now, because the typer knows that Any has no
+ // constructor and won't accept a call to super.init.
+ val superCall = Apply(Select(Super(This(tpnme.EMPTY), tpnme.EMPTY), nme.CONSTRUCTOR), Nil)
+ Block(List(superCall), Literal(Constant()))
+ }
}
}
diff --git a/src/compiler/scala/tools/nsc/transform/Constructors.scala b/src/compiler/scala/tools/nsc/transform/Constructors.scala
index d1c71faf1e..b60b411f47 100644
--- a/src/compiler/scala/tools/nsc/transform/Constructors.scala
+++ b/src/compiler/scala/tools/nsc/transform/Constructors.scala
@@ -44,11 +44,14 @@ abstract class Constructors extends Transform with ast.TreeDSL {
)
// decompose primary constructor into the three entities above.
val constrInfo: ConstrInfo = {
- val primary = stats find (_.symbol.isPrimaryConstructor)
- assert(primary.isDefined, "no constructor in template: impl = " + impl)
-
- val ddef @ DefDef(_, _, _, List(vparams), _, rhs @ Block(_, _)) = primary.get
- ConstrInfo(ddef, vparams map (_.symbol), rhs)
+ stats find (_.symbol.isPrimaryConstructor) match {
+ case Some(ddef @ DefDef(_, _, _, List(vparams), _, rhs @ Block(_, _))) =>
+ ConstrInfo(ddef, vparams map (_.symbol), rhs)
+ case x =>
+ // AnyVal constructor is OK
+ assert(clazz eq AnyValClass, "no constructor in template: impl = " + impl)
+ return impl
+ }
}
import constrInfo._
@@ -445,7 +448,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..828338425e 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)
@@ -368,6 +335,9 @@ abstract class Erasure extends AddInterfaces
class UnknownSig extends Exception
+ override def eraseInlineClassRef(clazz: Symbol): Type = ErasedInlineType(clazz)
+
+
/** The symbol's erased info. This is the type's erasure, except for the following symbols:
*
* - For $asInstanceOf : [T]T
@@ -602,7 +572,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)
@@ -747,7 +717,7 @@ abstract class Erasure extends AddInterfaces
var bridges: List[Tree] = List()
val opc = atPhase(currentRun.explicitouterPhase) {
new overridingPairs.Cursor(owner) {
- override def parents: List[Type] = List(owner.info.parents.head)
+ override def parents: List[Type] = List(owner.info.firstParent)
override def exclude(sym: Symbol): Boolean =
!sym.isMethod || sym.isPrivate || super.exclude(sym)
}
@@ -931,6 +901,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 +954,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..4db05f46d3
--- /dev/null
+++ b/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala
@@ -0,0 +1,169 @@
+/* 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... [Martin]: No, it wasn't; it's curried.
+ MethodType(List(thisParam), 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
+ println("expanding "+tree+"/"+allParams(extensionMono)+"/"+extensionMeth.info)
+ 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/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/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
index ab4a2141a9..adbb7bc7f1 100644
--- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala
+++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
@@ -633,7 +633,7 @@ abstract class UnCurry extends InfoTransform
tree1
}
} setType {
- assert(tree.tpe != null, tree + " tpe is null")
+ assert(tree.tpe != null, "tpe is null at " + tree.pos + " for " + tree.summaryString + " / " + tree)
uncurryTreeType(tree.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..a5e3c3e25d 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)
@@ -705,6 +705,17 @@ trait Namers extends MethodSynthesis {
if (needsCycleCheck && !typer.checkNonCyclic(tree.pos, tp))
sym setInfo ErrorType
}
+ // tree match {
+ // case ClassDef(_, _, _, impl) =>
+ // val parentsOK = (
+ // treeInfo.isInterface(sym, impl.body)
+ // || (sym eq ArrayClass)
+ // || (sym isSubClass AnyValClass)
+ // )
+ // if (!parentsOK)
+ // ensureParent(sym, AnyRefClass)
+ // case _ => ()
+ // }
}
def moduleClassTypeCompleter(tree: Tree) = {
@@ -836,6 +847,7 @@ trait Namers extends MethodSynthesis {
}
val parents = typer.parentTypes(templ) map checkParent
+
enterSelf(templ.self)
val decls = newScope
@@ -886,7 +898,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 +941,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 +1195,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 +1259,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 +1320,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 +1413,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 +1446,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/NamesDefaults.scala b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala
index 3a3c244d1c..359e72e3e4 100644
--- a/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala
@@ -228,7 +228,7 @@ trait NamesDefaults { self: Analyzer =>
case Select(sp @ Super(_, _), _) if isConstr =>
// 'moduleQual' fixes #3207. selection of the companion module of the
// superclass needs to have the same prefix as the superclass.
- blockWithoutQualifier(moduleQual(baseFun.pos, sp.symbol.tpe.parents.head))
+ blockWithoutQualifier(moduleQual(baseFun.pos, sp.symbol.tpe.firstParent))
// self constructor calls (in secondary constructors)
case Select(tp, name) if isConstr =>
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
index fa4664b34f..04213cfda7 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()
}
}
@@ -1480,7 +1482,10 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R
if (settings.Xmigration28.value)
checkMigration(sym, tree.pos)
- if (currentClass != sym.owner && sym.hasLocalFlag) {
+ if (sym eq NoSymbol) {
+ unit.warning(tree.pos, "Select node has NoSymbol! " + tree + " / " + tree.tpe)
+ }
+ else if (currentClass != sym.owner && sym.hasLocalFlag) {
var o = currentClass
var hidden = false
while (!hidden && o != sym.owner && o != sym.owner.moduleClass && !o.isPackage) {
@@ -1526,6 +1531,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 +1579,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 bc8a8a31b5..59437dc036 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)
@@ -943,7 +943,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) &&
@@ -1088,7 +1088,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 =
@@ -1103,12 +1103,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))))
}
}
@@ -1194,7 +1194,7 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser {
}
def parentTypes(templ: Template): List[Tree] =
- if (templ.parents.isEmpty) List()
+ if (templ.parents.isEmpty) List(TypeTree(AnyRefClass.tpe))
else try {
val clazz = context.owner
// Normalize supertype and mixins so that supertype is always a class, not a trait.
@@ -1206,9 +1206,11 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser {
val supertpt1 = typedType(supertpt)
if (!supertpt1.isErrorTyped) {
mixins = supertpt1 :: mixins
- supertpt = TypeTree(supertpt1.tpe.parents.head) setPos supertpt.pos.focus
+ supertpt = TypeTree(supertpt1.tpe.firstParent) setPos supertpt.pos.focus
}
}
+ if (supertpt.tpe.typeSymbol == AnyClass && firstParent.isTrait && firstParent != AnyValClass)
+ supertpt.tpe = AnyRefClass.tpe
// Determine
// - supertparams: Missing type parameters from supertype
@@ -1298,12 +1300,15 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser {
else xs
)
}
+
fixDuplicates(supertpt :: mixins) mapConserve (tpt => checkNoEscaping.privates(clazz, tpt))
}
catch {
case ex: TypeError =>
// fallback in case of cyclic errors
// @H none of the tests enter here but I couldn't rule it out
+ log("Type error calculating parents in template " + templ)
+ log("Error: " + ex)
ParentTypesError(templ, ex)
List(TypeTree(AnyRefClass.tpe))
}
@@ -1340,13 +1345,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)
@@ -1412,6 +1416,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.firstParent.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,
@@ -1779,8 +1787,12 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser {
transformedOrTyped(ddef.rhs, EXPRmode, tpt1.tpe)
}
- if (meth.isPrimaryConstructor && meth.isClassConstructor && !isPastTyper && !reporter.hasErrors)
- computeParamAliases(meth.owner, vparamss1, rhs1)
+ if (meth.isPrimaryConstructor && meth.isClassConstructor && !isPastTyper && !reporter.hasErrors) {
+ // At this point in AnyVal there is no supercall, which will blow up
+ // in computeParamAliases; there's nothing to be computed for Anyval anyway.
+ if (meth.owner ne AnyValClass)
+ computeParamAliases(meth.owner, vparamss1, rhs1)
+ }
if (tpt1.tpe.typeSymbol != NothingClass && !context.returnsSeen && rhs1.tpe.typeSymbol != NothingClass)
rhs1 = checkDead(rhs1)
@@ -2508,8 +2520,11 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser {
/** This is translating uses of List() into Nil. This is less
* than ideal from a consistency standpoint, but it shouldn't be
* altered without due caution.
+ * ... this also causes bootstrapping cycles if List_apply is
+ * forced during kind-arity checking, so it is guarded by additional
+ * tests to ensure we're sufficiently far along.
*/
- if (fun.symbol == List_apply && args.isEmpty && !forInteractive)
+ if (args.isEmpty && !forInteractive && fun.symbol.isInitialized && ListModule.hasCompleteInfo && (fun.symbol == List_apply))
atPos(tree.pos)(gen.mkNil setType restpe)
else
constfold(treeCopy.Apply(tree, fun, args1) setType ifPatternSkipFormals(restpe))
@@ -2887,10 +2902,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
@@ -3053,7 +3068,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),
@@ -3656,16 +3671,11 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser {
}
}
- val owntype =
- if (mix.isEmpty) {
- if ((mode & SUPERCONSTRmode) != 0)
- if (clazz.info.parents.isEmpty) AnyRefClass.tpe // can happen due to cyclic references ==> #1036
- else clazz.info.parents.head
- else intersectionType(clazz.info.parents)
- } else {
- findMixinSuper(clazz.tpe)
- }
-
+ val owntype = (
+ if (!mix.isEmpty) findMixinSuper(clazz.tpe)
+ else if ((mode & SUPERCONSTRmode) != 0) clazz.info.firstParent
+ else intersectionType(clazz.info.parents)
+ )
treeCopy.Super(tree, qual1, mix) setType SuperType(clazz.thisType, owntype)
}
@@ -3821,7 +3831,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
}
@@ -3877,7 +3887,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
@@ -4065,7 +4075,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)
@@ -4273,7 +4283,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,
@@ -4368,7 +4378,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 (
@@ -4600,6 +4610,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..393f0899f4 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
+abstract class AnyVal extends Any with 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/Equals.scala b/src/library/scala/Equals.scala
index 8aff7af175..4545c21e45 100644
--- a/src/library/scala/Equals.scala
+++ b/src/library/scala/Equals.scala
@@ -11,7 +11,7 @@ package scala
/** An interface containing operations for equality.
* The only method not already present in class `AnyRef` is `canEqual`.
*/
-trait Equals {
+trait Equals extends Any {
/** A method that should be called from every well-designed equals method
* that is open to be overridden in a subclass. See Programming in Scala,
* Chapter 28 for discussion and design.
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..64f999a932 100644
--- a/src/library/scala/NotNull.scala
+++ b/src/library/scala/NotNull.scala
@@ -6,12 +6,10 @@
** |/ **
\* */
-
-
package scala
/**
* A marker trait for things that are not allowed to be null
* @since 2.5
*/
-trait NotNull {}
+trait NotNull extends Any {}
diff --git a/src/library/scala/Proxy.scala b/src/library/scala/Proxy.scala
index 383ff5b3bb..604b2a299f 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/GenIterableLike.scala b/src/library/scala/collection/GenIterableLike.scala
index 18132f0a7b..7e68733afd 100644
--- a/src/library/scala/collection/GenIterableLike.scala
+++ b/src/library/scala/collection/GenIterableLike.scala
@@ -34,7 +34,7 @@ import generic.{ CanBuildFrom => CBF, _ }
* This is a base trait for all Scala collections that define an `iterator`
* method to step through one-by-one the collection's elements.
*/
-trait GenIterableLike[+A, +Repr] extends GenTraversableLike[A, Repr] {
+trait GenIterableLike[+A, +Repr] extends Any with GenTraversableLike[A, Repr] {
def iterator: Iterator[A]
diff --git a/src/library/scala/collection/GenSeqLike.scala b/src/library/scala/collection/GenSeqLike.scala
index 63e9543711..cb0e96fcbb 100644
--- a/src/library/scala/collection/GenSeqLike.scala
+++ b/src/library/scala/collection/GenSeqLike.scala
@@ -30,7 +30,7 @@ import annotation.bridge
* Sequences are special cases of iterable collections of class `Iterable`.
* Unlike iterables, sequences always have a defined order of elements.
*/
-trait GenSeqLike[+A, +Repr] extends GenIterableLike[A, Repr] with Equals with Parallelizable[A, parallel.ParSeq[A]] {
+trait GenSeqLike[+A, +Repr] extends Any with GenIterableLike[A, Repr] with Equals with Parallelizable[A, parallel.ParSeq[A]] {
def seq: Seq[A]
/** Selects an element by its index in the $coll.
diff --git a/src/library/scala/collection/GenTraversableLike.scala b/src/library/scala/collection/GenTraversableLike.scala
index c837775cf9..80667f559f 100644
--- a/src/library/scala/collection/GenTraversableLike.scala
+++ b/src/library/scala/collection/GenTraversableLike.scala
@@ -53,7 +53,7 @@ import annotation.migration
* @author Aleksandar Prokopec
* @since 2.9
*/
-trait GenTraversableLike[+A, +Repr] extends GenTraversableOnce[A] with Parallelizable[A, parallel.ParIterable[A]] {
+trait GenTraversableLike[+A, +Repr] extends Any with GenTraversableOnce[A] with Parallelizable[A, parallel.ParIterable[A]] {
def repr: Repr
diff --git a/src/library/scala/collection/GenTraversableOnce.scala b/src/library/scala/collection/GenTraversableOnce.scala
index 305f8d768d..6df112a652 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 Any {
def foreach[U](f: A => U): Unit
diff --git a/src/library/scala/collection/IterableLike.scala b/src/library/scala/collection/IterableLike.scala
index 4b0c5662d8..73d4efe125 100644
--- a/src/library/scala/collection/IterableLike.scala
+++ b/src/library/scala/collection/IterableLike.scala
@@ -49,7 +49,7 @@ import annotation.bridge
* @define Coll Iterable
* @define coll iterable collection
*/
-trait IterableLike[+A, +Repr] extends Equals with TraversableLike[A, Repr] with GenIterableLike[A, Repr] {
+trait IterableLike[+A, +Repr] extends Any with Equals with TraversableLike[A, Repr] with GenIterableLike[A, Repr] {
self =>
override protected[this] def thisCollection: Iterable[A] = this.asInstanceOf[Iterable[A]]
diff --git a/src/library/scala/collection/Parallelizable.scala b/src/library/scala/collection/Parallelizable.scala
index 59b37aff96..5bcefb81b2 100644
--- a/src/library/scala/collection/Parallelizable.scala
+++ b/src/library/scala/collection/Parallelizable.scala
@@ -17,7 +17,7 @@ import parallel.Combiner
* @tparam A the type of the elements in the collection
* @tparam ParRepr the actual type of the collection, which has to be parallel
*/
-trait Parallelizable[+A, +ParRepr <: Parallel] {
+trait Parallelizable[+A, +ParRepr <: Parallel] extends Any {
def seq: TraversableOnce[A]
diff --git a/src/library/scala/collection/SeqLike.scala b/src/library/scala/collection/SeqLike.scala
index 02298ef096..526ea7e240 100644
--- a/src/library/scala/collection/SeqLike.scala
+++ b/src/library/scala/collection/SeqLike.scala
@@ -59,7 +59,7 @@ import scala.math.Ordering
* @define orderDependent
* @define orderDependentFold
*/
-trait SeqLike[+A, +Repr] extends IterableLike[A, Repr] with GenSeqLike[A, Repr] with Parallelizable[A, ParSeq[A]] { self =>
+trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[A, Repr] with Parallelizable[A, ParSeq[A]] { self =>
override protected[this] def thisCollection: Seq[A] = this.asInstanceOf[Seq[A]]
override protected[this] def toCollection(repr: Repr): Seq[A] = repr.asInstanceOf[Seq[A]]
@@ -151,7 +151,7 @@ trait SeqLike[+A, +Repr] extends IterableLike[A, Repr] with GenSeqLike[A, Repr]
def next(): Repr = {
if (!hasNext)
Iterator.empty.next
-
+
val forcedElms = new mutable.ArrayBuffer[A](elms.size) ++= elms
val result = (self.newBuilder ++= forcedElms).result
var i = idxs.length - 2
diff --git a/src/library/scala/collection/TraversableLike.scala b/src/library/scala/collection/TraversableLike.scala
index 36d45c0c8a..0da1cfb913 100644
--- a/src/library/scala/collection/TraversableLike.scala
+++ b/src/library/scala/collection/TraversableLike.scala
@@ -64,7 +64,8 @@ import parallel.ParIterable
* @define Coll Traversable
* @define coll traversable collection
*/
-trait TraversableLike[+A, +Repr] extends HasNewBuilder[A, Repr]
+trait TraversableLike[+A, +Repr] extends Any
+ with HasNewBuilder[A, Repr]
with FilterMonadic[A, Repr]
with TraversableOnce[A]
with GenTraversableLike[A, Repr]
diff --git a/src/library/scala/collection/TraversableOnce.scala b/src/library/scala/collection/TraversableOnce.scala
index 5bb2e563f6..62ea692b90 100644
--- a/src/library/scala/collection/TraversableOnce.scala
+++ b/src/library/scala/collection/TraversableOnce.scala
@@ -56,7 +56,7 @@ import annotation.unchecked.{ uncheckedVariance => uV }
*
* Note: will not terminate for infinite-sized collections.
*/
-trait TraversableOnce[+A] extends GenTraversableOnce[A] {
+trait TraversableOnce[+A] extends Any with GenTraversableOnce[A] {
self =>
/** Self-documenting abstract methods. */
@@ -360,6 +360,7 @@ trait TraversableOnce[+A] extends GenTraversableOnce[A] {
object TraversableOnce {
implicit def traversableOnceCanBuildFrom[T] = new OnceCanBuildFrom[T]
implicit def wrapTraversableOnce[A](trav: TraversableOnce[A]) = new MonadOps(trav)
+ implicit def alternateImplicit[A](trav: TraversableOnce[A]) = new ForceImplicitAmbiguity
implicit def flattenTraversableOnce[A, CC[_]](travs: TraversableOnce[CC[A]])(implicit ev: CC[A] => TraversableOnce[A]) =
new FlattenOps[A](travs map ev)
@@ -391,6 +392,8 @@ object TraversableOnce {
}
}
+ class ForceImplicitAmbiguity
+
class MonadOps[+A](trav: TraversableOnce[A]) {
def map[B](f: A => B): TraversableOnce[B] = trav.toIterator map f
def flatMap[B](f: A => GenTraversableOnce[B]): TraversableOnce[B] = trav.toIterator flatMap f
diff --git a/src/library/scala/collection/generic/FilterMonadic.scala b/src/library/scala/collection/generic/FilterMonadic.scala
index 4d6d9ec6a3..d79112d616 100755
--- a/src/library/scala/collection/generic/FilterMonadic.scala
+++ b/src/library/scala/collection/generic/FilterMonadic.scala
@@ -12,7 +12,7 @@ package scala.collection.generic
/** A template trait that contains just the `map`, `flatMap`, `foreach` and `withFilter` methods
* of trait `TraversableLike`.
*/
-trait FilterMonadic[+A, +Repr] {
+trait FilterMonadic[+A, +Repr] extends Any {
def map[B, That](f: A => B)(implicit bf: CanBuildFrom[Repr, B, That]): That
def flatMap[B, That](f: A => collection.GenTraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That
def foreach[U](f: A => U): Unit
diff --git a/src/library/scala/collection/generic/HasNewBuilder.scala b/src/library/scala/collection/generic/HasNewBuilder.scala
index 6154a56441..8f0ce01911 100755
--- a/src/library/scala/collection/generic/HasNewBuilder.scala
+++ b/src/library/scala/collection/generic/HasNewBuilder.scala
@@ -10,7 +10,7 @@ package generic
import mutable.Builder
-trait HasNewBuilder[+A, +Repr] {
+trait HasNewBuilder[+A, +Repr] extends Any {
/** The builder that builds instances of Repr */
protected[this] def newBuilder: Builder[A, Repr]
}
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/collection/mutable/ArrayBuilder.scala b/src/library/scala/collection/mutable/ArrayBuilder.scala
index f72ba78446..f0e4c79abf 100644
--- a/src/library/scala/collection/mutable/ArrayBuilder.scala
+++ b/src/library/scala/collection/mutable/ArrayBuilder.scala
@@ -76,7 +76,7 @@ object ArrayBuilder {
this
}
- override def ++=(xs: TraversableOnce[T]): this.type = (xs: AnyRef) match {
+ override def ++=(xs: TraversableOnce[T]): this.type = (xs.asInstanceOf[AnyRef]) match {
case xs: WrappedArray.ofRef[_] =>
ensureSize(this.size + xs.length)
Array.copy(xs.array, 0, elems, this.size, xs.length)
diff --git a/src/library/scala/collection/mutable/ListBuffer.scala b/src/library/scala/collection/mutable/ListBuffer.scala
index 53c876ec08..26200c1f3e 100644
--- a/src/library/scala/collection/mutable/ListBuffer.scala
+++ b/src/library/scala/collection/mutable/ListBuffer.scala
@@ -175,10 +175,10 @@ final class ListBuffer[A]
}
override def ++=(xs: TraversableOnce[A]): this.type =
- if (xs eq this) ++= (this take size) else super.++=(xs)
+ if (xs.asInstanceOf[AnyRef] eq this) ++= (this take size) else super.++=(xs)
override def ++=:(xs: TraversableOnce[A]): this.type =
- if (xs eq this) ++=: (this take size) else super.++=:(xs)
+ if (xs.asInstanceOf[AnyRef] eq this) ++=: (this take size) else super.++=:(xs)
/** Clears the buffer contents.
*/
diff --git a/src/library/scala/math/Equiv.scala b/src/library/scala/math/Equiv.scala
index 92a794578e..bd8414a18d 100644
--- a/src/library/scala/math/Equiv.scala
+++ b/src/library/scala/math/Equiv.scala
@@ -29,7 +29,7 @@ import java.util.Comparator
* @since 2.7
*/
-trait Equiv[T] {
+trait Equiv[T] extends Any {
/** Returns `true` iff `x` is equivalent to `y`.
*/
def equiv(x: T, y: T): Boolean
diff --git a/src/library/scala/math/Ordered.scala b/src/library/scala/math/Ordered.scala
index 53d618db63..b76030718f 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/buildmanager/t2556_3/t2556_3.check b/test/files/buildmanager/t2556_3/t2556_3.check
index bf26602494..37808d2b31 100644
--- a/test/files/buildmanager/t2556_3/t2556_3.check
+++ b/test/files/buildmanager/t2556_3/t2556_3.check
@@ -3,8 +3,8 @@ compiling Set(A.scala, B.scala, C.scala)
Changes: Map()
builder > A.scala
compiling Set(A.scala)
-Changes: Map(class A -> List(), class B -> List(Changed(Class(B))[List((A,Object), (ScalaObject,ScalaObject))]))
-invalidate C.scala because parents have changed [Changed(Class(B))[List((A,Object), (ScalaObject,ScalaObject))]]
+Changes: Map(class A -> List(), class B -> List(Changed(Class(B))[List((A,Object))]))
+invalidate C.scala because parents have changed [Changed(Class(B))[List((A,Object))]]
invalidate B.scala because it references invalid (no longer inherited) definition [ParentChanged(Class(C))]
compiling Set(B.scala, C.scala)
B.scala:3: error: type mismatch;
diff --git a/test/files/lib/scalacheck.jar.desired.sha1 b/test/files/lib/scalacheck.jar.desired.sha1
index b104f58897..2be7479415 100644
--- a/test/files/lib/scalacheck.jar.desired.sha1
+++ b/test/files/lib/scalacheck.jar.desired.sha1
@@ -1 +1 @@
-2a3e19c3d8d93be661e66f941f19e7d49c667c2b ?scalacheck.jar
+f8cd51e0f78e30b3ac444b741b0b2249ac8248bb ?scalacheck.jar
diff --git a/test/files/neg/anyval-anyref-parent.check b/test/files/neg/anyval-anyref-parent.check
new file mode 100644
index 0000000000..b40a0f2710
--- /dev/null
+++ b/test/files/neg/anyval-anyref-parent.check
@@ -0,0 +1,4 @@
+anyval-anyref-parent.scala:5: error: Any does not have a constructor
+class Bar1 extends Any // fail
+ ^
+one error found
diff --git a/test/files/neg/anyval-anyref-parent.scala b/test/files/neg/anyval-anyref-parent.scala
new file mode 100644
index 0000000000..b7bb122ea8
--- /dev/null
+++ b/test/files/neg/anyval-anyref-parent.scala
@@ -0,0 +1,7 @@
+trait Foo1 extends Any
+trait Foo2 extends AnyVal
+trait Foo3 extends AnyRef
+
+class Bar1 extends Any // fail
+@inline class Bar2 extends AnyVal
+class Bar3 extends AnyRef
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..769f990210
--- /dev/null
+++ b/test/files/neg/anyval-children.check
@@ -0,0 +1,23 @@
+anyval-children.scala:3: error: class AnyVal needs to be a trait to be mixed in
+@inline class NotOkDingus2 extends Immutable with AnyVal // fail
+ ^
+anyval-children.scala:7: error: Bippy does not have a constructor
+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: Bippy does not have a constructor
+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: Bippy does not have a constructor
+@inline class NotOkBippy3 extends Bippy with Immutable //fail
+ ^
+6 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/t0764.check b/test/files/neg/t0764.check
index 0788db7f6e..e14c7705b8 100644
--- a/test/files/neg/t0764.check
+++ b/test/files/neg/t0764.check
@@ -1,5 +1,5 @@
t0764.scala:13: error: type mismatch;
- found : Object with Node{type T = _1.type} where val _1: Node{type T = NextType}
+ found : Node{type T = _1.type} where val _1: Node{type T = NextType}
required: Node{type T = Main.this.AType}
new Main[AType]( (value: AType).prepend )
^
diff --git a/test/files/neg/t2641.check b/test/files/neg/t2641.check
index 9e2f02ac47..909f4f0cf3 100644
--- a/test/files/neg/t2641.check
+++ b/test/files/neg/t2641.check
@@ -9,11 +9,7 @@ t2641.scala:17: error: illegal inheritance;
self-type ManagedSeq does not conform to scala.collection.TraversableView[A,ManagedSeqStrict[A]]'s selftype scala.collection.TraversableView[A,ManagedSeqStrict[A]]
with TraversableView[A, ManagedSeqStrict[A]]
^
-t2641.scala:16: error: illegal inheritance;
- self-type ManagedSeq does not conform to ScalaObject's selftype ScalaObject
- extends ManagedSeqStrict[A]
- ^
t2641.scala:27: error: value managedIterator is not a member of ManagedSeq
override def managedIterator = self.managedIterator slice (from, until)
^
-5 errors found
+four 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/neg/t3691.check b/test/files/neg/t3691.check
index cd7b440dce..bdf6c268b2 100644
--- a/test/files/neg/t3691.check
+++ b/test/files/neg/t3691.check
@@ -1,10 +1,10 @@
t3691.scala:4: error: type mismatch;
- found : Object with Test.A[String]
+ found : Test.A[String]
required: AnyRef{type A[x]}
val b = (new A[String]{}): { type A[x] } // not ok
^
t3691.scala:5: error: type mismatch;
- found : Object with Test.A[String]
+ found : Test.A[String]
required: AnyRef{type A}
val c = (new A[String]{}): { type A } // not ok
^
diff --git a/test/files/neg/t464-neg.check b/test/files/neg/t464-neg.check
index aea1987b2e..e822e7fb6b 100644
--- a/test/files/neg/t464-neg.check
+++ b/test/files/neg/t464-neg.check
@@ -1,7 +1,7 @@
t464-neg.scala:7: error: not found: value f1
f1()
^
-t464-neg.scala:8: error: method f1 in class A cannot be accessed in A with ScalaObject
+t464-neg.scala:8: error: method f1 in class A cannot be accessed in A
super.f1()
^
t464-neg.scala:9: error: value f2 is not a member of B
@@ -10,7 +10,7 @@ t464-neg.scala:9: error: value f2 is not a member of B
t464-neg.scala:10: error: method f3 in class A cannot be accessed in B
f3()
^
-t464-neg.scala:11: error: method f3 in class A cannot be accessed in A with ScalaObject
+t464-neg.scala:11: error: method f3 in class A cannot be accessed in A
super.f3()
^
5 errors found
diff --git a/test/files/neg/t4877.check b/test/files/neg/t4877.check
index 0f72300bb4..a4b1e6a50d 100644
--- a/test/files/neg/t4877.check
+++ b/test/files/neg/t4877.check
@@ -9,7 +9,7 @@ t4877.scala:6: error: type mismatch;
def foo3: AnyRef { def bar(x: Int): Int } = new AnyRef { def bar(x: Int) = "abc" }
^
t4877.scala:7: error: type mismatch;
- found : Object with C{def bar(x: Int): Int}
+ found : C{def bar(x: Int): Int}
required: C{def bar(x: Int): Int; def quux(x: Int): Int}
def foo4: C { def bar(x: Int): Int ; def quux(x: Int): Int } = new C { def bar(x: Int) = 5 }
^
diff --git a/test/files/neg/t5060.check b/test/files/neg/t5060.check
index ab860c9d5b..e71f30ccdb 100644
--- a/test/files/neg/t5060.check
+++ b/test/files/neg/t5060.check
@@ -1,7 +1,7 @@
-t5060.scala:2: error: covariant type T occurs in contravariant position in type => Object with ScalaObject{def contains(x: T): Unit} of value foo0
+t5060.scala:2: error: covariant type T occurs in contravariant position in type => Object{def contains(x: T): Unit} of value foo0
val foo0 = {
^
-t5060.scala:6: error: covariant type T occurs in contravariant position in type => Object with ScalaObject{def contains(x: T): Unit} of method foo1
+t5060.scala:6: error: covariant type T occurs in contravariant position in type => Object{def contains(x: T): Unit} of method foo1
def foo1 = {
^
two errors found
diff --git a/test/files/neg/t664.check b/test/files/neg/t664.check
index 43a6bea074..cbdf53daea 100644
--- a/test/files/neg/t664.check
+++ b/test/files/neg/t664.check
@@ -1,7 +1,7 @@
-t664.scala:4: error: type Foo is not a member of test.Test with ScalaObject
+t664.scala:4: error: type Foo is not a member of test.Test
trait Foo extends super.Foo {
^
-t664.scala:5: error: type Bar is not a member of AnyRef with ScalaObject
+t664.scala:5: error: type Bar is not a member of AnyRef
trait Bar extends super.Bar;
^
two errors found
diff --git a/test/files/neg/variances.check b/test/files/neg/variances.check
index 4eaab56cef..dc72b05e1e 100644
--- a/test/files/neg/variances.check
+++ b/test/files/neg/variances.check
@@ -4,7 +4,7 @@ variances.scala:4: error: covariant type A occurs in contravariant position in t
variances.scala:14: error: covariant type A occurs in contravariant position in type A of value a
private[this] def setA(a : A) = this.a = a
^
-variances.scala:16: error: covariant type A occurs in invariant position in supertype test.C[A] with ScalaObject of object Baz
+variances.scala:16: error: covariant type A occurs in invariant position in supertype test.C[A] of object Baz
object Baz extends C[A]
^
variances.scala:63: error: covariant type A occurs in contravariant position in type => test.Covariant.T[A]{val m: A => A} of value x
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/pos/t1050.scala b/test/files/pos/t1050.scala
index e017e30713..d34b0cff16 100644
--- a/test/files/pos/t1050.scala
+++ b/test/files/pos/t1050.scala
@@ -1,7 +1,7 @@
package t1050
abstract class A {
- type T <: scala.ScalaObject
+ type T <: scala.AnyRef
class A { this: T =>
def b = 3
def c = b
diff --git a/test/files/pos/trait-parents.scala b/test/files/pos/trait-parents.scala
new file mode 100644
index 0000000000..f6a2688751
--- /dev/null
+++ b/test/files/pos/trait-parents.scala
@@ -0,0 +1,16 @@
+trait Bip extends Any
+trait Foo extends Any
+trait Bar extends AnyRef
+trait Quux
+
+object Test {
+ def f(x: Bip) = 1
+ def g1(x: Foo with Bip) = f(x)
+
+ def main(args: Array[String]): Unit = {
+ f(new Bip with Foo { })
+ f(new Foo with Bip { })
+ g1(new Bip with Foo { })
+ g1(new Foo with Bip { })
+ }
+}
diff --git a/test/files/presentation/callcc-interpreter.check b/test/files/presentation/callcc-interpreter.check
index 3385ef12b7..41b07b07dc 100644
--- a/test/files/presentation/callcc-interpreter.check
+++ b/test/files/presentation/callcc-interpreter.check
@@ -20,7 +20,7 @@ retrieved 64 members
`method ->[B](y: B)(callccInterpreter.type, B)`
`method ==(x$1: Any)Boolean`
`method ==(x$1: AnyRef)Boolean`
-`method add(a: callccInterpreter.Value, b: callccInterpreter.Value)callccInterpreter.M[_ >: callccInterpreter.Num with callccInterpreter.Wrong.type <: Product with Serializable with callccInterpreter.Value]`
+`method add(a: callccInterpreter.Value, b: callccInterpreter.Value)callccInterpreter.M[_ >: callccInterpreter.Num with callccInterpreter.Wrong.type <: Serializable with Product with callccInterpreter.Value]`
`method apply(a: callccInterpreter.Value, b: callccInterpreter.Value)callccInterpreter.M[callccInterpreter.Value]`
`method asInstanceOf[T0]=> T0`
`method callCC[A](h: (A => callccInterpreter.M[A]) => callccInterpreter.M[A])callccInterpreter.M[A]`
@@ -87,7 +87,7 @@ def showM(m: callccInterpreter.M[callccInterpreter.Value]): String = m.in.apply(
askType at CallccInterpreter.scala(50,30)
================================================================================
[response] askTypeAt at (50,30)
-def add(a: callccInterpreter.Value, b: callccInterpreter.Value): callccInterpreter.M[_ >: callccInterpreter.Num with callccInterpreter.Wrong.type <: Product with Serializable with callccInterpreter.Value] = scala.this.Predef.Pair.apply[callccInterpreter.Value, callccInterpreter.Value](a, b) match {
+def add(a: callccInterpreter.Value, b: callccInterpreter.Value): callccInterpreter.M[_ >: callccInterpreter.Num with callccInterpreter.Wrong.type <: Serializable with Product with callccInterpreter.Value] = scala.this.Predef.Pair.apply[callccInterpreter.Value, callccInterpreter.Value](a, b) match {
case scala.this.Predef.Pair.unapply[callccInterpreter.Value, callccInterpreter.Value](<unapply-selector>) <unapply> ((n: Int)callccInterpreter.Num((m @ _)), (n: Int)callccInterpreter.Num((n @ _))) => this.unitM[callccInterpreter.Num](callccInterpreter.this.Num.apply(m.+(n)))
case _ => callccInterpreter.this.unitM[callccInterpreter.Wrong.type](callccInterpreter.this.Wrong)
}
diff --git a/test/files/run/primitive-sigs-2.check b/test/files/run/primitive-sigs-2.check
index c69d1b54a6..feb0619525 100644
--- a/test/files/run/primitive-sigs-2.check
+++ b/test/files/run/primitive-sigs-2.check
@@ -1,4 +1,4 @@
-T<java.lang.Object> interface scala.ScalaObject
+T<java.lang.Object>
List(A, char, class java.lang.Object)
a
public <T> java.lang.Object Arr.arr4(java.lang.Object[],scala.reflect.Manifest<T>)
diff --git a/test/files/run/programmatic-main.check b/test/files/run/programmatic-main.check
index 6f253f5de1..b5a54f5ea7 100644
--- a/test/files/run/programmatic-main.check
+++ b/test/files/run/programmatic-main.check
@@ -4,25 +4,26 @@
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
- uncurry 8 uncurry, translate function values to anonymous classes
- tailcalls 9 replace tail calls by jumps
- specialize 10 @specialized-driven class and method specialization
- explicitouter 11 this refs to outer pointers, translate patterns
- erasure 12 erase types, add interfaces for traits
- lazyvals 13 allocate bitmaps, translate lazy vals into lazified defs
- lambdalift 14 move nested functions to top level
- constructors 15 move field definitions into constructors
- flatten 16 eliminate inner classes
- mixin 17 mixin composition
- cleanup 18 platform-specific cleanups, generate reflective calls
- icode 19 generate portable intermediate code
- inliner 20 optimization: do inlining
-inlineExceptionHandlers 21 optimization: inline exception handlers
- closelim 22 optimization: eliminate uncalled closures
- dce 23 optimization: eliminate dead code
- jvm 24 generate JVM bytecode
- terminal 25 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
+ 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
diff --git a/test/files/run/repl-parens.check b/test/files/run/repl-parens.check
index 944846541f..69f0a9ce30 100644
--- a/test/files/run/repl-parens.check
+++ b/test/files/run/repl-parens.check
@@ -66,7 +66,7 @@ scala> 55 ; () => 5
res13: () => Int = <function0>
scala> () => { class X ; new X }
-res14: () => Object with ScalaObject = <function0>
+res14: () => Object = <function0>
scala>
diff --git a/test/files/run/t4172.check b/test/files/run/t4172.check
index 95e3eb950d..da467e27ea 100644
--- a/test/files/run/t4172.check
+++ b/test/files/run/t4172.check
@@ -4,7 +4,7 @@ Type :help for more information.
scala>
scala> val c = { class C { override def toString = "C" }; ((new C, new C { def f = 2 })) }
-c: (C, C{def f: Int}) forSome { type C <: Object with ScalaObject } = (C,C)
+c: (C, C{def f: Int}) forSome { type C <: Object } = (C,C)
scala>
diff --git a/test/files/run/t4891.check b/test/files/run/t4891.check
index 072f8df8d4..79fd7f6fbb 100644
--- a/test/files/run/t4891.check
+++ b/test/files/run/t4891.check
@@ -5,4 +5,3 @@ test.generic.C1
test.generic.C2
(m) public void test.generic.C1.m1()
null
-interface scala.ScalaObject
diff --git a/test/files/scalap/abstractClass/result.test b/test/files/scalap/abstractClass/result.test
index 9b8fc4dd95..9163346fc6 100644
--- a/test/files/scalap/abstractClass/result.test
+++ b/test/files/scalap/abstractClass/result.test
@@ -1,4 +1,4 @@
-abstract class AbstractClass extends java.lang.Object with scala.ScalaObject {
+abstract class AbstractClass extends java.lang.Object {
def this() = { /* compiled code */ }
def foo : scala.Predef.String
}
diff --git a/test/files/scalap/abstractMethod/result.test b/test/files/scalap/abstractMethod/result.test
index a1bd378c87..90f572f258 100644
--- a/test/files/scalap/abstractMethod/result.test
+++ b/test/files/scalap/abstractMethod/result.test
@@ -1,4 +1,4 @@
-trait AbstractMethod extends java.lang.Object with scala.ScalaObject {
+trait AbstractMethod extends java.lang.Object {
def $init$() : scala.Unit = { /* compiled code */ }
def arity : scala.Int
def isCool : scala.Boolean = { /* compiled code */ }
diff --git a/test/files/scalap/caseClass/result.test b/test/files/scalap/caseClass/result.test
index a0dbc497fe..8e3255859f 100644
--- a/test/files/scalap/caseClass/result.test
+++ b/test/files/scalap/caseClass/result.test
@@ -1,4 +1,4 @@
-case class CaseClass[A <: scala.Seq[scala.Int]](i : A, s : scala.Predef.String) extends java.lang.Object with scala.ScalaObject with scala.Product with scala.Serializable {
+case class CaseClass[A <: scala.Seq[scala.Int]](i : A, s : scala.Predef.String) extends java.lang.Object with scala.Product with scala.Serializable {
val i : A = { /* compiled code */ }
val s : scala.Predef.String = { /* compiled code */ }
def foo : scala.Int = { /* compiled code */ }
diff --git a/test/files/scalap/caseObject/result.test b/test/files/scalap/caseObject/result.test
index 55e46eccd7..9c66c6ebb1 100644
--- a/test/files/scalap/caseObject/result.test
+++ b/test/files/scalap/caseObject/result.test
@@ -1,4 +1,4 @@
-case object CaseObject extends java.lang.Object with scala.ScalaObject with scala.Product with scala.Serializable {
+case object CaseObject extends java.lang.Object with scala.Product with scala.Serializable {
def bar : scala.Int = { /* compiled code */ }
override def productPrefix : java.lang.String = { /* compiled code */ }
def productArity : scala.Int = { /* compiled code */ }
diff --git a/test/files/scalap/cbnParam/result.test b/test/files/scalap/cbnParam/result.test
index c6b2f4caa8..fbe035d63c 100644
--- a/test/files/scalap/cbnParam/result.test
+++ b/test/files/scalap/cbnParam/result.test
@@ -1,3 +1,3 @@
-class CbnParam extends java.lang.Object with scala.ScalaObject {
+class CbnParam extends java.lang.Object {
def this(s : => scala.Predef.String) = { /* compiled code */ }
}
diff --git a/test/files/scalap/classPrivate/result.test b/test/files/scalap/classPrivate/result.test
index 0d12b779c3..5f2e1cc00e 100644
--- a/test/files/scalap/classPrivate/result.test
+++ b/test/files/scalap/classPrivate/result.test
@@ -1,10 +1,10 @@
-class ClassPrivate extends java.lang.Object with scala.ScalaObject {
+class ClassPrivate extends java.lang.Object {
def this() = { /* compiled code */ }
def baz : scala.Int = { /* compiled code */ }
- class Outer extends java.lang.Object with scala.ScalaObject {
+ class Outer extends java.lang.Object {
def this() = { /* compiled code */ }
private[ClassPrivate] def qux : scala.Int = { /* compiled code */ }
}
protected def quux : scala.Int = { /* compiled code */ }
private[ClassPrivate] def bar : scala.Int = { /* compiled code */ }
-} \ No newline at end of file
+}
diff --git a/test/files/scalap/classWithExistential/result.test b/test/files/scalap/classWithExistential/result.test
index 91afddaf0e..b8ce005da9 100644
--- a/test/files/scalap/classWithExistential/result.test
+++ b/test/files/scalap/classWithExistential/result.test
@@ -1,4 +1,4 @@
-class ClassWithExistential extends java.lang.Object with scala.ScalaObject {
+class ClassWithExistential extends java.lang.Object {
def this() = { /* compiled code */ }
def foo[A, B] : scala.Function1[A, B forSome {type A <: scala.Seq[scala.Int]; type B >: scala.Predef.String}] = { /* compiled code */ }
-} \ No newline at end of file
+}
diff --git a/test/files/scalap/classWithSelfAnnotation/result.test b/test/files/scalap/classWithSelfAnnotation/result.test
index 326437c7be..df7bd86643 100644
--- a/test/files/scalap/classWithSelfAnnotation/result.test
+++ b/test/files/scalap/classWithSelfAnnotation/result.test
@@ -1,4 +1,4 @@
-class ClassWithSelfAnnotation extends java.lang.Object with scala.ScalaObject {
+class ClassWithSelfAnnotation extends java.lang.Object {
this : ClassWithSelfAnnotation with java.lang.CharSequence =>
def this() = { /* compiled code */ }
def foo : scala.Int = { /* compiled code */ }
diff --git a/test/files/scalap/covariantParam/result.test b/test/files/scalap/covariantParam/result.test
index 8acd9b497a..2f52f1f28e 100644
--- a/test/files/scalap/covariantParam/result.test
+++ b/test/files/scalap/covariantParam/result.test
@@ -1,4 +1,4 @@
-class CovariantParam[+A] extends java.lang.Object with scala.ScalaObject {
+class CovariantParam[+A] extends java.lang.Object {
def this() = { /* compiled code */ }
def foo[A](a : A) : scala.Int = { /* compiled code */ }
}
diff --git a/test/files/scalap/implicitParam/result.test b/test/files/scalap/implicitParam/result.test
index 11d678df06..0ea212dda6 100644
--- a/test/files/scalap/implicitParam/result.test
+++ b/test/files/scalap/implicitParam/result.test
@@ -1,4 +1,4 @@
-class ImplicitParam extends java.lang.Object with scala.ScalaObject {
+class ImplicitParam extends java.lang.Object {
def this() = { /* compiled code */ }
def foo(i : scala.Int)(implicit f : scala.Float, d : scala.Double) : scala.Int = { /* compiled code */ }
}
diff --git a/test/files/scalap/packageObject/result.test b/test/files/scalap/packageObject/result.test
index 6a8d6ae1d5..94c6a01b08 100644
--- a/test/files/scalap/packageObject/result.test
+++ b/test/files/scalap/packageObject/result.test
@@ -1,4 +1,4 @@
-package object PackageObject extends java.lang.Object with scala.ScalaObject {
+package object PackageObject extends java.lang.Object {
def this() = { /* compiled code */ }
type A = scala.Predef.String
def foo(i : scala.Int) : scala.Int = { /* compiled code */ }
diff --git a/test/files/scalap/paramClauses/result.test b/test/files/scalap/paramClauses/result.test
index 9ef93d2e76..dc4397386c 100644
--- a/test/files/scalap/paramClauses/result.test
+++ b/test/files/scalap/paramClauses/result.test
@@ -1,4 +1,4 @@
-class ParamClauses extends java.lang.Object with scala.ScalaObject {
+class ParamClauses extends java.lang.Object {
def this() = { /* compiled code */ }
def foo(i : scala.Int)(s : scala.Predef.String)(t : scala.Double) : scala.Int = { /* compiled code */ }
}
diff --git a/test/files/scalap/paramNames/result.test b/test/files/scalap/paramNames/result.test
index f9d98d9647..4d3c7d0c1e 100644
--- a/test/files/scalap/paramNames/result.test
+++ b/test/files/scalap/paramNames/result.test
@@ -1,4 +1,4 @@
-class ParamNames extends java.lang.Object with scala.ScalaObject {
+class ParamNames extends java.lang.Object {
def this() = { /* compiled code */ }
def foo(s : => scala.Seq[scala.Int], s2 : => scala.Seq[scala.Any]) : scala.Unit = { /* compiled code */ }
}
diff --git a/test/files/scalap/sequenceParam/result.test b/test/files/scalap/sequenceParam/result.test
index 4b9d7844ab..ed47c094fe 100644
--- a/test/files/scalap/sequenceParam/result.test
+++ b/test/files/scalap/sequenceParam/result.test
@@ -1,3 +1,3 @@
-class SequenceParam extends java.lang.Object with scala.ScalaObject {
+class SequenceParam extends java.lang.Object {
def this(s : scala.Predef.String, i : scala.Int*) = { /* compiled code */ }
}
diff --git a/test/files/scalap/simpleClass/result.test b/test/files/scalap/simpleClass/result.test
index d10b633bce..905046ce52 100644
--- a/test/files/scalap/simpleClass/result.test
+++ b/test/files/scalap/simpleClass/result.test
@@ -1,4 +1,4 @@
-class SimpleClass extends java.lang.Object with scala.ScalaObject {
+class SimpleClass extends java.lang.Object {
def this() = { /* compiled code */ }
def foo : scala.Int = { /* compiled code */ }
}
diff --git a/test/files/scalap/traitObject/result.test b/test/files/scalap/traitObject/result.test
index 0d7de1535d..d0521043c8 100644
--- a/test/files/scalap/traitObject/result.test
+++ b/test/files/scalap/traitObject/result.test
@@ -1,8 +1,8 @@
-trait TraitObject extends java.lang.Object with scala.ScalaObject {
+trait TraitObject extends java.lang.Object {
def $init$() : scala.Unit = { /* compiled code */ }
def foo : scala.Int = { /* compiled code */ }
}
-object TraitObject extends java.lang.Object with scala.ScalaObject {
+object TraitObject extends java.lang.Object {
def this() = { /* compiled code */ }
def bar : scala.Int = { /* compiled code */ }
}
diff --git a/test/files/scalap/typeAnnotations/result.test b/test/files/scalap/typeAnnotations/result.test
index b565d6185b..d28712f12b 100644
--- a/test/files/scalap/typeAnnotations/result.test
+++ b/test/files/scalap/typeAnnotations/result.test
@@ -1,8 +1,8 @@
-abstract class TypeAnnotations[@scala.specialized R] extends java.lang.Object with scala.ScalaObject {
+abstract class TypeAnnotations[@scala.specialized R] extends java.lang.Object {
def this() = { /* compiled code */ }
@scala.specialized
val x : scala.Int = { /* compiled code */ }
@scala.specialized
type T
def compose[@scala.specialized A](x : A, y : R) : A = { /* compiled code */ }
-} \ No newline at end of file
+}
diff --git a/test/files/scalap/valAndVar/result.test b/test/files/scalap/valAndVar/result.test
index 934ad0a086..90081acade 100644
--- a/test/files/scalap/valAndVar/result.test
+++ b/test/files/scalap/valAndVar/result.test
@@ -1,4 +1,4 @@
-class ValAndVar extends java.lang.Object with scala.ScalaObject {
+class ValAndVar extends java.lang.Object {
def this() = { /* compiled code */ }
val foo : java.lang.String = { /* compiled code */ }
var bar : scala.Int = { /* compiled code */ }
diff --git a/test/files/scalap/wildcardType/result.test b/test/files/scalap/wildcardType/result.test
index aa3d5d53bc..28147b6605 100644
--- a/test/files/scalap/wildcardType/result.test
+++ b/test/files/scalap/wildcardType/result.test
@@ -1,3 +1,3 @@
-class WildcardType extends java.lang.Object with scala.ScalaObject {
+class WildcardType extends java.lang.Object {
def this(f : scala.Function1[scala.Int, _]) = { /* compiled code */ }
}
diff --git a/test/files/speclib/instrumented.jar.desired.sha1 b/test/files/speclib/instrumented.jar.desired.sha1
index 68114c2393..7cdcf2f0b0 100644
--- a/test/files/speclib/instrumented.jar.desired.sha1
+++ b/test/files/speclib/instrumented.jar.desired.sha1
@@ -1 +1 @@
-2546f965f6718b000c4e6ef73559c11084177bd8 ?instrumented.jar
+5a9ee30043737b5d40511063b386dcbf3de0caae ?instrumented.jar
diff --git a/test/scaladoc/scala/html/HtmlFactoryTest.scala b/test/scaladoc/scala/html/HtmlFactoryTest.scala
index e2687dd510..d3b3b64359 100644
--- a/test/scaladoc/scala/html/HtmlFactoryTest.scala
+++ b/test/scaladoc/scala/html/HtmlFactoryTest.scala
@@ -290,27 +290,27 @@ object Test extends Properties("HtmlFactory") {
case _ => false
}
}
-
- property("Trac #484 - refinements and existentials") = {
- val files = createTemplates("Trac484.scala")
- val lines = """
- |type Bar = AnyRef { type Dingus <: T forSome { type T <: String } }
- |type Foo = AnyRef { ... /* 3 definitions in type refinement */ }
- |def g(x: T forSome { type T <: String }): String
- |def h(x: Float): AnyRef { def quux(x: Int,y: Int): Int }
- |def hh(x: Float): AnyRef { def quux(x: Int,y: Int): Int }
- |def j(x: Int): Bar
- |def k(): AnyRef { type Dingus <: T forSome { type T <: String } }
- """.stripMargin.trim.lines map (_.trim)
-
- files("RefinementAndExistentials.html") match {
- case node: scala.xml.Node => {
- val s = node.text.replaceAll("\\s+", " ")
- lines forall (s contains _)
- }
- case _ => false
- }
- }
+ //
+ // property("Trac #484 - refinements and existentials") = {
+ // val files = createTemplates("Trac484.scala")
+ // val lines = """
+ // |type Bar = AnyRef { type Dingus <: T forSome { type T <: String } }
+ // |type Foo = AnyRef { ... /* 3 definitions in type refinement */ }
+ // |def g(x: T forSome { type T <: String }): String
+ // |def h(x: Float): AnyRef { def quux(x: Int,y: Int): Int }
+ // |def hh(x: Float): AnyRef { def quux(x: Int,y: Int): Int }
+ // |def j(x: Int): Bar
+ // |def k(): AnyRef { type Dingus <: T forSome { type T <: String } }
+ // """.stripMargin.trim.lines map (_.trim)
+ //
+ // files("RefinementAndExistentials.html") match {
+ // case node: scala.xml.Node => {
+ // val s = node.text.replaceAll("\\s+", " ")
+ // lines forall (s contains _)
+ // }
+ // case _ => false
+ // }
+ // }
property("Trac #4289") = {
val files = createTemplates("Trac4289.scala")