From 57bccd7e757ee801ffec7bf1669c424edf33e81f Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Mon, 30 Jan 2012 13:00:39 -0800 Subject: Pushed new starr and updated desired shas. --- lib/scala-compiler.jar.desired.sha1 | 2 +- lib/scala-library-src.jar.desired.sha1 | 2 +- lib/scala-library.jar.desired.sha1 | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/scala-compiler.jar.desired.sha1 b/lib/scala-compiler.jar.desired.sha1 index 209189f444..2a4e218c86 100644 --- a/lib/scala-compiler.jar.desired.sha1 +++ b/lib/scala-compiler.jar.desired.sha1 @@ -1 +1 @@ -de9c0ef2ac2d13e2b56148ab2fe22de4ccdc34fc ?scala-compiler.jar +728a5b26cd8ccef172383c49bdc07c8236de5fd0 ?scala-compiler.jar diff --git a/lib/scala-library-src.jar.desired.sha1 b/lib/scala-library-src.jar.desired.sha1 index 81d1f677a5..739c62de6d 100644 --- a/lib/scala-library-src.jar.desired.sha1 +++ b/lib/scala-library-src.jar.desired.sha1 @@ -1 +1 @@ -d92a0fd350a661b4ba55f1aeea43a2ba5dec4629 ?scala-library-src.jar +0530fbb6e4539bf66a76523915b097451b057ab9 ?scala-library-src.jar diff --git a/lib/scala-library.jar.desired.sha1 b/lib/scala-library.jar.desired.sha1 index 30a8a5bbab..8cf9b47c77 100644 --- a/lib/scala-library.jar.desired.sha1 +++ b/lib/scala-library.jar.desired.sha1 @@ -1 +1 @@ -7fc8fd16bf0fe5cb25e9d43c614fe203fba397c5 ?scala-library.jar +ea548864dfc6682d9b747ddf4f9651b686d36dcc ?scala-library.jar -- cgit v1.2.3 From 37a0c8dd30d6443c47389922dbe1784f5dea0b00 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Fri, 3 Feb 2012 12:39:21 -0800 Subject: New shas for bootstrap libs. Free at last, free at last, of ScalaObject we're free at last. (With apologies to the Reverend, but the man had a way with words.) --- lib/scala-compiler.jar.desired.sha1 | 2 +- lib/scala-library-src.jar.desired.sha1 | 2 +- lib/scala-library.jar.desired.sha1 | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/scala-compiler.jar.desired.sha1 b/lib/scala-compiler.jar.desired.sha1 index 2a4e218c86..cc8631c6d4 100644 --- a/lib/scala-compiler.jar.desired.sha1 +++ b/lib/scala-compiler.jar.desired.sha1 @@ -1 +1 @@ -728a5b26cd8ccef172383c49bdc07c8236de5fd0 ?scala-compiler.jar +65ea33d0d4cc4aab5472f123524640fd1fab0a85 ?scala-compiler.jar diff --git a/lib/scala-library-src.jar.desired.sha1 b/lib/scala-library-src.jar.desired.sha1 index 739c62de6d..81d1f677a5 100644 --- a/lib/scala-library-src.jar.desired.sha1 +++ b/lib/scala-library-src.jar.desired.sha1 @@ -1 +1 @@ -0530fbb6e4539bf66a76523915b097451b057ab9 ?scala-library-src.jar +d92a0fd350a661b4ba55f1aeea43a2ba5dec4629 ?scala-library-src.jar diff --git a/lib/scala-library.jar.desired.sha1 b/lib/scala-library.jar.desired.sha1 index 8cf9b47c77..975649f4b4 100644 --- a/lib/scala-library.jar.desired.sha1 +++ b/lib/scala-library.jar.desired.sha1 @@ -1 +1 @@ -ea548864dfc6682d9b747ddf4f9651b686d36dcc ?scala-library.jar +ff3132990962fd0b779a5e8ceef163acdf0c3e29 ?scala-library.jar -- cgit v1.2.3 From 3a6b1124f18acf95923e228f6f41bdf3c23e0173 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sat, 4 Feb 2012 11:56:16 -0800 Subject: Guard List_apply from premature forcitude. Solved the annotation cycle puzzle. Was being burned again by the hack which preferentially treats List() as Nil to avoid List's extractor. This commit includes a new starr which fully bootstraps. Also at this point traits can extend Any and will not be given an AnyRef parent (until erasure.) This is the case for AnyVal and NotNull. --- lib/scala-compiler.jar.desired.sha1 | 2 +- lib/scala-library-src.jar.desired.sha1 | 2 +- lib/scala-library.jar.desired.sha1 | 2 +- src/compiler/scala/tools/nsc/typechecker/Typers.scala | 5 ++++- 4 files changed, 7 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/scala-compiler.jar.desired.sha1 b/lib/scala-compiler.jar.desired.sha1 index cc8631c6d4..22e714ad41 100644 --- a/lib/scala-compiler.jar.desired.sha1 +++ b/lib/scala-compiler.jar.desired.sha1 @@ -1 +1 @@ -65ea33d0d4cc4aab5472f123524640fd1fab0a85 ?scala-compiler.jar +83df84e719c0f966c67855a1b453aaff2c01e4f7 ?scala-compiler.jar diff --git a/lib/scala-library-src.jar.desired.sha1 b/lib/scala-library-src.jar.desired.sha1 index 81d1f677a5..cb39ee8604 100644 --- a/lib/scala-library-src.jar.desired.sha1 +++ b/lib/scala-library-src.jar.desired.sha1 @@ -1 +1 @@ -d92a0fd350a661b4ba55f1aeea43a2ba5dec4629 ?scala-library-src.jar +04d9d47973b10ec7353e2a8199b1bd5c62fb540a ?scala-library-src.jar diff --git a/lib/scala-library.jar.desired.sha1 b/lib/scala-library.jar.desired.sha1 index 975649f4b4..009d5f82ea 100644 --- a/lib/scala-library.jar.desired.sha1 +++ b/lib/scala-library.jar.desired.sha1 @@ -1 +1 @@ -ff3132990962fd0b779a5e8ceef163acdf0c3e29 ?scala-library.jar +c8e01ec6416bd883e996cf8c6916bf0173c31486 ?scala-library.jar diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index fdeab7b565..1d84f7fdaf 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -2525,8 +2525,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)) -- cgit v1.2.3 From c6a783ac089d8cf5a60a98946af5e80aff5a7d32 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sat, 4 Feb 2012 14:36:14 -0800 Subject: Making AnyVal into a class instead of a trait. -- traits can extend Any, AnyRef, or AnyVal -- classes can extend AnyRef or AnyVal but not Any. This breaks reflection for the moment as it smuggles AnyVal so far downstream that it's reflecting its way into bytecode (or something) but the following test case goes five for six as anticipated. 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 Eliminated various hijinx from definitions. --- lib/scala-compiler.jar.desired.sha1 | 2 +- lib/scala-library-src.jar.desired.sha1 | 2 +- lib/scala-library.jar.desired.sha1 | 2 +- .../scala/reflect/internal/Definitions.scala | 29 +++++----------------- .../scala/tools/nsc/ast/parser/Parsers.scala | 11 ++++---- .../scala/tools/nsc/transform/AddInterfaces.scala | 12 ++++++--- .../scala/tools/nsc/transform/Constructors.scala | 13 ++++++---- .../scala/tools/nsc/typechecker/Typers.scala | 2 ++ src/library/scala/AnyVal.scala | 2 +- test/files/neg/anyval-anyref-parent.check | 4 +++ test/files/neg/anyval-anyref-parent.scala | 7 ++++++ 11 files changed, 45 insertions(+), 41 deletions(-) create mode 100644 test/files/neg/anyval-anyref-parent.check create mode 100644 test/files/neg/anyval-anyref-parent.scala (limited to 'lib') diff --git a/lib/scala-compiler.jar.desired.sha1 b/lib/scala-compiler.jar.desired.sha1 index 22e714ad41..79f6de5e27 100644 --- a/lib/scala-compiler.jar.desired.sha1 +++ b/lib/scala-compiler.jar.desired.sha1 @@ -1 +1 @@ -83df84e719c0f966c67855a1b453aaff2c01e4f7 ?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 cb39ee8604..cfb865f1e8 100644 --- a/lib/scala-library-src.jar.desired.sha1 +++ b/lib/scala-library-src.jar.desired.sha1 @@ -1 +1 @@ -04d9d47973b10ec7353e2a8199b1bd5c62fb540a ?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 009d5f82ea..28a2c586a0 100644 --- a/lib/scala-library.jar.desired.sha1 +++ b/lib/scala-library.jar.desired.sha1 @@ -1 +1 @@ -c8e01ec6416bd883e996cf8c6916bf0173c31486 ?scala-library.jar +3516dc2e17bf72b1e4bc665e59f6b7ec51cba48d ?scala-library.jar diff --git a/src/compiler/scala/reflect/internal/Definitions.scala b/src/compiler/scala/reflect/internal/Definitions.scala index 82d7f947e6..7bd0c0f919 100644 --- a/src/compiler/scala/reflect/internal/Definitions.scala +++ b/src/compiler/scala/reflect/internal/Definitions.scala @@ -230,17 +230,12 @@ trait Definitions extends reflect.api.StandardDefinitions { lazy val AnyCompanionClass = getRequiredClass("scala.AnyCompanion") initFlags (SEALED | ABSTRACT | TRAIT) lazy val AnyValCompanionClass = getRequiredClass("scala.AnyValCompanion") initFlags (SEALED | ABSTRACT | TRAIT) - private var oldValueScheme = true - - lazy val AnyValClass = ScalaPackageClass.info member tpnme.AnyVal -// lazy val AnyValClass = ScalaPackageClass.info member tpnme.AnyVal orElse { -// // println("new anyval") -// oldValueScheme = true -// val anyval = enterNewClass(ScalaPackageClass, tpnme.AnyVal, anyparam, 0L) -// val av_constr = anyval.newClassConstructor(NoPosition) -// anyval.info.decls enter av_constr -// anyval -// } + lazy val AnyValClass = ScalaPackageClass.info member tpnme.AnyVal orElse { + val anyval = enterNewClass(ScalaPackageClass, tpnme.AnyVal, List(AnyClass.tpe, NotNullClass.tpe), 0L) + val av_constr = anyval.newClassConstructor(NoPosition) + anyval.info.decls enter av_constr + anyval + } lazy val AnyVal_getClass = enterNewMethod(AnyValClass, nme.getClass_, Nil, getClassReturnType(AnyValClass.tpe)) // bottom types @@ -1077,22 +1072,10 @@ trait Definitions extends reflect.api.StandardDefinitions { Object_synchronized, Object_isInstanceOf, Object_asInstanceOf, - //AnyVal_getClass, String_+, ComparableClass ) - /* Removing the anyref parent they acquire from having a source file. - */ - if (oldValueScheme) { - setParents(AnyValClass, List(NotNullClass.tpe, AnyClass.tpe)) - } else { - AnyVal_getClass // force it! - } - ScalaValueClasses foreach { sym => - setParents(sym, anyvalparam) - } - isInitialized = true } //init diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala index 8e5a0139a5..f7401c813a 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala @@ -2753,7 +2753,11 @@ self => val tstart0 = if (body.isEmpty && in.lastOffset < tstart) in.lastOffset else tstart atPos(tstart0) { - if (isPrimitiveType(name)) + if (inScalaPackage && name == tpnme.AnyVal) { + 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 @@ -2761,10 +2765,7 @@ self => } else { val parents = ( - if (parents0.isEmpty) { - if (inScalaPackage && name == tpnme.AnyVal) List(scalaAnyConstr) - else List(scalaAnyRefConstr) - } + if (parents0.isEmpty) List(scalaAnyRefConstr) /*if (!isInterface(mods, body) && !isScalaArray(name)) parents0 /* :+ scalaScalaObjectConstr*/ else*/ diff --git a/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala b/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala index 89dfbfd317..8fe82258e2 100644 --- a/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala +++ b/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala @@ -301,12 +301,16 @@ abstract class AddInterfaces extends InfoTransform { 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) => // AnyVal constructor + Literal(Constant()) + } } } diff --git a/src/compiler/scala/tools/nsc/transform/Constructors.scala b/src/compiler/scala/tools/nsc/transform/Constructors.scala index 256f13b3fb..a672059211 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 => + // assert(false, "no constructor in template: impl = " + impl) + // AnyVal constructor + return impl + } } import constrInfo._ diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 1d84f7fdaf..ba3172dd06 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -1610,6 +1610,8 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser { * @param rhs ... */ def computeParamAliases(clazz: Symbol, vparamss: List[List[ValDef]], rhs: Tree) { + if (clazz eq AnyValClass) + return debuglog("computing param aliases for "+clazz+":"+clazz.primaryConstructor.tpe+":"+rhs)//debug def decompose(call: Tree): (Tree, List[Tree]) = call match { case Apply(fn, args) => diff --git a/src/library/scala/AnyVal.scala b/src/library/scala/AnyVal.scala index daad6f6f5e..393f0899f4 100644 --- a/src/library/scala/AnyVal.scala +++ b/src/library/scala/AnyVal.scala @@ -25,7 +25,7 @@ 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]]. */ -trait AnyVal extends Any with NotNull { +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/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 -- cgit v1.2.3 From 6ba9411c7c6abdbd907ca93208ac58b474b201d0 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sat, 4 Feb 2012 21:06:42 -0800 Subject: Restored msil. --- build.xml | 12 +- lib/msil.jar.desired.sha1 | 2 +- .../scala/tools/nsc/backend/MSILPlatform.scala | 11 +- .../scala/tools/nsc/backend/icode/GenICode.scala | 322 ++++++++++----------- .../scala/tools/nsc/backend/icode/Opcodes.scala | 114 ++++---- .../scala/tools/nsc/backend/icode/TypeKinds.scala | 13 +- .../scala/tools/nsc/backend/msil/GenMSIL.scala | 25 +- src/compiler/scala/tools/nsc/io/MsilFile.scala | 5 +- .../scala/tools/nsc/symtab/SymbolLoaders.scala | 32 +- .../scala/tools/nsc/symtab/clr/CLRTypes.scala | 15 +- .../scala/tools/nsc/symtab/clr/TypeParser.scala | 165 ++++++----- .../scala/tools/nsc/util/MsilClassPath.scala | 21 +- 12 files changed, 366 insertions(+), 371 deletions(-) (limited to 'lib') diff --git a/build.xml b/build.xml index f50d51e80a..57d2eed1c0 100644 --- a/build.xml +++ b/build.xml @@ -281,7 +281,7 @@ INITIALISATION - + @@ -490,7 +490,7 @@ PACKED LOCKER BUILD (PALO) - + @@ -640,12 +640,12 @@ QUICK BUILD (QUICK) - + - + @@ -968,7 +968,7 @@ PACKED QUICK BUILD (PACK) - + @@ -1901,7 +1901,7 @@ STABLE REFERENCE (STARR) - + 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/src/compiler/scala/tools/nsc/backend/MSILPlatform.scala b/src/compiler/scala/tools/nsc/backend/MSILPlatform.scala index d5a02f9242..65b1fbc229 100644 --- a/src/compiler/scala/tools/nsc/backend/MSILPlatform.scala +++ b/src/compiler/scala/tools/nsc/backend/MSILPlatform.scala @@ -6,12 +6,12 @@ package scala.tools.nsc package backend -// import ch.epfl.lamp.compiler.{ msil => msillib } -// import util.{ ClassPath, MsilClassPath } -// import msil.GenMSIL -// import io.{ AbstractFile, MsilFile } +import ch.epfl.lamp.compiler.{ msil => msillib } +import util.{ ClassPath, MsilClassPath } +import msil.GenMSIL +import io.{ AbstractFile, MsilFile } -trait MSILPlatform /*extends Platform { +trait MSILPlatform extends Platform { import global._ import definitions.{ ComparatorClass, BoxedNumberClass, getMember } @@ -63,4 +63,3 @@ trait MSILPlatform /*extends Platform { def needCompile(bin: MsilFile, src: AbstractFile) = false // always use compiled file on .net } -*/ \ No newline at end of file diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala index acb20b4627..3baff7da9e 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala @@ -160,8 +160,8 @@ abstract class GenICode extends SubComponent { case Assign(lhs @ Select(_, _), rhs) => val isStatic = lhs.symbol.isStaticMember var ctx1 = if (isStatic) ctx - // else if (forMSIL && msil_IsValuetypeInstField(lhs.symbol)) - // msil_genLoadQualifierAddress(lhs, ctx) + else if (forMSIL && msil_IsValuetypeInstField(lhs.symbol)) + msil_genLoadQualifierAddress(lhs, ctx) else genLoadQualifier(lhs, ctx) ctx1 = genLoad(rhs, ctx1, toTypeKind(lhs.symbol.info)) @@ -460,132 +460,132 @@ abstract class GenICode extends SubComponent { fun.symbol.simpleName + ") " + " at: " + (tree.pos) ) } - // - // /** - // * forMSIL - // */ - // private def msil_IsValuetypeInstMethod(msym: Symbol) = ( - // loaders.clrTypes.methods get msym exists (mMSIL => - // mMSIL.IsInstance && mMSIL.DeclaringType.IsValueType - // ) - // ) - // private def msil_IsValuetypeInstField(fsym: Symbol) = ( - // loaders.clrTypes.fields get fsym exists (fMSIL => - // !fMSIL.IsStatic && fMSIL.DeclaringType.IsValueType - // ) - // ) - // - // /** - // * forMSIL: Adds a local var, the emitted code requires one more slot on the stack as on entry - // */ - // private def msil_genLoadZeroOfNonEnumValuetype(ctx: Context, kind: TypeKind, pos: Position, leaveAddressOnStackInstead: Boolean) { - // val REFERENCE(clssym) = kind - // assert(loaders.clrTypes.isNonEnumValuetype(clssym), clssym) - // val local = ctx.makeLocal(pos, clssym.tpe, "tmp") - // ctx.method.addLocal(local) - // ctx.bb.emit(CIL_LOAD_LOCAL_ADDRESS(local), pos) - // ctx.bb.emit(CIL_INITOBJ(kind), pos) - // val instr = if (leaveAddressOnStackInstead) - // CIL_LOAD_LOCAL_ADDRESS(local) - // else - // LOAD_LOCAL(local) - // ctx.bb.emit(instr, pos) - // } - // - // /** - // * forMSIL - // */ - // private def msil_genLoadAddressOf(tree: Tree, ctx: Context, expectedType: TypeKind, butRawValueIsAlsoGoodEnough: Boolean): Context = { - // var generatedType = expectedType - // var addressTaken = false - // debuglog("at line: " + (if (tree.pos.isDefined) tree.pos.line else tree.pos)) - // - // var resCtx: Context = tree match { - // - // // emits CIL_LOAD_FIELD_ADDRESS - // case Select(qualifier, selector) if (!tree.symbol.isModule) => - // addressTaken = true - // val sym = tree.symbol - // generatedType = toTypeKind(sym.info) - // - // if (sym.isStaticMember) { - // ctx.bb.emit(CIL_LOAD_FIELD_ADDRESS(sym, true), tree.pos) - // ctx - // } else { - // val ctx1 = genLoadQualifier(tree, ctx) - // ctx1.bb.emit(CIL_LOAD_FIELD_ADDRESS(sym, false), tree.pos) - // ctx1 - // } - // - // // emits CIL_LOAD_LOCAL_ADDRESS - // case Ident(name) if (!tree.symbol.isPackage && !tree.symbol.isModule)=> - // addressTaken = true - // val sym = tree.symbol - // try { - // val Some(l) = ctx.method.lookupLocal(sym) - // ctx.bb.emit(CIL_LOAD_LOCAL_ADDRESS(l), tree.pos) - // generatedType = l.kind // actually, should be "V&" but the callsite is aware of this - // } catch { - // case ex: MatchError => - // abort("symbol " + sym + " does not exist in " + ctx.method) - // } - // ctx - // - // // emits CIL_LOAD_ARRAY_ITEM_ADDRESS - // case Apply(fun, args) => - // if (isPrimitive(fun.symbol)) { - // - // val sym = tree.symbol - // val Apply(fun @ Select(receiver, _), args) = tree - // val code = scalaPrimitives.getPrimitive(sym, receiver.tpe) - // - // if (isArrayOp(code)) { - // val arrayObj = receiver - // val k = toTypeKind(arrayObj.tpe) - // val ARRAY(elementType) = k - // if (scalaPrimitives.isArrayGet(code)) { - // var ctx1 = genLoad(arrayObj, ctx, k) - // // load argument on stack - // debugassert(args.length == 1, "Too many arguments for array get operation: " + tree) - // ctx1 = genLoad(args.head, ctx1, INT) - // generatedType = elementType // actually "managed pointer to element type" but the callsite is aware of this - // ctx1.bb.emit(CIL_LOAD_ARRAY_ITEM_ADDRESS(elementType), tree.pos) - // addressTaken = true - // ctx1 - // } else null - // } else null - // } else null - // - // case This(qual) => - // /* TODO: this case handler is a placeholder for the time when Level 2 support for valuetypes is in place, - // in particular when invoking other methods on this where this is a valuetype value (boxed or not). - // As receiver, a managed pointer is expected, and a plain ldarg.0 achieves just that. */ - // addressTaken = true - // genLoad(tree, ctx, expectedType) - // - // case _ => - // null /* A method returning ByRef won't pass peverify, so I guess this case handler is dead code. - // Even if it's not, the code below to handler !addressTaken below. */ - // } - // - // if (!addressTaken) { - // resCtx = genLoad(tree, ctx, expectedType) - // if (!butRawValueIsAlsoGoodEnough) { - // // raw value on stack (must be an intermediate result, e.g. returned by method call), take address - // addressTaken = true - // val boxType = expectedType // toTypeKind(expectedType /* TODO FIXME */) - // resCtx.bb.emit(BOX(boxType), tree.pos) - // resCtx.bb.emit(CIL_UNBOX(boxType), tree.pos) - // } - // } - // - // // emit conversion - // if (generatedType != expectedType) - // abort("Unexpected tree in msil_genLoadAddressOf: " + tree + " at: " + tree.pos) - // - // resCtx - // } - // + + /** + * forMSIL + */ + private def msil_IsValuetypeInstMethod(msym: Symbol) = ( + loaders.clrTypes.methods get msym exists (mMSIL => + mMSIL.IsInstance && mMSIL.DeclaringType.IsValueType + ) + ) + private def msil_IsValuetypeInstField(fsym: Symbol) = ( + loaders.clrTypes.fields get fsym exists (fMSIL => + !fMSIL.IsStatic && fMSIL.DeclaringType.IsValueType + ) + ) + + /** + * forMSIL: Adds a local var, the emitted code requires one more slot on the stack as on entry + */ + private def msil_genLoadZeroOfNonEnumValuetype(ctx: Context, kind: TypeKind, pos: Position, leaveAddressOnStackInstead: Boolean) { + val REFERENCE(clssym) = kind + assert(loaders.clrTypes.isNonEnumValuetype(clssym), clssym) + val local = ctx.makeLocal(pos, clssym.tpe, "tmp") + ctx.method.addLocal(local) + ctx.bb.emit(CIL_LOAD_LOCAL_ADDRESS(local), pos) + ctx.bb.emit(CIL_INITOBJ(kind), pos) + val instr = if (leaveAddressOnStackInstead) + CIL_LOAD_LOCAL_ADDRESS(local) + else + LOAD_LOCAL(local) + ctx.bb.emit(instr, pos) + } + + /** + * forMSIL + */ + private def msil_genLoadAddressOf(tree: Tree, ctx: Context, expectedType: TypeKind, butRawValueIsAlsoGoodEnough: Boolean): Context = { + var generatedType = expectedType + var addressTaken = false + debuglog("at line: " + (if (tree.pos.isDefined) tree.pos.line else tree.pos)) + + var resCtx: Context = tree match { + + // emits CIL_LOAD_FIELD_ADDRESS + case Select(qualifier, selector) if (!tree.symbol.isModule) => + addressTaken = true + val sym = tree.symbol + generatedType = toTypeKind(sym.info) + + if (sym.isStaticMember) { + ctx.bb.emit(CIL_LOAD_FIELD_ADDRESS(sym, true), tree.pos) + ctx + } else { + val ctx1 = genLoadQualifier(tree, ctx) + ctx1.bb.emit(CIL_LOAD_FIELD_ADDRESS(sym, false), tree.pos) + ctx1 + } + + // emits CIL_LOAD_LOCAL_ADDRESS + case Ident(name) if (!tree.symbol.isPackage && !tree.symbol.isModule)=> + addressTaken = true + val sym = tree.symbol + try { + val Some(l) = ctx.method.lookupLocal(sym) + ctx.bb.emit(CIL_LOAD_LOCAL_ADDRESS(l), tree.pos) + generatedType = l.kind // actually, should be "V&" but the callsite is aware of this + } catch { + case ex: MatchError => + abort("symbol " + sym + " does not exist in " + ctx.method) + } + ctx + + // emits CIL_LOAD_ARRAY_ITEM_ADDRESS + case Apply(fun, args) => + if (isPrimitive(fun.symbol)) { + + val sym = tree.symbol + val Apply(fun @ Select(receiver, _), args) = tree + val code = scalaPrimitives.getPrimitive(sym, receiver.tpe) + + if (isArrayOp(code)) { + val arrayObj = receiver + val k = toTypeKind(arrayObj.tpe) + val ARRAY(elementType) = k + if (scalaPrimitives.isArrayGet(code)) { + var ctx1 = genLoad(arrayObj, ctx, k) + // load argument on stack + debugassert(args.length == 1, "Too many arguments for array get operation: " + tree) + ctx1 = genLoad(args.head, ctx1, INT) + generatedType = elementType // actually "managed pointer to element type" but the callsite is aware of this + ctx1.bb.emit(CIL_LOAD_ARRAY_ITEM_ADDRESS(elementType), tree.pos) + addressTaken = true + ctx1 + } else null + } else null + } else null + + case This(qual) => + /* TODO: this case handler is a placeholder for the time when Level 2 support for valuetypes is in place, + in particular when invoking other methods on this where this is a valuetype value (boxed or not). + As receiver, a managed pointer is expected, and a plain ldarg.0 achieves just that. */ + addressTaken = true + genLoad(tree, ctx, expectedType) + + case _ => + null /* A method returning ByRef won't pass peverify, so I guess this case handler is dead code. + Even if it's not, the code below to handler !addressTaken below. */ + } + + if (!addressTaken) { + resCtx = genLoad(tree, ctx, expectedType) + if (!butRawValueIsAlsoGoodEnough) { + // raw value on stack (must be an intermediate result, e.g. returned by method call), take address + addressTaken = true + val boxType = expectedType // toTypeKind(expectedType /* TODO FIXME */) + resCtx.bb.emit(BOX(boxType), tree.pos) + resCtx.bb.emit(CIL_UNBOX(boxType), tree.pos) + } + } + + // emit conversion + if (generatedType != expectedType) + abort("Unexpected tree in msil_genLoadAddressOf: " + tree + " at: " + tree.pos) + + resCtx + } + /** * Generate code for trees that produce values on the stack @@ -793,19 +793,19 @@ abstract class GenICode extends SubComponent { debugassert(ctor.owner == cls, "Symbol " + ctor.owner.fullName + " is different than " + tpt) - // val ctx2 = if (forMSIL && loaders.clrTypes.isNonEnumValuetype(cls)) { - // /* parameterful constructors are the only possible custom constructors, - // a default constructor can't be defined for valuetypes, CLR dixit */ - // val isDefaultConstructor = args.isEmpty - // if (isDefaultConstructor) { - // msil_genLoadZeroOfNonEnumValuetype(ctx, rt, tree.pos, leaveAddressOnStackInstead = false) - // ctx - // } else { - // val ctx1 = genLoadArguments(args, ctor.info.paramTypes, ctx) - // ctx1.bb.emit(CIL_NEWOBJ(ctor), tree.pos) - // ctx1 - // } - // } else { + val ctx2 = if (forMSIL && loaders.clrTypes.isNonEnumValuetype(cls)) { + /* parameterful constructors are the only possible custom constructors, + a default constructor can't be defined for valuetypes, CLR dixit */ + val isDefaultConstructor = args.isEmpty + if (isDefaultConstructor) { + msil_genLoadZeroOfNonEnumValuetype(ctx, rt, tree.pos, leaveAddressOnStackInstead = false) + ctx + } else { + val ctx1 = genLoadArguments(args, ctor.info.paramTypes, ctx) + ctx1.bb.emit(CIL_NEWOBJ(ctor), tree.pos) + ctx1 + } + } else { val nw = NEW(rt) ctx.bb.emit(nw, tree.pos) ctx.bb.emit(DUP(generatedType)) @@ -815,8 +815,8 @@ abstract class GenICode extends SubComponent { nw.init = init ctx1.bb.emit(init, tree.pos) ctx1 - // } - // ctx2 + } + ctx2 case _ => abort("Cannot instantiate " + tpt + "of kind: " + generatedType) @@ -845,12 +845,12 @@ abstract class GenICode extends SubComponent { generatedType = boxType ctx1.bb.emit(UNBOX(boxType), expr.pos) ctx1 - // - // case Apply(fun @ _, List(expr)) if (forMSIL && loaders.clrTypes.isAddressOf(fun.symbol)) => - // debuglog("ADDRESSOF : " + fun.symbol.fullName); - // val ctx1 = msil_genLoadAddressOf(expr, ctx, toTypeKind(expr.tpe), butRawValueIsAlsoGoodEnough = false) - // generatedType = toTypeKind(fun.symbol.tpe.resultType) - // ctx1 + + case Apply(fun @ _, List(expr)) if (forMSIL && loaders.clrTypes.isAddressOf(fun.symbol)) => + debuglog("ADDRESSOF : " + fun.symbol.fullName); + val ctx1 = msil_genLoadAddressOf(expr, ctx, toTypeKind(expr.tpe), butRawValueIsAlsoGoodEnough = false) + generatedType = toTypeKind(fun.symbol.tpe.resultType) + ctx1 case app @ Apply(fun, args) => val sym = fun.symbol @@ -887,9 +887,9 @@ abstract class GenICode extends SubComponent { var ctx1 = if (invokeStyle.hasInstance) { - // if (forMSIL && !(invokeStyle.isInstanceOf[SuperCall]) && msil_IsValuetypeInstMethod(sym)) - // msil_genLoadQualifierAddress(fun, ctx) - // else + if (forMSIL && !(invokeStyle.isInstanceOf[SuperCall]) && msil_IsValuetypeInstMethod(sym)) + msil_genLoadQualifierAddress(fun, ctx) + else genLoadQualifier(fun, ctx) } else ctx @@ -1150,15 +1150,15 @@ abstract class GenICode extends SubComponent { case _ => abort("Unknown qualifier " + tree) } - // - // /** forMSIL */ - // private def msil_genLoadQualifierAddress(tree: Tree, ctx: Context): Context = - // tree match { - // case Select(qualifier, _) => - // msil_genLoadAddressOf(qualifier, ctx, toTypeKind(qualifier.tpe), butRawValueIsAlsoGoodEnough = false) - // case _ => - // abort("Unknown qualifier " + tree) - // } + + /** forMSIL */ + private def msil_genLoadQualifierAddress(tree: Tree, ctx: Context): Context = + tree match { + case Select(qualifier, _) => + msil_genLoadAddressOf(qualifier, ctx, toTypeKind(qualifier.tpe), butRawValueIsAlsoGoodEnough = false) + case _ => + abort("Unknown qualifier " + tree) + } /** * Generate code that loads args into label parameters. diff --git a/src/compiler/scala/tools/nsc/backend/icode/Opcodes.scala b/src/compiler/scala/tools/nsc/backend/icode/Opcodes.scala index bf8580b903..2bcfb9d4a9 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/Opcodes.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/Opcodes.scala @@ -636,63 +636,63 @@ trait Opcodes { self: ICodes => // CLR backend -// -// case class CIL_LOAD_LOCAL_ADDRESS(local: Local) extends Instruction { -// /** Returns a string representation of this instruction */ -// override def toString(): String = "CIL_LOAD_LOCAL_ADDRESS "+local //+isArgument?" (argument)":""; -// -// override def consumed = 0 -// override def produced = 1 -// -// override def producedTypes = List(msil_mgdptr(local.kind)) -// } -// -// case class CIL_LOAD_FIELD_ADDRESS(field: Symbol, isStatic: Boolean) extends Instruction { -// /** Returns a string representation of this instruction */ -// override def toString(): String = -// "CIL_LOAD_FIELD_ADDRESS " + (if (isStatic) field.fullName else field.toString) -// -// override def consumed = if (isStatic) 0 else 1 -// override def produced = 1 -// -// override def consumedTypes = if (isStatic) Nil else List(REFERENCE(field.owner)); -// override def producedTypes = List(msil_mgdptr(REFERENCE(field.owner))); -// } -// -// case class CIL_LOAD_ARRAY_ITEM_ADDRESS(kind: TypeKind) extends Instruction { -// /** Returns a string representation of this instruction */ -// override def toString(): String = "CIL_LOAD_ARRAY_ITEM_ADDRESS (" + kind + ")" -// -// override def consumed = 2 -// override def produced = 1 -// -// override def consumedTypes = List(ARRAY(kind), INT) -// override def producedTypes = List(msil_mgdptr(kind)) -// } -// -// case class CIL_UNBOX(valueType: TypeKind) extends Instruction { -// override def toString(): String = "CIL_UNBOX " + valueType -// override def consumed = 1 -// override def consumedTypes = ObjectReference :: Nil // actually consumes a 'boxed valueType' -// override def produced = 1 -// override def producedTypes = List(msil_mgdptr(valueType)) -// } -// -// case class CIL_INITOBJ(valueType: TypeKind) extends Instruction { -// override def toString(): String = "CIL_INITOBJ " + valueType -// override def consumed = 1 -// override def consumedTypes = ObjectReference :: Nil // actually consumes a managed pointer -// override def produced = 0 -// } -// -// case class CIL_NEWOBJ(method: Symbol) extends Instruction { -// override def toString(): String = "CIL_NEWOBJ " + hostClass.fullName + method.fullName -// var hostClass: Symbol = method.owner; -// override def consumed = method.tpe.paramTypes.length -// override def consumedTypes = method.tpe.paramTypes map toTypeKind -// override def produced = 1 -// override def producedTypes = List(toTypeKind(method.tpe.resultType)) -// } + + case class CIL_LOAD_LOCAL_ADDRESS(local: Local) extends Instruction { + /** Returns a string representation of this instruction */ + override def toString(): String = "CIL_LOAD_LOCAL_ADDRESS "+local //+isArgument?" (argument)":""; + + override def consumed = 0 + override def produced = 1 + + override def producedTypes = List(msil_mgdptr(local.kind)) + } + + case class CIL_LOAD_FIELD_ADDRESS(field: Symbol, isStatic: Boolean) extends Instruction { + /** Returns a string representation of this instruction */ + override def toString(): String = + "CIL_LOAD_FIELD_ADDRESS " + (if (isStatic) field.fullName else field.toString) + + override def consumed = if (isStatic) 0 else 1 + override def produced = 1 + + override def consumedTypes = if (isStatic) Nil else List(REFERENCE(field.owner)); + override def producedTypes = List(msil_mgdptr(REFERENCE(field.owner))); +} + + case class CIL_LOAD_ARRAY_ITEM_ADDRESS(kind: TypeKind) extends Instruction { + /** Returns a string representation of this instruction */ + override def toString(): String = "CIL_LOAD_ARRAY_ITEM_ADDRESS (" + kind + ")" + + override def consumed = 2 + override def produced = 1 + + override def consumedTypes = List(ARRAY(kind), INT) + override def producedTypes = List(msil_mgdptr(kind)) + } + + case class CIL_UNBOX(valueType: TypeKind) extends Instruction { + override def toString(): String = "CIL_UNBOX " + valueType + override def consumed = 1 + override def consumedTypes = ObjectReference :: Nil // actually consumes a 'boxed valueType' + override def produced = 1 + override def producedTypes = List(msil_mgdptr(valueType)) + } + + case class CIL_INITOBJ(valueType: TypeKind) extends Instruction { + override def toString(): String = "CIL_INITOBJ " + valueType + override def consumed = 1 + override def consumedTypes = ObjectReference :: Nil // actually consumes a managed pointer + override def produced = 0 + } + + case class CIL_NEWOBJ(method: Symbol) extends Instruction { + override def toString(): String = "CIL_NEWOBJ " + hostClass.fullName + method.fullName + var hostClass: Symbol = method.owner; + override def consumed = method.tpe.paramTypes.length + override def consumedTypes = method.tpe.paramTypes map toTypeKind + override def produced = 1 + override def producedTypes = List(toTypeKind(method.tpe.resultType)) + } } } diff --git a/src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala b/src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala index 998ac90778..a485272ca6 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala @@ -423,10 +423,11 @@ trait TypeKinds { self: ICodes => primitiveTypeMap.getOrElse(sym, newReference(sym)) private def primitiveOrClassType(sym: Symbol, targs: List[Type]) = primitiveTypeMap.getOrElse(sym, arrayOrClassType(sym, targs)) - // - // def msil_mgdptr(tk: TypeKind): TypeKind = (tk: @unchecked) match { - // case REFERENCE(cls) => REFERENCE(loaders.clrTypes.mdgptrcls4clssym(cls)) - // // TODO have ready class-symbols for the by-ref versions of built-in valuetypes - // case _ => abort("cannot obtain a managed pointer for " + tk) - // } + + def msil_mgdptr(tk: TypeKind): TypeKind = (tk: @unchecked) match { + case REFERENCE(cls) => REFERENCE(loaders.clrTypes.mdgptrcls4clssym(cls)) + // TODO have ready class-symbols for the by-ref versions of built-in valuetypes + case _ => abort("cannot obtain a managed pointer for " + tk) + } + } diff --git a/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala b/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala index aba537f3bd..d2e54ff3f1 100644 --- a/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala +++ b/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala @@ -7,16 +7,16 @@ package scala.tools.nsc package backend.msil -// import java.io.{File, IOException} -// import java.nio.{ByteBuffer, ByteOrder} -// import scala.collection.{ mutable, immutable } -// import scala.tools.nsc.symtab._ -// -// import ch.epfl.lamp.compiler.msil.{Type => MsilType, _} -// import ch.epfl.lamp.compiler.msil.emit._ -// import ch.epfl.lamp.compiler.msil.util.PECustomMod - -abstract class GenMSIL /*extends SubComponent { +import java.io.{File, IOException} +import java.nio.{ByteBuffer, ByteOrder} +import scala.collection.{ mutable, immutable } +import scala.tools.nsc.symtab._ + +import ch.epfl.lamp.compiler.msil.{Type => MsilType, _} +import ch.epfl.lamp.compiler.msil.emit._ +import ch.epfl.lamp.compiler.msil.util.PECustomMod + +abstract class GenMSIL extends SubComponent { import global._ import loaders.clrTypes import clrTypes.{types, constructors, methods, fields} @@ -1815,7 +1815,7 @@ abstract class GenMSIL /*extends SubComponent { types.get(sym).getOrElse { classes.get(sym) match { case Some(iclass) => - msilTypeBuilderFromSym(sym) + msilTypeBuilderFromSym(sym) case None => getType(sym) } @@ -1844,7 +1844,7 @@ abstract class GenMSIL /*extends SubComponent { debuglog("super type: " + parents(0).typeSymbol + ", msil type: " + superType) val interfaces: Array[MsilType] = - parents.tail.map(p => msilTypeFromSym(p.typeSymbol)).toArray + parents.tail.map(p => msilTypeFromSym(p.typeSymbol)).toArray if (parents.length > 1) { if (settings.debug.value) { log("interfaces:") @@ -2355,4 +2355,3 @@ abstract class GenMSIL /*extends SubComponent { } // class BytecodeGenerator } // class GenMSIL -*/ \ No newline at end of file diff --git a/src/compiler/scala/tools/nsc/io/MsilFile.scala b/src/compiler/scala/tools/nsc/io/MsilFile.scala index aeaa1b759b..d970d0e9c9 100644 --- a/src/compiler/scala/tools/nsc/io/MsilFile.scala +++ b/src/compiler/scala/tools/nsc/io/MsilFile.scala @@ -6,14 +6,13 @@ package scala.tools.nsc package io -// import ch.epfl.lamp.compiler.msil.{ Type => MsilType, _ } +import ch.epfl.lamp.compiler.msil.{ Type => MsilType, _ } /** This class wraps an MsilType. It exists only so * ClassPath can treat all of JVM/MSIL/bin/src files * uniformly, as AbstractFiles. */ -class MsilFile /* (val msilType: MsilType) extends VirtualFile(msilType.FullName, msilType.Namespace) { +class MsilFile(val msilType: MsilType) extends VirtualFile(msilType.FullName, msilType.Namespace) { } object NoMsilFile extends MsilFile(null) { } -*/ \ No newline at end of file diff --git a/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala b/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala index 2241bb224e..942ec1fa86 100644 --- a/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala +++ b/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala @@ -13,7 +13,7 @@ import classfile.ClassfileParser import reflect.internal.Flags._ import reflect.internal.MissingRequirementError import util.Statistics._ -import scala.tools.nsc.io.{ AbstractFile } //, MsilFile } +import scala.tools.nsc.io.{ AbstractFile, MsilFile } /** This class ... * @@ -236,16 +236,16 @@ abstract class SymbolLoaders { } override def sourcefile: Option[AbstractFile] = classfileParser.srcfile } - // - // class MsilFileLoader(msilFile: MsilFile) extends SymbolLoader { - // private def typ = msilFile.msilType - // private object typeParser extends clr.TypeParser { - // val global: SymbolLoaders.this.global.type = SymbolLoaders.this.global - // } - // - // protected def description = "MsilFile "+ typ.FullName + ", assembly "+ typ.Assembly.FullName - // protected def doComplete(root: Symbol) { typeParser.parse(typ, root) } - // } + + class MsilFileLoader(msilFile: MsilFile) extends SymbolLoader { + private def typ = msilFile.msilType + private object typeParser extends clr.TypeParser { + val global: SymbolLoaders.this.global.type = SymbolLoaders.this.global + } + + protected def description = "MsilFile "+ typ.FullName + ", assembly "+ typ.Assembly.FullName + protected def doComplete(root: Symbol) { typeParser.parse(typ, root) } + } class SourcefileLoader(val srcfile: AbstractFile) extends SymbolLoader { protected def description = "source file "+ srcfile.toString @@ -258,11 +258,11 @@ abstract class SymbolLoaders { protected def description = "module class loader" protected def doComplete(root: Symbol) { root.sourceModule.initialize } } - // - // object clrTypes extends clr.CLRTypes { - // val global: SymbolLoaders.this.global.type = SymbolLoaders.this.global - // if (global.forMSIL) init() - // } + + object clrTypes extends clr.CLRTypes { + val global: SymbolLoaders.this.global.type = SymbolLoaders.this.global + if (global.forMSIL) init() + } /** used from classfile parser to avoid cyclies */ var parentsLevel = 0 diff --git a/src/compiler/scala/tools/nsc/symtab/clr/CLRTypes.scala b/src/compiler/scala/tools/nsc/symtab/clr/CLRTypes.scala index 469f7ce3ab..7be0fcb146 100644 --- a/src/compiler/scala/tools/nsc/symtab/clr/CLRTypes.scala +++ b/src/compiler/scala/tools/nsc/symtab/clr/CLRTypes.scala @@ -7,17 +7,17 @@ package scala.tools.nsc package symtab package clr -// import java.io.File -// import java.util.{Comparator, StringTokenizer} -// import scala.util.Sorting -// import ch.epfl.lamp.compiler.msil._ -// import scala.collection.{ mutable, immutable } -// import scala.tools.nsc.util.{Position, NoPosition} +import java.io.File +import java.util.{Comparator, StringTokenizer} +import scala.util.Sorting +import ch.epfl.lamp.compiler.msil._ +import scala.collection.{ mutable, immutable } +import scala.tools.nsc.util.{Position, NoPosition} /** * Collects all types from all reference assemblies. */ -abstract class CLRTypes /*{ +abstract class CLRTypes { val global: Global import global.Symbol @@ -135,4 +135,3 @@ abstract class CLRTypes /*{ def isDelegateType(t: Type): Boolean = { t.BaseType() == DELEGATE } } // CLRTypes -*/ \ No newline at end of file diff --git a/src/compiler/scala/tools/nsc/symtab/clr/TypeParser.scala b/src/compiler/scala/tools/nsc/symtab/clr/TypeParser.scala index d16c9980d5..e11a5a4ad9 100644 --- a/src/compiler/scala/tools/nsc/symtab/clr/TypeParser.scala +++ b/src/compiler/scala/tools/nsc/symtab/clr/TypeParser.scala @@ -6,17 +6,17 @@ package scala.tools.nsc package symtab package clr -// import java.io.IOException -// import io.MsilFile -// import ch.epfl.lamp.compiler.msil.{Type => MSILType, Attribute => MSILAttribute, _} -// import scala.collection.{ mutable, immutable } -// import scala.reflect.internal.pickling.UnPickler -// import ch.epfl.lamp.compiler.msil.Type.TMVarUsage +import java.io.IOException +import io.MsilFile +import ch.epfl.lamp.compiler.msil.{Type => MSILType, Attribute => MSILAttribute, _} +import scala.collection.{ mutable, immutable } +import scala.reflect.internal.pickling.UnPickler +import ch.epfl.lamp.compiler.msil.Type.TMVarUsage /** * @author Nikolay Mihaylov */ -abstract class TypeParser /*{ +abstract class TypeParser { val global: Global @@ -224,14 +224,14 @@ abstract class TypeParser /*{ if (canBeTakenAddressOf) { clazzBoxed.setInfo( if (ownTypeParams.isEmpty) classInfoAsInMetadata - else GenPolyType(ownTypeParams, classInfoAsInMetadata) ) + else polyType(ownTypeParams, classInfoAsInMetadata) ) clazzBoxed.setFlag(flags) val rawValueInfoType = ClassInfoType(definitions.anyvalparam, instanceDefs, clazz) clazz.setInfo( if (ownTypeParams.isEmpty) rawValueInfoType - else GenPolyType(ownTypeParams, rawValueInfoType) ) + else polyType(ownTypeParams, rawValueInfoType) ) } else { clazz.setInfo( if (ownTypeParams.isEmpty) classInfoAsInMetadata - else GenPolyType(ownTypeParams, classInfoAsInMetadata) ) + else polyType(ownTypeParams, classInfoAsInMetadata) ) } // TODO I don't remember if statics.setInfo and staticModule.setInfo should also know about type params @@ -256,18 +256,18 @@ abstract class TypeParser /*{ // import nested types for (ntype <- typ.getNestedTypes() if !(ntype.IsNestedPrivate || ntype.IsNestedAssembly || ntype.IsNestedFamANDAssem) - || ntype.IsInterface /* TODO why shouldn't nested ifaces be type-parsed too? */ ) + || ntype.IsInterface /* TODO why shouldn't nested ifaces be type-parsed too? */ ) { val loader = new loaders.MsilFileLoader(new MsilFile(ntype)) - val nclazz = statics.newClass(ntype.Name.toTypeName) - val nmodule = statics.newModule(ntype.Name) - nclazz.setInfo(loader) - nmodule.setInfo(loader) - staticDefs.enter(nclazz) - staticDefs.enter(nmodule) - - assert(nclazz.companionModule == nmodule, nmodule) - assert(nmodule.companionClass == nclazz, nclazz) + val nclazz = statics.newClass(ntype.Name.toTypeName) + val nmodule = statics.newModule(ntype.Name) + nclazz.setInfo(loader) + nmodule.setInfo(loader) + staticDefs.enter(nclazz) + staticDefs.enter(nmodule) + + assert(nclazz.companionModule == nmodule, nmodule) + assert(nmodule.companionClass == nclazz, nclazz) } val fields = typ.getFields() @@ -280,9 +280,9 @@ abstract class TypeParser /*{ val name = newTermName(field.Name); val fieldType = if (field.IsLiteral && !field.FieldType.IsEnum && isDefinedAtgetConstant(getCLRType(field.FieldType))) - ConstantType(getConstant(getCLRType(field.FieldType), field.getValue)) - else - getCLRType(field.FieldType) + ConstantType(getConstant(getCLRType(field.FieldType), field.getValue)) + else + getCLRType(field.FieldType) val owner = if (field.IsStatic()) statics else clazz; val sym = owner.newValue(NoPosition, name).setFlag(flags).setInfo(fieldType); // TODO: set private within!!! -> look at typechecker/Namers.scala @@ -301,49 +301,49 @@ abstract class TypeParser /*{ for (prop <- typ.getProperties) { val propType: Type = getCLSType(prop.PropertyType); if (propType != null) { - val getter: MethodInfo = prop.GetGetMethod(true); - val setter: MethodInfo = prop.GetSetMethod(true); - var gparamsLength: Int = -1; - if (!(getter == null || getter.IsPrivate || getter.IsAssembly + val getter: MethodInfo = prop.GetGetMethod(true); + val setter: MethodInfo = prop.GetSetMethod(true); + var gparamsLength: Int = -1; + if (!(getter == null || getter.IsPrivate || getter.IsAssembly || getter.IsFamilyAndAssembly || getter.HasPtrParamOrRetType)) - { - assert(prop.PropertyType == getter.ReturnType); - val gparams: Array[ParameterInfo] = getter.GetParameters(); - gparamsLength = gparams.length; - val name: Name = if (gparamsLength == 0) prop.Name else nme.apply; - val flags = translateAttributes(getter); - val owner: Symbol = if (getter.IsStatic) statics else clazz; - val methodSym = owner.newMethod(NoPosition, name).setFlag(flags) + { + assert(prop.PropertyType == getter.ReturnType); + val gparams: Array[ParameterInfo] = getter.GetParameters(); + gparamsLength = gparams.length; + val name: Name = if (gparamsLength == 0) prop.Name else nme.apply; + val flags = translateAttributes(getter); + val owner: Symbol = if (getter.IsStatic) statics else clazz; + val methodSym = owner.newMethod(NoPosition, name).setFlag(flags) val mtype: Type = if (gparamsLength == 0) NullaryMethodType(propType) // .NET properties can't be polymorphic else methodType(getter, getter.ReturnType)(methodSym) methodSym.setInfo(mtype); - methodSym.setFlag(Flags.ACCESSOR); - (if (getter.IsStatic) staticDefs else instanceDefs).enter(methodSym) - clrTypes.methods(methodSym) = getter; - methodsSet -= getter; - } - if (!(setter == null || setter.IsPrivate || setter.IsAssembly + methodSym.setFlag(Flags.ACCESSOR); + (if (getter.IsStatic) staticDefs else instanceDefs).enter(methodSym) + clrTypes.methods(methodSym) = getter; + methodsSet -= getter; + } + if (!(setter == null || setter.IsPrivate || setter.IsAssembly || setter.IsFamilyAndAssembly || setter.HasPtrParamOrRetType)) - { - val sparams: Array[ParameterInfo] = setter.GetParameters() - if(getter != null) - assert(getter.IsStatic == setter.IsStatic); - assert(setter.ReturnType == clrTypes.VOID); - if(getter != null) - assert(sparams.length == gparamsLength + 1, "" + getter + "; " + setter); - - val name: Name = if (gparamsLength == 0) nme.getterToSetter(prop.Name) - else nme.update; - val flags = translateAttributes(setter); - val mtype = methodType(setter, definitions.UnitClass.tpe); - val owner: Symbol = if (setter.IsStatic) statics else clazz; - val methodSym = owner.newMethod(NoPosition, name).setFlag(flags) + { + val sparams: Array[ParameterInfo] = setter.GetParameters() + if(getter != null) + assert(getter.IsStatic == setter.IsStatic); + assert(setter.ReturnType == clrTypes.VOID); + if(getter != null) + assert(sparams.length == gparamsLength + 1, "" + getter + "; " + setter); + + val name: Name = if (gparamsLength == 0) nme.getterToSetter(prop.Name) + else nme.update; + val flags = translateAttributes(setter); + val mtype = methodType(setter, definitions.UnitClass.tpe); + val owner: Symbol = if (setter.IsStatic) statics else clazz; + val methodSym = owner.newMethod(NoPosition, name).setFlag(flags) methodSym.setInfo(mtype(methodSym)) - methodSym.setFlag(Flags.ACCESSOR); - (if (setter.IsStatic) staticDefs else instanceDefs).enter(methodSym); - clrTypes.methods(methodSym) = setter; - methodsSet -= setter; - } + methodSym.setFlag(Flags.ACCESSOR); + (if (setter.IsStatic) staticDefs else instanceDefs).enter(methodSym); + clrTypes.methods(methodSym) = setter; + methodsSet -= setter; + } } } @@ -354,27 +354,27 @@ abstract class TypeParser /*{ val adder: MethodInfo = event.GetAddMethod(); val remover: MethodInfo = event.GetRemoveMethod(); if (!(adder == null || adder.IsPrivate || adder.IsAssembly - || adder.IsFamilyAndAssembly)) - { - assert(adder.ReturnType == clrTypes.VOID); - assert(adder.GetParameters().map(_.ParameterType).toList == List(event.EventHandlerType)); - val name = encode("+="); - val flags = translateAttributes(adder); - val mtype: Type = methodType(adder, adder.ReturnType); - createMethod(name, flags, mtype, adder, adder.IsStatic) - methodsSet -= adder; - } + || adder.IsFamilyAndAssembly)) + { + assert(adder.ReturnType == clrTypes.VOID); + assert(adder.GetParameters().map(_.ParameterType).toList == List(event.EventHandlerType)); + val name = encode("+="); + val flags = translateAttributes(adder); + val mtype: Type = methodType(adder, adder.ReturnType); + createMethod(name, flags, mtype, adder, adder.IsStatic) + methodsSet -= adder; + } if (!(remover == null || remover.IsPrivate || remover.IsAssembly - || remover.IsFamilyAndAssembly)) - { - assert(remover.ReturnType == clrTypes.VOID); - assert(remover.GetParameters().map(_.ParameterType).toList == List(event.EventHandlerType)); - val name = encode("-="); - val flags = translateAttributes(remover); - val mtype: Type = methodType(remover, remover.ReturnType); - createMethod(name, flags, mtype, remover, remover.IsStatic) - methodsSet -= remover; - } + || remover.IsFamilyAndAssembly)) + { + assert(remover.ReturnType == clrTypes.VOID); + assert(remover.GetParameters().map(_.ParameterType).toList == List(event.EventHandlerType)); + val name = encode("-="); + val flags = translateAttributes(remover); + val mtype: Type = methodType(remover, remover.ReturnType); + createMethod(name, flags, mtype, remover, remover.IsStatic) + methodsSet -= remover; + } } */ /* Adds view amounting to syntax sugar for a CLR implicit overload. @@ -480,7 +480,7 @@ abstract class TypeParser /*{ val mtype = methodType(method, rettype); if (mtype == null) return; /* START CLR generics (snippet 4) */ - val mInfo = if (method.IsGeneric) GenPolyType(newMethodTParams, mtype(methodSym)) + val mInfo = if (method.IsGeneric) polyType(newMethodTParams, mtype(methodSym)) else mtype(methodSym) /* END CLR generics (snippet 4) */ /* START CLR non-generics (snippet 4) @@ -805,7 +805,7 @@ abstract class TypeParser /*{ private def translateAttributes(typ: MSILType): Long = { var flags: Long = Flags.JAVA; if (typ.IsNotPublic() || typ.IsNestedPrivate() - || typ.IsNestedAssembly() || typ.IsNestedFamANDAssem()) + || typ.IsNestedAssembly() || typ.IsNestedFamANDAssem()) flags = flags | Flags.PRIVATE; else if (typ.IsNestedFamily() || typ.IsNestedFamORAssem()) flags = flags | Flags.PROTECTED; @@ -849,4 +849,3 @@ abstract class TypeParser /*{ flags } } -*/ \ No newline at end of file diff --git a/src/compiler/scala/tools/nsc/util/MsilClassPath.scala b/src/compiler/scala/tools/nsc/util/MsilClassPath.scala index e46f3cbc77..6215506141 100644 --- a/src/compiler/scala/tools/nsc/util/MsilClassPath.scala +++ b/src/compiler/scala/tools/nsc/util/MsilClassPath.scala @@ -8,20 +8,20 @@ package scala.tools.nsc package util -// import java.io.File -// import java.net.URL -// import java.util.StringTokenizer -// import scala.util.Sorting -// import scala.collection.mutable -// import scala.tools.nsc.io.{ AbstractFile, MsilFile } -// import ch.epfl.lamp.compiler.msil.{ Type => MSILType, Assembly } -// import ClassPath.{ ClassPathContext, isTraitImplementation } +import java.io.File +import java.net.URL +import java.util.StringTokenizer +import scala.util.Sorting +import scala.collection.mutable +import scala.tools.nsc.io.{ AbstractFile, MsilFile } +import ch.epfl.lamp.compiler.msil.{ Type => MSILType, Assembly } +import ClassPath.{ ClassPathContext, isTraitImplementation } /** Keeping the MSIL classpath code in its own file is important to make sure * we don't accidentally introduce a dependency on msil.jar in the jvm. */ -object MsilClassPath /*{ +object MsilClassPath { def collectTypes(assemFile: AbstractFile) = { var res: Array[MSILType] = MSILType.EmptyTypes val assem = Assembly.LoadFrom(assemFile.path) @@ -166,5 +166,4 @@ class AssemblyClassPath(types: Array[MSILType], namespace: String, val context: * MSILType values. */ class MsilClassPath(ext: String, user: String, source: String, context: MsilContext) -extends MergedClassPath[MsilFile](MsilClassPath.assembleEntries(ext, user, source, context), context) { } -*/ \ No newline at end of file +extends MergedClassPath[MsilFile](MsilClassPath.assembleEntries(ext, user, source, context), context) { } \ No newline at end of file -- cgit v1.2.3 From 55990c9ec619cf212a31db4f818dedb5d3150157 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Wed, 14 Mar 2012 10:25:59 -0700 Subject: New starr to support new fundamental laws of reality. And grueling recovery from branch drift. Merges a portion (and only a portion) of topic/inline into master. The major changes which come with this merge are: AnyVal is unsealed, can be extended directly. ScalaObject is no longer with us. --- lib/scala-compiler.jar.desired.sha1 | 2 +- lib/scala-library-src.jar.desired.sha1 | 2 +- lib/scala-library.jar.desired.sha1 | 2 +- .../scala/tools/nsc/transform/LiftCode.scala | 571 --------------------- .../scala/tools/nsc/typechecker/RefChecks.scala | 2 +- test/files/codelib/code.jar.desired.sha1 | 2 +- test/files/neg/anyval-children-2.check | 2 +- test/files/neg/t5529.check | 4 +- test/files/presentation/callcc-interpreter.check | 4 +- test/files/run/existentials3.check | 44 +- test/files/run/programmatic-main.check | 37 +- test/files/run/reify_ann1a.check | 4 +- test/files/run/reify_ann1b.check | 4 +- test/files/run/reify_classfileann_a.check | 4 +- test/files/run/t1195.check | 12 +- test/files/run/t5224.check | 2 +- test/files/run/t5271_1.check | 2 +- test/files/run/t5271_2.check | 2 +- test/files/run/t5271_3.check | 4 +- test/files/run/t5527.check | 14 +- test/files/specialized/SI-5005.check | 4 +- 21 files changed, 75 insertions(+), 649 deletions(-) delete mode 100644 src/compiler/scala/tools/nsc/transform/LiftCode.scala (limited to 'lib') diff --git a/lib/scala-compiler.jar.desired.sha1 b/lib/scala-compiler.jar.desired.sha1 index 79f6de5e27..d8c99fd8a7 100644 --- a/lib/scala-compiler.jar.desired.sha1 +++ b/lib/scala-compiler.jar.desired.sha1 @@ -1 +1 @@ -40f87533e0d03ad04ca632119286d347ee54d8ae ?scala-compiler.jar +c6fc8984eeabb722aca2d99e7afebdb96e834995 ?scala-compiler.jar diff --git a/lib/scala-library-src.jar.desired.sha1 b/lib/scala-library-src.jar.desired.sha1 index cfb865f1e8..1acb36ecd9 100644 --- a/lib/scala-library-src.jar.desired.sha1 +++ b/lib/scala-library-src.jar.desired.sha1 @@ -1 +1 @@ -4a34794dd9a45cd2e8603de559f565535e7aa74b ?scala-library-src.jar +8aca5d1d5890965ea4c8ece61a6018484566a95b ?scala-library-src.jar diff --git a/lib/scala-library.jar.desired.sha1 b/lib/scala-library.jar.desired.sha1 index 28a2c586a0..00fc8b0018 100644 --- a/lib/scala-library.jar.desired.sha1 +++ b/lib/scala-library.jar.desired.sha1 @@ -1 +1 @@ -3516dc2e17bf72b1e4bc665e59f6b7ec51cba48d ?scala-library.jar +3348de294ffc98750730e835e06a84dd4e1133fc ?scala-library.jar diff --git a/src/compiler/scala/tools/nsc/transform/LiftCode.scala b/src/compiler/scala/tools/nsc/transform/LiftCode.scala deleted file mode 100644 index 8affea56a2..0000000000 --- a/src/compiler/scala/tools/nsc/transform/LiftCode.scala +++ /dev/null @@ -1,571 +0,0 @@ -/* 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.ListBuffer -import scala.tools.nsc.util.FreshNameCreator -import scala.runtime.ScalaRunTime.{ isAnyVal, isTuple } - -/** - * Translate expressions of the form reflect.Code.lift(exp) - * to the reified "reflect trees" representation of exp. - * Also: mutable variables that are accessed from a local function are wrapped in refs. - * - * @author Martin Odersky - * @version 2.10 - */ -abstract class LiftCode extends Transform with TypingTransformers { - - import global._ // the global environment - import definitions._ // standard classes and methods - import typer.{ typed, atOwner } // methods to type trees - - val symbols: global.type = global - - /** the following two members override abstract members in Transform */ - val phaseName: String = "liftcode" - - def newTransformer(unit: CompilationUnit): Transformer = - new Codifier(unit) - - private lazy val MirrorMemberNames = - ReflectRuntimeMirror.info.nonPrivateMembers filter (_.isTerm) map (_.toString) toSet - - // Would be nice if we could use something like this to check the names, - // but it seems that info is unavailable when I need it. - private def mirrorFactoryName(value: Any): Option[String] = value match { - // Modest (inadequate) sanity check that there's a member by this name. - case x: Product if MirrorMemberNames(x.productPrefix) => - Some(x.productPrefix) - case _ => - Some(value.getClass.getName split """[$.]""" last) filter MirrorMemberNames - } - private def isMirrorMemberObject(value: Product) = value match { - case NoType | NoPrefix | NoPosition | EmptyTree => true - case _ => false - } - - class Codifier(unit: CompilationUnit) extends TypingTransformer(unit) { - - val reifyDebug = settings.Yreifydebug.value - val reifyTyperDebug = settings.Yreifytyperdebug.value - val debugTrace = util.trace when reifyDebug - - val reifyCopypaste = settings.Yreifycopypaste.value - def printCopypaste(tree: Tree) { - if (reifyDebug) println("=======================") - printCopypaste1(tree) - if (reifyDebug) println("=======================") - } - def printCopypaste1(tree: Tree) { - import scala.reflect.api.Modifier - import scala.reflect.api.Modifier._ - - def copypasteModifier(mod: Modifier.Value): String = mod match { - case mod @ ( - `protected` | `private` | `override` | - `abstract` | `final` | `sealed` | - `implicit` | `lazy` | `macro` | - `case` | `trait`) => "`" + mod.toString + "`" - case mod => mod.toString - } - - // I fervently hope this is a test case or something, not anything being - // depended upon. Of more fragile code I cannot conceive. - for (line <- (tree.toString.split(Properties.lineSeparator) drop 2 dropRight 1)) { - var s = line.trim - s = s.replace("$mr.", "") - s = s.replace(".apply", "") - s = s.replace("scala.collection.immutable.", "") - s = "List\\[List\\[.*?\\].*?\\]".r.replaceAllIn(s, "List") - s = "List\\[.*?\\]".r.replaceAllIn(s, "List") - s = s.replace("immutable.this.Nil", "List()") - s = s.replace("modifiersFromInternalFlags", "Modifiers") - s = s.replace("Modifiers(0L, newTypeName(\"\"), List())", "Modifiers()") - s = """Modifiers\((\d+)[lL], newTypeName\("(.*?)"\), List\((.*?)\)\)""".r.replaceAllIn(s, m => { - val buf = new StringBuilder - - val flags = m.group(1).toLong - val s_flags = Flags.modifiersOfFlags(flags) map copypasteModifier mkString ", " - if (s_flags != "") - buf.append("Set(" + s_flags + ")") - - val privateWithin = "" + m.group(2) - if (privateWithin != "") - buf.append(", newTypeName(\"" + privateWithin + "\")") - - val annotations = m.group(3) - if (annotations.nonEmpty) - buf.append(", List(" + annotations + ")") - - "Modifiers(" + buf.toString + ")" - }) - s = """setInternalFlags\((\d+)L\)""".r.replaceAllIn(s, m => { - val flags = m.group(1).toLong - val mods = Flags.modifiersOfFlags(flags) map copypasteModifier - "setInternalFlags(flagsOfModifiers(List(" + mods.mkString(", ") + ")))" - }) - - println(s) - } - } - - override def transformUnit(unit: CompilationUnit) { - atPhase(phase.next) { - super.transformUnit(unit) - } - } - - override def transform(tree: Tree): Tree = { - val sym = tree.symbol - tree match { - case Apply(_, List(tree)) if sym == Code_lift => // reify Code.lift[T](expr) instances - val saved = printTypings - try { - debugTrace("transforming = ")(if (settings.Xshowtrees.value) "\n" + nodePrinters.nodeToString(tree).trim else tree.toString) - debugTrace("transformed = ") { - val untyped = codify(super.transform(tree)) - if (reifyCopypaste) printCopypaste(untyped) - - printTypings = reifyTyperDebug - val typed = localTyper.typedPos(tree.pos)(untyped) - typed - } - } catch { - case ex: ReifierError => - unit.error(ex.pos, ex.msg) - tree - } finally { - printTypings = saved - } - case _ => - super.transform(tree) - } - } - - def codify(tree: Tree): Tree = debugTrace("codified " + tree + " -> ") { - val targetType = definitions.CodeClass.primaryConstructor.info.paramTypes.head - val reifier = new Reifier() - val arg = gen.mkAsInstanceOf(reifier.reifyTopLevel(tree), targetType, wrapInApply = false) - val treetpe = // this really should use packedType(tree.tpe, context.owner) - // where packedType is defined in Typers. But we can do that only if liftCode is moved to Typers. - if (tree.tpe.typeSymbol.isAnonymousClass) tree.tpe.typeSymbol.classBound - else tree.tpe - New(TypeTree(appliedType(definitions.CodeClass.typeConstructor, List(treetpe.widen))), - List(List(arg))) - } - } - - /** - * Given a tree or type, generate a tree that when executed at runtime produces the original tree or type. - * For instance: Given - * - * var x = 1; Code(x + 1) - * - * The `x + 1` expression is reified to - * - * $mr.Apply($mr.Select($mr.Ident($mr.freeVar("x". , x), "+"), List($mr.Literal($mr.Constant(1)))))) - * - * Or, the term name 'abc' is reified to: - * - * $mr.Apply($mr.Select($mr.Ident("newTermName")), List(Literal(Constant("abc"))))) - * - * todo: Treat embedded Code blocks by merging them into containing block - * - */ - class Reifier() { - - final val scalaPrefix = "scala." - final val localPrefix = "$local" - final val memoizerName = "$memo" - - val reifyDebug = settings.Yreifydebug.value - - private val reifiableSyms = mutable.ArrayBuffer[Symbol]() // the symbols that are reified with the tree - private val symIndex = mutable.HashMap[Symbol, Int]() // the index of a reifiable symbol in `reifiableSyms` - private var boundSyms = Set[Symbol]() // set of all symbols that are bound in tree to be reified - - /** - * Generate tree of the form - * - * { val $mr = scala.reflect.runtime.Mirror - * $local1 = new TypeSymbol(owner1, NoPosition, name1) - * ... - * $localN = new TermSymbol(ownerN, NoPositiion, nameN) - * $local1.setInfo(tpe1) - * ... - * $localN.setInfo(tpeN) - * $localN.setAnnotations(annotsN) - * rtree - * } - * - * where - * - * - `$localI` are free type symbols in the environment, as well as local symbols - * of refinement types. - * - `tpeI` are the info's of `symI` - * - `rtree` is code that generates `data` at runtime, maintaining all attributes. - * - `data` is typically a tree or a type. - */ - def reifyTopLevel(data: Any): Tree = { - val rtree = reify(data) - Block(mirrorAlias :: reifySymbolTableSetup, rtree) - } - - private def isLocatable(sym: Symbol) = - sym.isPackageClass || sym.owner.isClass || sym.isTypeParameter && sym.paramPos >= 0 - - private def registerReifiableSymbol(sym: Symbol): Unit = - if (!(symIndex contains sym)) { - sym.owner.ownersIterator find (x => !isLocatable(x)) foreach registerReifiableSymbol - symIndex(sym) = reifiableSyms.length - reifiableSyms += sym - } - - // helper methods - - private def localName(sym: Symbol): TermName = - newTermName(localPrefix + symIndex(sym)) - - private def call(fname: String, args: Tree*): Tree = - Apply(termPath(fname), args.toList) - - private def mirrorSelect(name: String): Tree = - termPath(nme.MIRROR_PREFIX + name) - - private def mirrorCall(name: TermName, args: Tree*): Tree = - call("" + (nme.MIRROR_PREFIX append name), args: _*) - - private def mirrorCall(name: String, args: Tree*): Tree = - call(nme.MIRROR_PREFIX + name, args: _*) - - private def mirrorFactoryCall(value: Product, args: Tree*): Tree = - mirrorCall(value.productPrefix, args: _*) - - private def scalaFactoryCall(name: String, args: Tree*): Tree = - call(scalaPrefix + name + ".apply", args: _*) - - private def mkList(args: List[Tree]): Tree = - scalaFactoryCall("collection.immutable.List", args: _*) - - private def reifyModifiers(m: Modifiers) = - mirrorCall("modifiersFromInternalFlags", reify(m.flags), reify(m.privateWithin), reify(m.annotations)) - - private def reifyAggregate(name: String, args: Any*) = - scalaFactoryCall(name, (args map reify).toList: _*) - - /** - * Reify a list - */ - private def reifyList(xs: List[Any]): Tree = - mkList(xs map reify) - - /** Reify a name */ - private def reifyName(name: Name) = - mirrorCall(if (name.isTypeName) "newTypeName" else "newTermName", Literal(Constant(name.toString))) - - private def isFree(sym: Symbol) = - !(symIndex contains sym) - - /** - * Reify a reference to a symbol - */ - private def reifySymRef(sym: Symbol): Tree = { - symIndex get sym match { - case Some(idx) => - Ident(localName(sym)) - case None => - if (sym == NoSymbol) - mirrorSelect("NoSymbol") - else if (sym == RootPackage) - mirrorSelect("definitions.RootPackage") - else if (sym == RootClass) - mirrorSelect("definitions.RootClass") - else if (sym == EmptyPackage) - mirrorSelect("definitions.EmptyPackage") - else if (sym == EmptyPackageClass) - mirrorSelect("definitions.EmptyPackageClass") - else if (sym.isModuleClass) - Select(reifySymRef(sym.sourceModule), "moduleClass") - else if (sym.isStatic && sym.isClass) - mirrorCall("staticClass", reify(sym.fullName)) - else if (sym.isStatic && sym.isModule) - mirrorCall("staticModule", reify(sym.fullName)) - else if (isLocatable(sym)) - if (sym.isTypeParameter) - mirrorCall("selectParam", reify(sym.owner), reify(sym.paramPos)) - else { - if (reifyDebug) println("locatable: " + sym + " " + sym.isPackageClass + " " + sym.owner + " " + sym.isTypeParameter) - val rowner = reify(sym.owner) - val rname = reify(sym.name.toString) - if (sym.isType) - mirrorCall("selectType", rowner, rname) - else if (sym.isMethod && sym.owner.isClass && sym.owner.info.decl(sym.name).isOverloaded) { - val index = sym.owner.info.decl(sym.name).alternatives indexOf sym - assert(index >= 0, sym) - mirrorCall("selectOverloadedMethod", rowner, rname, reify(index)) - } else - mirrorCall("selectTerm", rowner, rname) - } - else { - if (sym.isTerm) { - if (reifyDebug) println("Free: " + sym) - val symtpe = lambdaLift.boxIfCaptured(sym, sym.tpe, erasedTypes = false) - def markIfCaptured(arg: Ident): Tree = - if (sym.isCapturedVariable) referenceCapturedVariable(arg) else arg - mirrorCall("freeVar", reify(sym.name.toString), reify(symtpe), markIfCaptured(Ident(sym))) - } else { - if (reifyDebug) println("Late local: " + sym) - registerReifiableSymbol(sym) - reifySymRef(sym) - } - } - } - } - - /** - * reify the creation of a symbol - */ - private def reifySymbolDef(sym: Symbol): Tree = { - if (reifyDebug) println("reify sym def " + sym) - - ValDef(NoMods, localName(sym), TypeTree(), - Apply( - Select(reify(sym.owner), "newNestedSymbol"), - List(reify(sym.name), reify(sym.pos), Literal(Constant(sym.flags))) - ) - ) - } - - /** - * Generate code to add type and annotation info to a reified symbol - */ - private def fillInSymbol(sym: Symbol): Tree = { - val rset = Apply(Select(reifySymRef(sym), nme.setTypeSig), List(reifyType(sym.info))) - if (sym.annotations.isEmpty) rset - else Apply(Select(rset, nme.setAnnotations), List(reify(sym.annotations))) - } - - /** Reify a scope */ - private def reifyScope(scope: Scope): Tree = { - scope foreach registerReifiableSymbol - mirrorCall(nme.newScopeWith, scope.toList map reifySymRef: _*) - } - - /** Reify a list of symbols that need to be created */ - private def reifySymbols(syms: List[Symbol]): Tree = { - syms foreach registerReifiableSymbol - mkList(syms map reifySymRef) - } - - /** Reify a type that defines some symbols */ - private def reifyTypeBinder(value: Product, bound: List[Symbol], underlying: Type): Tree = - mirrorFactoryCall(value, reifySymbols(bound), reify(underlying)) - - /** Reify a type */ - private def reifyType(tpe0: Type): Tree = { - val tpe = tpe0.normalize - val tsym = tpe.typeSymbol - if (tsym.isClass && tpe == tsym.typeConstructor && tsym.isStatic) - Select(reifySymRef(tpe.typeSymbol), nme.asTypeConstructor) - else tpe match { - case t @ NoType => - reifyMirrorObject(t) - case t @ NoPrefix => - reifyMirrorObject(t) - case tpe @ ThisType(clazz) if clazz.isModuleClass && clazz.isStatic => - mirrorCall(nme.thisModuleType, reify(clazz.fullName)) - case t @ RefinedType(parents, decls) => - registerReifiableSymbol(tpe.typeSymbol) - mirrorFactoryCall(t, reify(parents), reify(decls), reify(t.typeSymbol)) - case t @ ClassInfoType(parents, decls, clazz) => - registerReifiableSymbol(clazz) - mirrorFactoryCall(t, reify(parents), reify(decls), reify(t.typeSymbol)) - case t @ ExistentialType(tparams, underlying) => - reifyTypeBinder(t, tparams, underlying) - case t @ PolyType(tparams, underlying) => - reifyTypeBinder(t, tparams, underlying) - case t @ MethodType(params, restpe) => - reifyTypeBinder(t, params, restpe) - case _ => - reifyProductUnsafe(tpe) - } - } - - private def definedInLiftedCode(tpe: Type) = - tpe exists (tp => boundSyms contains tp.typeSymbol) - - private def isErased(tree: Tree) = tree match { - case tt: TypeTree => definedInLiftedCode(tt.tpe) && tt.original == null - case _ => false - } - - /** Reify a tree */ - private def reifyTree(tree: Tree): Tree = tree match { - case EmptyTree => - reifyMirrorObject(EmptyTree) - case This(_) if !(boundSyms contains tree.symbol) => - reifyFree(tree) - case Ident(_) if !(boundSyms contains tree.symbol) => - if (tree.symbol.isVariable && tree.symbol.owner.isTerm) { - captureVariable(tree.symbol) // Note order dependency: captureVariable needs to come before reifyTree here. - mirrorCall("Select", reifyFree(tree), reifyName(nme.elem)) - } else reifyFree(tree) - case tt: TypeTree if (tt.tpe != null) => - if (definedInLiftedCode(tt.tpe)) { - // erase non-essential (i.e. inferred) types - // reify symless counterparts of essential types - if (tt.original != null) reify(tt.original) else mirrorCall("TypeTree") - } else { - var rtt = mirrorCall(nme.TypeTree, reifyType(tt.tpe)) - if (tt.original != null) { - val setOriginal = Select(rtt, newTermName("setOriginal")) - val reifiedOriginal = reify(tt.original) - rtt = Apply(setOriginal, List(reifiedOriginal)) - } - rtt - } - case ta @ TypeApply(hk, ts) => - if (ts exists isErased) reifyTree(hk) else reifyProduct(ta) - case global.emptyValDef => - mirrorSelect(nme.emptyValDef) - case Literal(constant @ Constant(tpe: Type)) if boundSyms exists (tpe contains _) => - CannotReifyClassOfBoundType(tree, tpe) - case Literal(constant @ Constant(sym: Symbol)) if boundSyms contains sym => - CannotReifyClassOfBoundEnum(tree, constant.tpe) - case _ => - if (tree.isDef) { - if (reifyDebug) println("boundSym: " + tree.symbol) - boundSyms += tree.symbol - } - - reifyProduct(tree) - /* - if (tree.isDef || tree.isInstanceOf[Function]) - registerReifiableSymbol(tree.symbol) - if (tree.hasSymbol) - rtree = Apply(Select(rtree, nme.setSymbol), List(reifySymRef(tree.symbol))) - Apply(Select(rtree, nme.setType), List(reifyType(tree.tpe))) -*/ - } - - /** - * Reify a free reference. The result will be either a mirror reference - * to a global value, or else a mirror Literal. - */ - private def reifyFree(tree: Tree): Tree = tree match { - case This(_) if tree.symbol.isClass && !tree.symbol.isModuleClass => - val sym = tree.symbol - if (reifyDebug) println("This for %s, reified as freeVar".format(sym)) - if (reifyDebug) println("Free: " + sym) - val freeVar = mirrorCall("freeVar", reify(sym.name.toString), reify(sym.tpe), This(sym)) - mirrorCall(nme.Ident, freeVar) - case This(_) => - if (reifyDebug) println("This for %s, reified as This".format(tree.symbol)) - mirrorCall(nme.This, reifySymRef(tree.symbol)) - case _ => - mirrorCall(nme.Ident, reifySymRef(tree.symbol)) - } - - // todo: consider whether we should also reify positions - private def reifyPosition(pos: Position): Tree = - reifyMirrorObject(NoPosition) - - // !!! we must eliminate these casts. - private def reifyProductUnsafe(x: Any): Tree = - reifyProduct(x.asInstanceOf[Product]) - private def reifyProduct(x: Product): Tree = - mirrorCall(x.productPrefix, (x.productIterator map reify).toList: _*) - - /** - * Reify a case object defined in Mirror - */ - private def reifyMirrorObject(name: String): Tree = mirrorSelect(name) - private def reifyMirrorObject(x: Product): Tree = reifyMirrorObject(x.productPrefix) - - private def isReifiableConstant(value: Any) = value match { - case null => true // seems pretty reifable to me? - case _: String => true - case _ => isAnyVal(value) - } - - /** Reify an arbitary value */ - private def reify(value: Any): Tree = value match { - case tree: Tree => reifyTree(tree) - case sym: Symbol => reifySymRef(sym) - case tpe: Type => reifyType(tpe) - case xs: List[_] => reifyList(xs) - case xs: Array[_] => scalaFactoryCall(nme.Array, xs map reify: _*) - case scope: Scope => reifyScope(scope) - case x: Name => reifyName(x) - case x: Position => reifyPosition(x) - case x: Modifiers => reifyModifiers(x) - case _ => - if (isReifiableConstant(value)) Literal(Constant(value)) - else reifyProductUnsafe(value) - } - - /** - * An (unreified) path that refers to definition with given fully qualified name - * @param mkName Creator for last portion of name (either TermName or TypeName) - */ - private def path(fullname: String, mkName: String => Name): Tree = { - val parts = fullname split "\\." - val prefixParts = parts.init - val lastName = mkName(parts.last) - if (prefixParts.isEmpty) Ident(lastName) - else { - val prefixTree = ((Ident(prefixParts.head): Tree) /: prefixParts.tail)(Select(_, _)) - Select(prefixTree, lastName) - } - } - - /** An (unreified) path that refers to term definition with given fully qualified name */ - private def termPath(fullname: String): Tree = path(fullname, newTermName) - - /** An (unreified) path that refers to type definition with given fully qualified name */ - private def typePath(fullname: String): Tree = path(fullname, newTypeName) - - private def mirrorAlias = - ValDef(NoMods, nme.MIRROR_SHORT, TypeTree(), termPath(fullnme.MirrorPackage)) - - /** - * Generate code that generates a symbol table of all symbols registered in `reifiableSyms` - */ - private def reifySymbolTableSetup: List[Tree] = { - val symDefs, fillIns = new mutable.ArrayBuffer[Tree] - var i = 0 - while (i < reifiableSyms.length) { - // fillInSymbol might create new reifiableSyms, that's why this is done iteratively - symDefs += reifySymbolDef(reifiableSyms(i)) - fillIns += fillInSymbol(reifiableSyms(i)) - i += 1 - } - - symDefs.toList ++ fillIns.toList - } - } - - /** A throwable signalling a reification error */ - class ReifierError(var pos: Position, val msg: String) extends Throwable(msg) { - def this(msg: String) = this(NoPosition, msg) - } - - def CannotReifyClassOfBoundType(tree: Tree, tpe: Type) = { - val msg = "cannot reify classOf[%s] which refers to a type declared inside the block being reified".format(tpe) - throw new ReifierError(tree.pos, msg) - } - - def CannotReifyClassOfBoundEnum(tree: Tree, tpe: Type) = { - val msg = "cannot reify classOf[%s] which refers to an enum declared inside the block being reified".format(tpe) - throw new ReifierError(tree.pos, msg) - } -} diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index 1e17cb2e3f..a9278a2616 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -526,7 +526,7 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R // #3622: erasure operates on uncurried types -- // note on passing sym in both cases: only sym.isType is relevant for uncurry.transformInfo // !!! erasure.erasure(sym, uncurry.transformInfo(sym, tp)) gives erreneous of inaccessible type - check whether that's still the case! - def uncurryAndErase(tp: Type) = erasure.erasure(sym)(uncurry.transformInfo(sym, tp)) + def uncurryAndErase(tp: Type) = erasure.erasure(sym, uncurry.transformInfo(sym, tp)) val tp1 = uncurryAndErase(clazz.thisType.memberType(sym)) val tp2 = uncurryAndErase(clazz.thisType.memberType(other)) afterErasure(tp1 matches tp2) diff --git a/test/files/codelib/code.jar.desired.sha1 b/test/files/codelib/code.jar.desired.sha1 index dbf19cafd7..8dabf404b9 100644 --- a/test/files/codelib/code.jar.desired.sha1 +++ b/test/files/codelib/code.jar.desired.sha1 @@ -1 +1 @@ -e25f1daf9010b9dc6038ae7069fc9d0f7d48a53b ?code.jar +e76a8883d275ca4870f745b505fb0a1cb9cbe446 ?code.jar diff --git a/test/files/neg/anyval-children-2.check b/test/files/neg/anyval-children-2.check index cb327faeeb..a88682ea93 100644 --- a/test/files/neg/anyval-children-2.check +++ b/test/files/neg/anyval-children-2.check @@ -1,4 +1,4 @@ -anyval-children-2.scala:1: error: Only @inline classes (not traits) are allowed to extend AnyVal +anyval-children-2.scala:1: error: Only classes (not traits) are allowed to extend AnyVal @inline trait NotOkDingus1 extends AnyVal // fail ^ one error found diff --git a/test/files/neg/t5529.check b/test/files/neg/t5529.check index 78a26aeb50..5d2175fa79 100644 --- a/test/files/neg/t5529.check +++ b/test/files/neg/t5529.check @@ -4,9 +4,7 @@ t5529.scala:12: error: File is already defined as class File t5529.scala:10: error: class type required but test.Test.File found sealed class Dir extends File { } ^ -t5529.scala:10: error: illegal inheritance; super - is not a subclass of the superclass Object - of the mixin trait ScalaObject +t5529.scala:10: error: test.Test.File does not have a constructor sealed class Dir extends File { } ^ three errors found diff --git a/test/files/presentation/callcc-interpreter.check b/test/files/presentation/callcc-interpreter.check index 41b07b07dc..3385ef12b7 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 <: Serializable with Product with callccInterpreter.Value]` +`method add(a: callccInterpreter.Value, b: callccInterpreter.Value)callccInterpreter.M[_ >: callccInterpreter.Num with callccInterpreter.Wrong.type <: Product with Serializable 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 <: Serializable with Product 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 <: Product with Serializable 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]() ((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/existentials3.check b/test/files/run/existentials3.check index 41dc1f767c..8559540f80 100644 --- a/test/files/run/existentials3.check +++ b/test/files/run/existentials3.check @@ -1,22 +1,22 @@ -_ <: scala.runtime.AbstractFunction0[_ <: Object with Test$ToS with scala.ScalaObject with scala.Product with scala.Serializable] with scala.ScalaObject with scala.Serializable with java.lang.Object -_ <: Object with Test$ToS with scala.ScalaObject with scala.Product with scala.Serializable -Object with Test$ToS with scala.ScalaObject -Object with Test$ToS with scala.ScalaObject -Object with Test$ToS with scala.ScalaObject -scala.Function0[Object with Test$ToS with scala.ScalaObject] -scala.Function0[Object with Test$ToS with scala.ScalaObject] -_ <: Object with _ <: Object with Object with Test$ToS with scala.ScalaObject -_ <: Object with _ <: Object with _ <: Object with Test$ToS with scala.ScalaObject -scala.collection.immutable.List[Object with scala.collection.Seq[Int] with scala.ScalaObject] -scala.collection.immutable.List[Object with scala.collection.Seq[_ <: Int] with scala.ScalaObject] -_ <: scala.runtime.AbstractFunction0[_ <: Object with Test$ToS with scala.ScalaObject with scala.Product with scala.Serializable] with scala.ScalaObject with scala.Serializable with java.lang.Object -_ <: Object with Test$ToS with scala.ScalaObject with scala.Product with scala.Serializable -Object with Test$ToS with scala.ScalaObject -Object with Test$ToS with scala.ScalaObject -Object with Test$ToS with scala.ScalaObject -scala.Function0[Object with Test$ToS with scala.ScalaObject] -scala.Function0[Object with Test$ToS with scala.ScalaObject] -_ <: Object with _ <: Object with Object with Test$ToS with scala.ScalaObject -_ <: Object with _ <: Object with _ <: Object with Test$ToS with scala.ScalaObject -scala.collection.immutable.List[Object with scala.collection.Seq[Int] with scala.ScalaObject] -scala.collection.immutable.List[Object with scala.collection.Seq[_ <: Int] with scala.ScalaObject] +_ <: scala.runtime.AbstractFunction0[_ <: Object with Test$ToS with scala.Product with scala.Serializable with Object] with scala.Serializable with java.lang.Object +_ <: Object with Test$ToS with scala.Product with scala.Serializable with Object +Object with Test$ToS +Object with Test$ToS with Object +Object with Test$ToS +scala.Function0[Object with Test$ToS] +scala.Function0[Object with Test$ToS] +_ <: Object with _ <: Object with Object with Test$ToS with Object with Object +_ <: Object with _ <: Object with _ <: Object with Test$ToS with Object with Object +scala.collection.immutable.List[Object with scala.collection.Seq[Int] with Object] +scala.collection.immutable.List[Object with scala.collection.Seq[_ <: Int] with Object] +_ <: scala.runtime.AbstractFunction0[_ <: Object with Test$ToS with scala.Product with scala.Serializable with Object] with scala.Serializable with java.lang.Object +_ <: Object with Test$ToS with scala.Product with scala.Serializable with Object +Object with Test$ToS +Object with Test$ToS with Object +Object with Test$ToS +scala.Function0[Object with Test$ToS] +scala.Function0[Object with Test$ToS] +_ <: Object with _ <: Object with Object with Test$ToS with Object with Object +_ <: Object with _ <: Object with _ <: Object with Test$ToS with Object with Object +scala.collection.immutable.List[Object with scala.collection.Seq[Int] with Object] +scala.collection.immutable.List[Object with scala.collection.Seq[_ <: Int] with Object] diff --git a/test/files/run/programmatic-main.check b/test/files/run/programmatic-main.check index a24de79b8a..b5a54f5ea7 100644 --- a/test/files/run/programmatic-main.check +++ b/test/files/run/programmatic-main.check @@ -8,23 +8,22 @@ superaccessors 6 add super accessors in traits and nested classes pickler 7 serialize symbol tables refchecks 8 reference/override checking, translate nested objects - liftcode 9 reify trees - uncurry 10 uncurry, translate function values to anonymous classes - tailcalls 11 replace tail calls by jumps - specialize 12 @specialized-driven class and method specialization - explicitouter 13 this refs to outer pointers, translate patterns - erasure 14 erase types, add interfaces for traits - lazyvals 15 allocate bitmaps, translate lazy vals into lazified defs - lambdalift 16 move nested functions to top level - constructors 17 move field definitions into constructors - flatten 18 eliminate inner classes - mixin 19 mixin composition - cleanup 20 platform-specific cleanups, generate reflective calls - icode 21 generate portable intermediate code - inliner 22 optimization: do inlining -inlineExceptionHandlers 23 optimization: inline exception handlers - closelim 24 optimization: eliminate uncalled closures - dce 25 optimization: eliminate dead code - jvm 26 generate JVM bytecode - terminal 27 The last phase in the compiler chain + 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/reify_ann1a.check b/test/files/run/reify_ann1a.check index 2822238706..97d4848a49 100644 --- a/test/files/run/reify_ann1a.check +++ b/test/files/run/reify_ann1a.check @@ -1,5 +1,5 @@ { - @new ann(immutable.this.List.apply[String]("1a")) @new ann(immutable.this.List.apply[String]("1b")) class C[@new ann(immutable.this.List.apply[String]("2a")) @new ann(immutable.this.List.apply[String]("2b")) T>: Nothing <: Any] extends Object with ScalaObject { + @new ann(immutable.this.List.apply[String]("1a")) @new ann(immutable.this.List.apply[String]("1b")) class C[@new ann(immutable.this.List.apply[String]("2a")) @new ann(immutable.this.List.apply[String]("2b")) T>: Nothing <: Any] extends scala.AnyRef { @new ann(immutable.this.List.apply[String]("3a")) @new ann(immutable.this.List.apply[String]("3b")) private[this] val x: T @ann(immutable.this.List.apply[String]("4a")) @ann(immutable.this.List.apply[String]("4b")) = _; def (@new ann(immutable.this.List.apply[String]("3a")) @new ann(immutable.this.List.apply[String]("3b")) x: T @ann(immutable.this.List.apply[String]("4a")) @ann(immutable.this.List.apply[String]("4b"))) = { super.(); @@ -14,7 +14,7 @@ () } { - @ann(immutable.this.List.apply[String]("1a")) @ann(immutable.this.List.apply[String]("1b")) class C[@ann(immutable.this.List.apply[String]("2a")) @ann(immutable.this.List.apply[String]("2b")) T>: Nothing <: Any] extends Object with ScalaObject { + @ann(immutable.this.List.apply[String]("1a")) @ann(immutable.this.List.apply[String]("1b")) class C[@ann(immutable.this.List.apply[String]("2a")) @ann(immutable.this.List.apply[String]("2b")) T>: Nothing <: Any] extends scala.AnyRef { @ann(immutable.this.List.apply[String]("3a")) @ann(immutable.this.List.apply[String]("3b")) private[this] val x: T @ann(immutable.this.List.apply[String]("4b")) @ann(immutable.this.List.apply[String]("4a")) = _; def (@ann(immutable.this.List.apply[String]("3a")) @ann(immutable.this.List.apply[String]("3b")) x: T @ann(immutable.this.List.apply[String]("4b")) @ann(immutable.this.List.apply[String]("4a"))): C[T] = { C.super.(); diff --git a/test/files/run/reify_ann1b.check b/test/files/run/reify_ann1b.check index e240e1e0ce..ceebc0e2ed 100644 --- a/test/files/run/reify_ann1b.check +++ b/test/files/run/reify_ann1b.check @@ -1,5 +1,5 @@ { - @new ann(bar = "1a") @new ann(bar = "1b") class C[@new ann(bar = "2a") @new ann(bar = "2b") T>: Nothing <: Any] extends Object with ScalaObject { + @new ann(bar = "1a") @new ann(bar = "1b") class C[@new ann(bar = "2a") @new ann(bar = "2b") T>: Nothing <: Any] extends scala.AnyRef { @new ann(bar = "3a") @new ann(bar = "3b") private[this] val x: T @ann(bar = "4a") @ann(bar = "4b") = _; def (@new ann(bar = "3a") @new ann(bar = "3b") x: T @ann(bar = "4a") @ann(bar = "4b")) = { super.(); @@ -14,7 +14,7 @@ () } { - @ann(bar = "1a") @ann(bar = "1b") class C[@ann(bar = "2a") @ann(bar = "2b") T>: Nothing <: Any] extends Object with ScalaObject { + @ann(bar = "1a") @ann(bar = "1b") class C[@ann(bar = "2a") @ann(bar = "2b") T>: Nothing <: Any] extends scala.AnyRef { @ann(bar = "3a") @ann(bar = "3b") private[this] val x: T @ann(bar = "4b") @ann(bar = "4a") = _; def (@ann(bar = "3a") @ann(bar = "3b") x: T @ann(bar = "4b") @ann(bar = "4a")): C[T] = { C.super.(); diff --git a/test/files/run/reify_classfileann_a.check b/test/files/run/reify_classfileann_a.check index 1773263a94..419d916907 100644 --- a/test/files/run/reify_classfileann_a.check +++ b/test/files/run/reify_classfileann_a.check @@ -1,5 +1,5 @@ { - @new ann(bar = "1", quux = Array("2", "3"), baz = new ann(bar = "4")) class C extends Object with ScalaObject { + @new ann(bar = "1", quux = Array("2", "3"), baz = new ann(bar = "4")) class C extends scala.AnyRef { def () = { super.(); () @@ -8,7 +8,7 @@ () } { - @ann(bar = "1", quux = ["2", "3"], baz = ann(bar = "4")) class C extends Object with ScalaObject { + @ann(bar = "1", quux = ["2", "3"], baz = ann(bar = "4")) class C extends scala.AnyRef { def (): C = { C.super.(); () diff --git a/test/files/run/t1195.check b/test/files/run/t1195.check index dc521fb8ca..1214d0c4b5 100644 --- a/test/files/run/t1195.check +++ b/test/files/run/t1195.check @@ -1,6 +1,6 @@ -_ <: scala.runtime.AbstractFunction1[Int, _ <: Object with scala.ScalaObject with scala.Product with scala.Serializable] with scala.ScalaObject with scala.Serializable with java.lang.Object -_ <: Object with scala.ScalaObject with scala.Product with scala.Serializable -Object with scala.ScalaObject with scala.Product with scala.Serializable -_ <: scala.runtime.AbstractFunction1[Int, _ <: Object with scala.ScalaObject with scala.Product with scala.Serializable] with scala.ScalaObject with scala.Serializable with java.lang.Object -_ <: Object with scala.ScalaObject with scala.Product with scala.Serializable -Object with scala.ScalaObject with scala.Product with scala.Serializable +_ <: scala.runtime.AbstractFunction1[Int, _ <: Object with scala.Product with scala.Serializable with Object] with scala.Serializable with java.lang.Object +_ <: Object with scala.Product with scala.Serializable with Object +Object with scala.Product with scala.Serializable +_ <: scala.runtime.AbstractFunction1[Int, _ <: Object with scala.Product with scala.Serializable with Object] with scala.Serializable with java.lang.Object +_ <: Object with scala.Product with scala.Serializable with Object +Object with scala.Product with scala.Serializable diff --git a/test/files/run/t5224.check b/test/files/run/t5224.check index 5bead91b36..28bc75d4fd 100644 --- a/test/files/run/t5224.check +++ b/test/files/run/t5224.check @@ -1,5 +1,5 @@ { - @new Foo(bar = "qwe") class C extends Object with ScalaObject { + @new Foo(bar = "qwe") class C extends scala.AnyRef { def () = { super.(); () diff --git a/test/files/run/t5271_1.check b/test/files/run/t5271_1.check index d4fd544e88..9b956da17a 100644 --- a/test/files/run/t5271_1.check +++ b/test/files/run/t5271_1.check @@ -1,5 +1,5 @@ { - case class C extends Object with ScalaObject with Product with Serializable { + case class C extends Object with Product with Serializable { val foo : Int = _; val bar : Int = _; def (foo: Int, bar: Int) = { diff --git a/test/files/run/t5271_2.check b/test/files/run/t5271_2.check index 5a519f265f..27297febb6 100644 --- a/test/files/run/t5271_2.check +++ b/test/files/run/t5271_2.check @@ -1,5 +1,5 @@ { - case class C extends Object with ScalaObject with Product with Serializable { + case class C extends Object with Product with Serializable { val foo : Int = _; val bar : Int = _; def (foo: Int, bar: Int) = { diff --git a/test/files/run/t5271_3.check b/test/files/run/t5271_3.check index be87696f02..9331c78959 100644 --- a/test/files/run/t5271_3.check +++ b/test/files/run/t5271_3.check @@ -1,12 +1,12 @@ { - object C extends Object with ScalaObject with Serializable { + object C extends scala.AnyRef with Serializable { def () = { super.(); () }; def qwe: Int = 4 }; - case class C extends Object with ScalaObject with Product with Serializable { + case class C extends Object with Product with Serializable { val foo : Int = _; val bar : Int = _; def (foo: Int, bar: Int) = { diff --git a/test/files/run/t5527.check b/test/files/run/t5527.check index 4a8a9ce602..bb13928fd8 100644 --- a/test/files/run/t5527.check +++ b/test/files/run/t5527.check @@ -1,13 +1,13 @@ [[syntax trees at end of parser]]// Scala source: newSource1 package { - object UselessComments extends scala.ScalaObject { + object UselessComments extends scala.AnyRef { def () = { super.(); () }; var z = 0; def test1 = { - object Maybe extends scala.ScalaObject { + object Maybe extends scala.AnyRef { def () = { super.(); () @@ -42,13 +42,13 @@ package { } }; /** comments that we should keep */ - object UsefulComments extends scala.ScalaObject { + object UsefulComments extends scala.AnyRef { def () = { super.(); () }; /** class A */ - class A extends scala.ScalaObject { + class A extends scala.AnyRef { def () = { super.(); () @@ -61,7 +61,7 @@ package { var u = 2 }; /** trait B */ - abstract trait B extends scala.ScalaObject { + abstract trait B extends scala.AnyRef { def $init$() = { () }; @@ -75,7 +75,7 @@ package { var u = 2 }; /** object C */ - object C extends scala.ScalaObject { + object C extends scala.AnyRef { def () = { super.(); () @@ -88,7 +88,7 @@ package { var u = 2 }; /** class D */ - @new deprecated("use ... instead", "2.10.0") class D extends scala.ScalaObject { + @new deprecated("use ... instead", "2.10.0") class D extends scala.AnyRef { def () = { super.(); () diff --git a/test/files/specialized/SI-5005.check b/test/files/specialized/SI-5005.check index d2a97512ae..9fc63a2b1d 100644 --- a/test/files/specialized/SI-5005.check +++ b/test/files/specialized/SI-5005.check @@ -1,6 +1,6 @@ [[syntax trees at end of specialize]]// Scala source: newSource1 package { - class C2[@specialized(scala.Boolean) U >: Nothing <: Any] extends Object with ScalaObject { + class C2[@specialized(scala.Boolean) U >: Nothing <: Any] extends Object { def (): C2[U] = { C2.super.(); () @@ -8,7 +8,7 @@ package { def apply(x: U): U = x; def apply$mcZ$sp(x: Boolean): Boolean = C2.this.apply(x.asInstanceOf[U]()).asInstanceOf[Boolean]() }; - class B extends Object with ScalaObject { + class B extends Object { def (): B = { B.super.(); () -- cgit v1.2.3