diff options
Diffstat (limited to 'src/compiler')
30 files changed, 167 insertions, 151 deletions
diff --git a/src/compiler/scala/reflect/macros/runtime/FrontEnds.scala b/src/compiler/scala/reflect/macros/runtime/FrontEnds.scala index 69fa416f8f..c5c1c84cde 100644 --- a/src/compiler/scala/reflect/macros/runtime/FrontEnds.scala +++ b/src/compiler/scala/reflect/macros/runtime/FrontEnds.scala @@ -41,7 +41,7 @@ trait FrontEnds extends scala.tools.reflect.FrontEnds { } def interactive(): Unit = universe.reporter match { - case reporter: tools.nsc.reporters.AbstractReporter => reporter.displayPrompt() + case reporter: scala.tools.nsc.reporters.AbstractReporter => reporter.displayPrompt() case _ => () } -}
\ No newline at end of file +} diff --git a/src/compiler/scala/reflect/macros/runtime/Settings.scala b/src/compiler/scala/reflect/macros/runtime/Settings.scala index c602532ea4..e9d9a17b81 100644 --- a/src/compiler/scala/reflect/macros/runtime/Settings.scala +++ b/src/compiler/scala/reflect/macros/runtime/Settings.scala @@ -17,7 +17,7 @@ trait Settings { setCompilerSettings(options.split(" ").toList) def setCompilerSettings(options: List[String]): this.type = { - val settings = new tools.nsc.Settings(_ => ()) + val settings = new scala.tools.nsc.Settings(_ => ()) settings.copyInto(universe.settings) this } diff --git a/src/compiler/scala/reflect/macros/util/Traces.scala b/src/compiler/scala/reflect/macros/util/Traces.scala index 078cd2b74f..d16916b753 100644 --- a/src/compiler/scala/reflect/macros/util/Traces.scala +++ b/src/compiler/scala/reflect/macros/util/Traces.scala @@ -2,7 +2,7 @@ package scala.reflect.macros package util trait Traces { - def globalSettings: tools.nsc.Settings + def globalSettings: scala.tools.nsc.Settings val macroDebugLite = globalSettings.YmacrodebugLite.value val macroDebugVerbose = globalSettings.YmacrodebugVerbose.value @@ -10,4 +10,4 @@ trait Traces { val macroTraceVerbose = scala.tools.nsc.util.trace when macroDebugVerbose @inline final def macroLogLite(msg: => Any) { if (macroDebugLite || macroDebugVerbose) println(msg) } @inline final def macroLogVerbose(msg: => Any) { if (macroDebugVerbose) println(msg) } -}
\ No newline at end of file +} diff --git a/src/compiler/scala/tools/nsc/ast/TreeDSL.scala b/src/compiler/scala/tools/nsc/ast/TreeDSL.scala index 2ee38d4b91..e90d779885 100644 --- a/src/compiler/scala/tools/nsc/ast/TreeDSL.scala +++ b/src/compiler/scala/tools/nsc/ast/TreeDSL.scala @@ -95,7 +95,7 @@ trait TreeDSL { def INT_>= (other: Tree) = fn(target, getMember(IntClass, nme.GE), other) def INT_== (other: Tree) = fn(target, getMember(IntClass, nme.EQ), other) def INT_!= (other: Tree) = fn(target, getMember(IntClass, nme.NE), other) - + // generic operations on ByteClass, IntClass, LongClass def GEN_| (other: Tree, kind: ClassSymbol) = fn(target, getMember(kind, nme.OR), other) def GEN_& (other: Tree, kind: ClassSymbol) = fn(target, getMember(kind, nme.AND), other) @@ -234,7 +234,7 @@ trait TreeDSL { } class DefTreeStart(val name: Name) extends TreeVODDStart with DefCreator { def tparams: List[TypeDef] = Nil - def vparamss: List[List[ValDef]] = List(Nil) + def vparamss: List[List[ValDef]] = ListOfNil } class IfStart(cond: Tree, thenp: Tree) { diff --git a/src/compiler/scala/tools/nsc/ast/TreeGen.scala b/src/compiler/scala/tools/nsc/ast/TreeGen.scala index ca8a377c6f..b22681e52b 100644 --- a/src/compiler/scala/tools/nsc/ast/TreeGen.scala +++ b/src/compiler/scala/tools/nsc/ast/TreeGen.scala @@ -44,7 +44,7 @@ abstract class TreeGen extends reflect.internal.TreeGen with TreeDSL { setInfo analyzer.ImportType(qual) ) val importTree = ( - Import(qual, List(ImportSelector(nme.WILDCARD, -1, null, -1))) + Import(qual, ImportSelector.wildList) setSymbol importSym setType NoType ) @@ -58,7 +58,7 @@ abstract class TreeGen extends reflect.internal.TreeGen with TreeDSL { def mkUnchecked(expr: Tree): Tree = atPos(expr.pos) { // This can't be "Annotated(New(UncheckedClass), expr)" because annotations // are very picky about things and it crashes the compiler with "unexpected new". - Annotated(New(scalaDot(UncheckedClass.name), List(Nil)), expr) + Annotated(New(scalaDot(UncheckedClass.name), ListOfNil), expr) } // if it's a Match, mark the selector unchecked; otherwise nothing. def mkUncheckedMatch(tree: Tree) = tree match { @@ -357,8 +357,8 @@ abstract class TreeGen extends reflect.internal.TreeGen with TreeDSL { */ def mkSynchronizedCheck(clazz: Symbol, cond: Tree, syncBody: List[Tree], stats: List[Tree]): Tree = mkSynchronizedCheck(mkAttributedThis(clazz), cond, syncBody, stats) - - def mkSynchronizedCheck(attrThis: Tree, cond: Tree, syncBody: List[Tree], stats: List[Tree]): Tree = + + def mkSynchronizedCheck(attrThis: Tree, cond: Tree, syncBody: List[Tree], stats: List[Tree]): Tree = Block(mkSynchronized( attrThis, If(cond, Block(syncBody: _*), EmptyTree)) :: diff --git a/src/compiler/scala/tools/nsc/ast/Trees.scala b/src/compiler/scala/tools/nsc/ast/Trees.scala index 6f17a7d625..b703a90ebf 100644 --- a/src/compiler/scala/tools/nsc/ast/Trees.scala +++ b/src/compiler/scala/tools/nsc/ast/Trees.scala @@ -111,7 +111,7 @@ trait Trees extends reflect.internal.Trees { self: Global => if (body forall treeInfo.isInterfaceMember) List() else List( atPos(wrappingPos(superPos, lvdefs)) ( - DefDef(NoMods, nme.MIXIN_CONSTRUCTOR, List(), List(List()), TypeTree(), Block(lvdefs, Literal(Constant()))))) + DefDef(NoMods, nme.MIXIN_CONSTRUCTOR, List(), ListOfNil, TypeTree(), Block(lvdefs, Literal(Constant()))))) } else { // convert (implicit ... ) to ()(implicit ... ) if its the only parameter section if (vparamss1.isEmpty || !vparamss1.head.isEmpty && vparamss1.head.head.mods.isImplicit) diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala index 391874c488..cbe9d96e4d 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala @@ -192,7 +192,7 @@ self => override def blockExpr(): Tree = skipBraces(EmptyTree) - override def templateBody(isPre: Boolean) = skipBraces((emptyValDef, List(EmptyTree))) + override def templateBody(isPre: Boolean) = skipBraces((emptyValDef, EmptyTree.asList)) } class UnitParser(val unit: global.CompilationUnit, patches: List[BracePatch]) extends SourceFileParser(unit.source) { @@ -395,7 +395,7 @@ self => NoMods, nme.CONSTRUCTOR, Nil, - List(Nil), + ListOfNil, TypeTree(), Block(List(Apply(gen.mkSuperSelect, Nil)), Literal(Constant(()))) ) @@ -404,7 +404,7 @@ self => def mainParamType = AppliedTypeTree(Ident(tpnme.Array), List(Ident(tpnme.String))) def mainParameter = List(ValDef(Modifiers(Flags.PARAM), nme.argv, mainParamType, EmptyTree)) def mainSetArgv = List(ValDef(NoMods, nme.args, TypeTree(), Ident(nme.argv))) - def mainNew = makeNew(Nil, emptyValDef, stmts, List(Nil), NoPosition, NoPosition) + def mainNew = makeNew(Nil, emptyValDef, stmts, ListOfNil, NoPosition, NoPosition) def mainDef = DefDef(NoMods, nme.main, Nil, List(mainParameter), scalaDot(tpnme.Unit), Block(mainSetArgv, mainNew)) // object Main @@ -2093,7 +2093,7 @@ self => def annotationExpr(): Tree = atPos(in.offset) { val t = exprSimpleType() if (in.token == LPAREN) New(t, multipleArgumentExprs()) - else New(t, List(Nil)) + else New(t, ListOfNil) } /* -------- PARAMETERS ------------------------------------------- */ @@ -2732,10 +2732,10 @@ self => def templateParents(isTrait: Boolean): (List[Tree], List[List[Tree]]) = { val parents = new ListBuffer[Tree] += startAnnotType() val argss = ( - // TODO: the insertion of List(Nil) here is where "new Foo" becomes + // TODO: the insertion of ListOfNil here is where "new Foo" becomes // indistinguishable from "new Foo()". if (in.token == LPAREN && !isTrait) multipleArgumentExprs() - else List(Nil) + else ListOfNil ) while (in.token == WITH) { @@ -2773,7 +2773,7 @@ self => val (self1, body1) = templateBodyOpt(traitParentSeen = isTrait) (parents, argss, self1, earlyDefs ::: body1) } else { - (List(), List(List()), self, body) + (List(), ListOfNil, self, body) } } else { val (parents, argss) = templateParents(isTrait = isTrait) @@ -2800,7 +2800,7 @@ self => else { newLineOptWhenFollowedBy(LBRACE) val (self, body) = templateBodyOpt(traitParentSeen = false) - (List(), List(List()), self, body) + (List(), ListOfNil, self, body) } ) def anyrefParents() = { @@ -2813,7 +2813,7 @@ self => def anyvalConstructor() = ( // Not a well-formed constructor, has to be finished later - see note // regarding AnyVal constructor in AddInterfaces. - DefDef(NoMods, nme.CONSTRUCTOR, Nil, List(Nil), TypeTree(), Block(Nil, Literal(Constant()))) + DefDef(NoMods, nme.CONSTRUCTOR, Nil, ListOfNil, TypeTree(), Block(Nil, Literal(Constant()))) ) val tstart0 = if (body.isEmpty && in.lastOffset < tstart) in.lastOffset else tstart @@ -2834,7 +2834,7 @@ self => * @param isPre specifies whether in early initializer (true) or not (false) */ def templateBody(isPre: Boolean) = inBraces(templateStatSeq(isPre = isPre)) match { - case (self, Nil) => (self, List(EmptyTree)) + case (self, Nil) => (self, EmptyTree.asList) case result => result } def templateBodyOpt(traitParentSeen: Boolean): (ValDef, List[Tree]) = { @@ -2938,7 +2938,7 @@ self => /** Informal - for the repl and other direct parser accessors. */ def templateStats(): List[Tree] = templateStatSeq(isPre = false)._2 match { - case Nil => List(EmptyTree) + case Nil => EmptyTree.asList case stats => stats } diff --git a/src/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala b/src/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala index 5afec611e9..146329183c 100755 --- a/src/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala @@ -162,7 +162,7 @@ abstract class SymbolicXMLBuilder(p: Parsers#Parser, preserveWS: Boolean) { /** could optimize if args.length == 0, args.length == 1 AND args(0) is <: Node. */ def makeXMLseq(pos: Position, args: Seq[Tree]) = { - val buffer = ValDef(NoMods, _buf, TypeTree(), New(_scala_xml_NodeBuffer, List(Nil))) + val buffer = ValDef(NoMods, _buf, TypeTree(), New(_scala_xml_NodeBuffer, ListOfNil)) val applies = args filterNot isEmptyText map (t => Apply(Select(Ident(_buf), _plus), List(t))) atPos(pos)( Block(buffer :: applies.toList, Ident(_buf)) ) diff --git a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala index 898045e410..edf747486a 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala @@ -217,12 +217,12 @@ abstract class TreeBuilder { atPos(cpos) { ClassDef( Modifiers(FINAL), x, Nil, - Template(parents, self, NoMods, List(Nil), argss, stats, cpos.focus)) + Template(parents, self, NoMods, ListOfNil, argss, stats, cpos.focus)) }), atPos(npos) { New( Ident(x) setPos npos.focus, - List(Nil)) + ListOfNil) } ) } diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala index a480429026..a40d8c1a06 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala @@ -880,14 +880,29 @@ abstract class GenICode extends SubComponent { case app @ Apply(fun @ Select(qual, _), args) if !ctx.method.symbol.isStaticConstructor - && fun.symbol.isAccessor && fun.symbol.accessed.hasStaticAnnotation => + && fun.symbol.isAccessor && fun.symbol.accessed.hasStaticAnnotation + && qual.tpe.typeSymbol.orElse(fun.symbol.owner).companionClass != NoSymbol => // bypass the accessor to the companion object and load the static field directly - // the only place were this bypass is not done, is the static intializer for the static field itself + // this bypass is not done: + // - if the static intializer for the static field itself + // - if there is no companion class of the object owner - this happens in the REPL val sym = fun.symbol generatedType = toTypeKind(sym.accessed.info) - val hostClass = qual.tpe.typeSymbol.orElse(sym.owner).companionClass - val staticfield = hostClass.info.findMember(sym.accessed.name, NoFlags, NoFlags, false) - + val hostOwner = qual.tpe.typeSymbol.orElse(sym.owner) + val hostClass = hostOwner.companionClass + val staticfield = hostClass.info.findMember(sym.accessed.name, NoFlags, NoFlags, false) orElse { + if (!currentRun.compiles(hostOwner)) { + // hostOwner was separately compiled -- the static field symbol needs to be recreated in hostClass + import Flags._ + debuglog("recreating sym.accessed.name: " + sym.accessed.name) + val objectfield = hostOwner.info.findMember(sym.accessed.name, NoFlags, NoFlags, false) + val staticfield = hostClass.newVariable(newTermName(sym.accessed.name.toString), tree.pos, STATIC | SYNTHETIC | FINAL) setInfo objectfield.tpe + staticfield.addAnnotation(definitions.StaticClass) + hostClass.info.decls enter staticfield + staticfield + } else NoSymbol + } + if (sym.isGetter) { ctx.bb.emit(LOAD_FIELD(staticfield, true) setHostClass hostClass, tree.pos) ctx diff --git a/src/compiler/scala/tools/nsc/backend/icode/ICodes.scala b/src/compiler/scala/tools/nsc/backend/icode/ICodes.scala index 81fd285cdb..d43013c644 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/ICodes.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/ICodes.scala @@ -2,11 +2,6 @@ * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ -/* NSC -- new scala compiler - * Copyright 2005-2012 LAMP/EPFL - * @author Martin Odersky - */ - package scala.tools.nsc package backend diff --git a/src/compiler/scala/tools/nsc/backend/icode/Opcodes.scala b/src/compiler/scala/tools/nsc/backend/icode/Opcodes.scala index 0f7080ef3c..1fcb406e96 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/Opcodes.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/Opcodes.scala @@ -82,6 +82,8 @@ trait Opcodes { self: ICodes => final val jumpsCat = 10 final val retCat = 11 + private lazy val ObjectReferenceList = ObjectReference :: Nil + /** This class represents an instruction of the intermediate code. * Each case subclass will represent a specific operation. */ @@ -392,14 +394,13 @@ trait Opcodes { self: ICodes => else args } - override def produced = - if (producedType == UNIT || method.isConstructor) 0 - else 1 - - private def producedType: TypeKind = toTypeKind(method.info.resultType) - override def producedTypes = - if (produced == 0) Nil - else producedType :: Nil + private val producedList = toTypeKind(method.info.resultType) match { + case UNIT => Nil + case _ if method.isConstructor => Nil + case kind => kind :: Nil + } + override def produced = producedList.size + override def producedTypes = producedList /** object identity is equality for CALL_METHODs. Needed for * being able to store such instructions into maps, when more @@ -423,7 +424,7 @@ trait Opcodes { self: ICodes => assert(boxType.isValueType && !boxType.isInstanceOf[BOXED] && (boxType ne UNIT)) // documentation override def toString(): String = "UNBOX " + boxType override def consumed = 1 - override def consumedTypes = ObjectReference :: Nil + override def consumedTypes = ObjectReferenceList override def produced = 1 override def producedTypes = boxType :: Nil override def category = objsCat @@ -474,7 +475,7 @@ trait Opcodes { self: ICodes => override def consumed = 1 override def produced = 1 - override def consumedTypes = ObjectReference :: Nil + override def consumedTypes = ObjectReferenceList override def producedTypes = BOOL :: Nil override def category = castsCat @@ -490,7 +491,7 @@ trait Opcodes { self: ICodes => override def consumed = 1 override def produced = 1 - override def consumedTypes = ObjectReference :: Nil + override def consumedTypes = ObjectReferenceList override def producedTypes = typ :: Nil override def category = castsCat @@ -576,7 +577,6 @@ trait Opcodes { self: ICodes => override def produced = 0 override def consumedTypes = kind :: Nil - override def category = jumpsCat } @@ -799,7 +799,7 @@ trait Opcodes { self: ICodes => 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 consumedTypes = ObjectReferenceList // actually consumes a 'boxed valueType' override def produced = 1 override def producedTypes = msil_mgdptr(valueType) :: Nil override def category = objsCat @@ -808,7 +808,7 @@ trait Opcodes { self: ICodes => 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 consumedTypes = ObjectReferenceList // actually consumes a managed pointer override def produced = 0 override def category = objsCat } diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala index 17b479e5e5..87a59128fe 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala @@ -2217,15 +2217,11 @@ abstract class GenASM extends SubComponent with BytecodeWriters { def getMerged(): collection.Map[Local, List[Interval]] = { // TODO should but isn't: unbalanced start(s) of scope(s) val shouldBeEmpty = pending filter { p => val Pair(k, st) = p; st.nonEmpty }; - - val merged = mutable.Map.empty[Local, List[Interval]] - - def addToMerged(lv: Local, start: Label, end: Label) { - val ranges = merged.getOrElseUpdate(lv, Nil) - val coalesced = fuse(ranges, Interval(start, end)) - merged.update(lv, coalesced) - } - + val merged = mutable.Map[Local, List[Interval]]() + def addToMerged(lv: Local, start: Label, end: Label) { + val intv = Interval(start, end) + merged(lv) = if (merged contains lv) fuse(merged(lv), intv) else intv :: Nil + } for(LocVarEntry(lv, start, end) <- seen) { addToMerged(lv, start, end) } /* for each var with unbalanced start(s) of scope(s): diff --git a/src/compiler/scala/tools/nsc/interpreter/Imports.scala b/src/compiler/scala/tools/nsc/interpreter/Imports.scala index 5193166889..14d43bc6d5 100644 --- a/src/compiler/scala/tools/nsc/interpreter/Imports.scala +++ b/src/compiler/scala/tools/nsc/interpreter/Imports.scala @@ -23,7 +23,7 @@ trait Imports { val hd :: tl = sym.fullName.split('.').toList map newTermName val tree = Import( tl.foldLeft(Ident(hd): Tree)((x, y) => Select(x, y)), - List(ImportSelector(nme.WILDCARD, -1, null, -1)) + ImportSelector.wildList ) tree setSymbol sym new ImportHandler(tree) @@ -192,4 +192,4 @@ trait Imports { private def membersAtPickler(sym: Symbol): List[Symbol] = beforePickler(sym.info.nonPrivateMembers.toList) -}
\ No newline at end of file +} diff --git a/src/compiler/scala/tools/nsc/javac/JavaParsers.scala b/src/compiler/scala/tools/nsc/javac/JavaParsers.scala index d1c404b3e3..c5da8822d5 100644 --- a/src/compiler/scala/tools/nsc/javac/JavaParsers.scala +++ b/src/compiler/scala/tools/nsc/javac/JavaParsers.scala @@ -551,7 +551,7 @@ trait JavaParsers extends ast.parser.ParsersCommon with JavaScanners { if (parentToken == AT && in.token == DEFAULT) { val annot = atPos(pos) { - New(Select(scalaDot(nme.runtime), tpnme.AnnotationDefaultATTR), List(List())) + New(Select(scalaDot(nme.runtime), tpnme.AnnotationDefaultATTR), ListOfNil) } mods1 = mods1 withAnnotations List(annot) skipTo(SEMI) @@ -640,7 +640,7 @@ trait JavaParsers extends ast.parser.ParsersCommon with JavaScanners { def importCompanionObject(cdef: ClassDef): Tree = atPos(cdef.pos) { - Import(Ident(cdef.name.toTermName), List(ImportSelector(nme.WILDCARD, -1, null, -1))) + Import(Ident(cdef.name.toTermName), ImportSelector.wildList) } // Importing the companion object members cannot be done uncritically: see @@ -841,7 +841,7 @@ trait JavaParsers extends ast.parser.ParsersCommon with JavaScanners { val predefs = List( DefDef( Modifiers(Flags.JAVA | Flags.STATIC), nme.values, List(), - List(List()), + ListOfNil, arrayOf(enumType), blankExpr), DefDef( diff --git a/src/compiler/scala/tools/nsc/package.scala b/src/compiler/scala/tools/nsc/package.scala index 9ad0d9ba1f..9d593e5acc 100644 --- a/src/compiler/scala/tools/nsc/package.scala +++ b/src/compiler/scala/tools/nsc/package.scala @@ -14,4 +14,6 @@ package object nsc { type MissingRequirementError = scala.reflect.internal.MissingRequirementError val MissingRequirementError = scala.reflect.internal.MissingRequirementError + + val ListOfNil = List(Nil) } diff --git a/src/compiler/scala/tools/nsc/transform/CleanUp.scala b/src/compiler/scala/tools/nsc/transform/CleanUp.scala index 436867257a..300bf833a8 100644 --- a/src/compiler/scala/tools/nsc/transform/CleanUp.scala +++ b/src/compiler/scala/tools/nsc/transform/CleanUp.scala @@ -50,14 +50,14 @@ abstract class CleanUp extends Transform with ast.TreeDSL { private def transformTemplate(tree: Tree) = { val t @ Template(parents, self, body) = tree clearStatics() - + val newBody = transformTrees(body) val templ = deriveTemplate(tree)(_ => transformTrees(newStaticMembers.toList) ::: newBody) try addStaticInits(templ) // postprocess to include static ctors finally clearStatics() } private def mkTerm(prefix: String): TermName = unit.freshTermName(prefix) - + //private val classConstantMeth = new HashMap[String, Symbol] //private val symbolStaticFields = new HashMap[String, (Symbol, Tree, Tree)] @@ -542,12 +542,12 @@ abstract class CleanUp extends Transform with ast.TreeDSL { else tree } - + case ValDef(mods, name, tpt, rhs) if tree.symbol.hasStaticAnnotation => log("moving @static valdef field: " + name + ", in: " + tree.symbol.owner) val sym = tree.symbol val owner = sym.owner - + val staticBeforeLifting = atPhase(currentRun.erasurePhase) { owner.isStatic } val isPrivate = atPhase(currentRun.typerPhase) { sym.getter(owner).hasFlag(PRIVATE) } val isProtected = atPhase(currentRun.typerPhase) { sym.getter(owner).hasFlag(PROTECTED) } @@ -574,19 +574,19 @@ abstract class CleanUp extends Transform with ast.TreeDSL { val compclass = enclosing.newClass(newTypeName(owner.name.toString)) compclass setInfo ClassInfoType(List(ObjectClass.tpe), newScope, compclass) enclosing.info.decls enter compclass - - val compclstree = ClassDef(compclass, NoMods, List(List()), List(List()), List(), tree.pos) - + + val compclstree = ClassDef(compclass, NoMods, ListOfNil, ListOfNil, List(), tree.pos) + syntheticClasses.getOrElseUpdate(enclosing, mutable.Set()) += compclstree - + compclass case comp => comp } - + // create a static field in the companion class for this @static field val stfieldSym = linkedClass.newVariable(newTermName(name), tree.pos, STATIC | SYNTHETIC | FINAL) setInfo sym.tpe stfieldSym.addAnnotation(StaticClass) - + val names = classNames.getOrElseUpdate(linkedClass, linkedClass.info.decls.collect { case sym if sym.name.isTermName => sym.name } toSet) @@ -597,9 +597,9 @@ abstract class CleanUp extends Transform with ast.TreeDSL { ) } else { linkedClass.info.decls enter stfieldSym - + val initializerBody = rhs - + // static field was previously initialized in the companion object itself, like this: // staticBodies((linkedClass, stfieldSym)) = Select(This(owner), sym.getter(owner)) // instead, we move the initializer to the static ctor of the companion class @@ -608,7 +608,7 @@ abstract class CleanUp extends Transform with ast.TreeDSL { } } super.transform(tree) - + /* MSIL requires that the stack is empty at the end of a try-block. * Hence, we here rewrite all try blocks with a result != {Unit, All} such that they * store their result in a local variable. The catch blocks are adjusted as well. @@ -722,7 +722,7 @@ abstract class CleanUp extends Transform with ast.TreeDSL { case Block(stats, expr) => stats :+ expr case t => List(t) } - + val newCtor = findStaticCtor(template) match { // in case there already were static ctors - augment existing ones // currently, however, static ctors aren't being generated anywhere else @@ -746,7 +746,7 @@ abstract class CleanUp extends Transform with ast.TreeDSL { deriveTemplate(template)(newCtor :: _) } } - + private def addStaticDeclarations(tree: Template, clazz: Symbol) { // add static field initializer statements for each static field in clazz if (!clazz.isModuleClass) for { @@ -757,22 +757,23 @@ abstract class CleanUp extends Transform with ast.TreeDSL { val valdef = staticBodies((clazz, stfieldSym)) val ValDef(_, _, _, rhs) = valdef val fixedrhs = rhs.changeOwner((valdef.symbol, clazz.info.decl(nme.CONSTRUCTOR))) - + val stfieldDef = localTyper.typedPos(tree.pos)(VAL(stfieldSym) === EmptyTree) val flattenedInit = fixedrhs match { case Block(stats, expr) => Block(stats, REF(stfieldSym) === expr) case rhs => REF(stfieldSym) === rhs } val stfieldInit = localTyper.typedPos(tree.pos)(flattenedInit) - + // add field definition to new defs newStaticMembers append stfieldDef newStaticInits append stfieldInit + case _ => // ignore @static on other members } } - - - + + + override def transformStats(stats: List[Tree], exprOwner: Symbol): List[Tree] = { super.transformStats(stats, exprOwner) ++ { // flush pending synthetic classes created in this owner @@ -785,22 +786,22 @@ abstract class CleanUp extends Transform with ast.TreeDSL { case clsdef @ ClassDef(mods, name, tparams, t @ Template(parent, self, body)) => // process all classes in the package again to add static initializers clearStatics() - + addStaticDeclarations(t, clsdef.symbol) - + val templ = deriveTemplate(t)(_ => transformTrees(newStaticMembers.toList) ::: body) val ntempl = try addStaticInits(templ) finally clearStatics() - + val derived = deriveClassDef(clsdef)(_ => ntempl) classNames.remove(clsdef.symbol) derived - + case stat => stat } } - + } // CleanUpTransformer } diff --git a/src/compiler/scala/tools/nsc/transform/Constructors.scala b/src/compiler/scala/tools/nsc/transform/Constructors.scala index f2f4a44b02..afc109c47a 100644 --- a/src/compiler/scala/tools/nsc/transform/Constructors.scala +++ b/src/compiler/scala/tools/nsc/transform/Constructors.scala @@ -506,14 +506,14 @@ abstract class Constructors extends Transform with ast.TreeDSL { val applyMethodDef = DefDef( sym = applyMethod, - vparamss = List(List()), + vparamss = ListOfNil, rhs = Block(applyMethodStats, gen.mkAttributedRef(BoxedUnit_UNIT))) ClassDef( sym = closureClass, constrMods = Modifiers(0), vparamss = List(List(outerFieldDef)), - argss = List(List()), + argss = ListOfNil, body = List(applyMethodDef), superPos = impl.pos) } diff --git a/src/compiler/scala/tools/nsc/transform/Mixin.scala b/src/compiler/scala/tools/nsc/transform/Mixin.scala index 3c828db7f3..79b24e826d 100644 --- a/src/compiler/scala/tools/nsc/transform/Mixin.scala +++ b/src/compiler/scala/tools/nsc/transform/Mixin.scala @@ -492,19 +492,19 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL { * fields count as fields defined by the class itself. */ private val fieldOffset = perRunCaches.newMap[Symbol, Int]() - + private val bitmapKindForCategory = perRunCaches.newMap[Name, ClassSymbol]() - + // ByteClass, IntClass, LongClass private def bitmapKind(field: Symbol): ClassSymbol = bitmapKindForCategory(bitmapCategory(field)) - + private def flagsPerBitmap(field: Symbol): Int = bitmapKind(field) match { case BooleanClass => 1 case ByteClass => 8 case IntClass => 32 case LongClass => 64 } - + /** The first transform; called in a pre-order traversal at phase mixin * (that is, every node is processed before its children). @@ -718,7 +718,7 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL { val sym = clazz0.info.decl(bitmapName) assert(!sym.isOverloaded, sym) - + def createBitmap: Symbol = { val bitmapKind = bitmapKindForCategory(category) val sym = clazz0.newVariable(bitmapName, clazz0.pos) setInfo bitmapKind.tpe @@ -732,7 +732,7 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL { case BooleanClass => VAL(sym) === FALSE case _ => VAL(sym) === ZERO } - + sym setFlag PrivateLocal clazz0.info.decls.enter(sym) addDef(clazz0.pos, init) @@ -744,7 +744,7 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL { else createBitmap } - + def maskForOffset(offset: Int, sym: Symbol, kind: ClassSymbol): Tree = { def realOffset = offset % flagsPerBitmap(sym) if (kind == LongClass ) LIT(1L << realOffset) else LIT(1 << realOffset) @@ -755,9 +755,9 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL { val bmp = bitmapFor(clazz, offset, valSym) def mask = maskForOffset(offset, valSym, kind) def x = This(clazz) DOT bmp - def newValue = if (kind == BooleanClass) TRUE else (x GEN_| (mask, kind)) + def newValue = if (kind == BooleanClass) TRUE else (x GEN_| (mask, kind)) - x === newValue + x === newValue } /** Return an (untyped) tree of the form 'clazz.this.bitmapSym & mask (==|!=) 0', the @@ -775,7 +775,7 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL { else lhs GEN_!= (ZERO, kind) } } - + def mkSlowPathDef(clazz: Symbol, lzyVal: Symbol, cond: Tree, syncBody: List[Tree], stats: List[Tree], retVal: Tree, attrThis: Tree, args: List[Tree]): Symbol = { val defSym = clazz.newMethod(nme.newLazyValSlowComputeName(lzyVal.name), lzyVal.pos, PRIVATE) @@ -791,14 +791,14 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL { stats: List[Tree], retVal: Tree): Tree = { mkFastPathBody(clazz, lzyVal, cond, syncBody, stats, retVal, gen.mkAttributedThis(clazz), List()) } - + def mkFastPathBody(clazz: Symbol, lzyVal: Symbol, cond: Tree, syncBody: List[Tree], stats: List[Tree], retVal: Tree, attrThis: Tree, args: List[Tree]): Tree = { val slowPathSym: Symbol = mkSlowPathDef(clazz, lzyVal, cond, syncBody, stats, retVal, attrThis, args) If(cond, fn (This(clazz), slowPathSym, args.map(arg => Ident(arg.symbol)): _*), retVal) } - - + + /** Always copy the tree if we are going to perform sym substitution, * otherwise we will side-effect on the tree that is used in the fast path */ @@ -807,7 +807,7 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL { if (tree.hasSymbol && from.contains(tree.symbol)) super.transform(tree.duplicate) else super.transform(tree.duplicate) - + override def apply[T <: Tree](tree: T): T = if (from.isEmpty) tree else super.apply(tree) } @@ -827,8 +827,8 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL { * The result will be a tree of the form * { if ((bitmap&n & MASK) == 0) this.l$compute() * else l$ - * - * ... + * + * ... * def l$compute() = { synchronized(this) { * if ((bitmap$n & MASK) == 0) { * init // l$ = <rhs> @@ -836,7 +836,7 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL { * }} * l$ * } - * + * * ... * this.f1 = null * ... this.fn = null @@ -846,7 +846,7 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL { * For Int bitmap it is 32 and then 'n' in the above code is: (offset / 32), * the MASK is (1 << (offset % 32)). * If the class contains only a single lazy val then the bitmap is represented - * as a Boolean and the condition checking is a simple bool test. + * as a Boolean and the condition checking is a simple bool test. */ def mkLazyDef(clazz: Symbol, lzyVal: Symbol, init: List[Tree], retVal: Tree, offset: Int): Tree = { def nullify(sym: Symbol) = Select(This(clazz), sym.accessedOrSelf) === LIT(null) @@ -878,7 +878,7 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL { def mkCheckedAccessor(clazz: Symbol, retVal: Tree, offset: Int, pos: Position, fieldSym: Symbol): Tree = { val sym = fieldSym.getter(fieldSym.owner) val bitmapSym = bitmapFor(clazz, offset, sym) - val kind = bitmapKind(sym) + val kind = bitmapKind(sym) val mask = maskForOffset(offset, sym, kind) val msg = "Uninitialized field: " + unit.source + ": " + pos.line val result = @@ -966,7 +966,7 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL { stats flatMap { case stat @ Assign(lhs @ Select(This(_), _), rhs) => stat :: checkedGetter(lhs) // remove initialization for default values - case Apply(lhs @ Select(Ident(self), _), List(EmptyTree)) if lhs.symbol.isSetter => Nil + case Apply(lhs @ Select(Ident(self), _), EmptyTree.asList) if lhs.symbol.isSetter => Nil case stat => List(stat) }, exprOwner diff --git a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala index 049157dcf1..30cab66677 100644 --- a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala +++ b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala @@ -111,7 +111,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { case TypeRef(_, GroupOfSpecializable, arg :: Nil) => arg.typeArgs map (_.typeSymbol) case _ => - List(tp.typeSymbol) + tp.typeSymbol :: Nil } } } @@ -362,7 +362,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { // creating each permutation of concrete types def loop(ctypes: List[List[Type]]): List[List[Type]] = ctypes match { case Nil => Nil - case set :: Nil => set map (x => List(x)) + case set :: Nil => set map (_ :: Nil) case set :: sets => for (x <- set ; xs <- loop(sets)) yield x :: xs } // zip the keys with each permutation to create a TypeEnv. @@ -424,7 +424,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { case MethodType(argSyms, resTpe) => specializedTypeVars(resTpe :: argSyms.map(_.tpe)) case ExistentialType(_, res) => specializedTypeVars(res) case AnnotatedType(_, tp, _) => specializedTypeVars(tp) - case TypeBounds(lo, hi) => specializedTypeVars(List(lo, hi)) + case TypeBounds(lo, hi) => specializedTypeVars(lo :: hi :: Nil) case RefinedType(parents, _) => parents flatMap specializedTypeVars toSet case _ => Set() } diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala index e98bf519fe..aae9625e2d 100644 --- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala +++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala @@ -35,8 +35,8 @@ import language.postfixOps * - convert non-local returns to throws with enclosing try statements. * - convert try-catch expressions in contexts where there might be values on the stack to * a local method and a call to it (since an exception empties the evaluation stack): - * - * meth(x_1,..., try { x_i } catch { ..}, .. x_b0) ==> + * + * meth(x_1,..., try { x_i } catch { ..}, .. x_b0) ==> * { * def liftedTry$1 = try { x_i } catch { .. } * meth(x_1, .., liftedTry$1(), .. ) @@ -271,7 +271,7 @@ abstract class UnCurry extends InfoTransform localTyper.typedPos(fun.pos) { Block( - List(ClassDef(anonClass, NoMods, List(List()), List(List()), List(applyMethodDef), fun.pos)), + List(ClassDef(anonClass, NoMods, ListOfNil, ListOfNil, List(applyMethodDef), fun.pos)), Typed(New(anonClass.tpe), TypeTree(fun.tpe))) } @@ -396,7 +396,7 @@ abstract class UnCurry extends InfoTransform localTyper.typedPos(fun.pos) { Block( - List(ClassDef(anonClass, NoMods, List(List()), List(List()), List(applyOrElseMethodDef, isDefinedAtMethodDef), fun.pos)), + List(ClassDef(anonClass, NoMods, ListOfNil, ListOfNil, List(applyOrElseMethodDef, isDefinedAtMethodDef), fun.pos)), Typed(New(anonClass.tpe), TypeTree(fun.tpe))) } } @@ -558,7 +558,7 @@ abstract class UnCurry extends InfoTransform sym.setInfo(MethodType(List(), tree.tpe)) tree.changeOwner(currentOwner -> sym) localTyper.typedPos(tree.pos)(Block( - List(DefDef(sym, List(Nil), tree)), + List(DefDef(sym, ListOfNil, tree)), Apply(Ident(sym), Nil) )) } @@ -641,7 +641,7 @@ abstract class UnCurry extends InfoTransform case ret @ Return(_) if (isNonLocalReturn(ret)) => withNeedLift(true) { super.transform(ret) } - case Try(_, Nil, _) => + case Try(_, Nil, _) => // try-finally does not need lifting: lifting is needed only for try-catch // expressions that are evaluated in a context where the stack might not be empty. // `finally` does not attempt to continue evaluation after an exception, so the fact @@ -711,8 +711,12 @@ abstract class UnCurry extends InfoTransform } case dd @ DefDef(_, _, _, vparamss0, _, rhs0) => + val vparamss1 = vparamss0 match { + case _ :: Nil => vparamss0 + case _ => vparamss0.flatten :: Nil + } val flatdd = copyDefDef(dd)( - vparamss = List(vparamss0.flatten), + vparamss = vparamss1, rhs = nonLocalReturnKeys get dd.symbol match { case Some(k) => atPos(rhs0.pos)(nonLocalReturnTry(rhs0, k, dd.symbol)) case None => rhs0 diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala index dd5588e9a6..6a908c6c65 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala @@ -27,6 +27,13 @@ trait Contexts { self: Analyzer => override def implicitss: List[List[ImplicitInfo]] = Nil override def toString = "NoContext" } + private object RootImports { + import definitions._ + // Possible lists of root imports + val javaList = JavaLangPackage :: Nil + val javaAndScalaList = JavaLangPackage :: ScalaPackage :: Nil + val completeList = JavaLangPackage :: ScalaPackage :: PredefModule :: Nil + } private val startContext = { NoContext.make( @@ -46,13 +53,12 @@ trait Contexts { self: Analyzer => * among its leading imports, or if the tree is [[scala.Predef]], `Predef` is not imported. */ protected def rootImports(unit: CompilationUnit): List[Symbol] = { - import definitions._ - assert(isDefinitionsInitialized, "definitions uninitialized") + assert(definitions.isDefinitionsInitialized, "definitions uninitialized") if (settings.noimports.value) Nil - else if (unit.isJava) List(JavaLangPackage) - else if (settings.nopredef.value || treeInfo.noPredefImportForUnit(unit.body)) List(JavaLangPackage, ScalaPackage) - else List(JavaLangPackage, ScalaPackage, PredefModule) + else if (unit.isJava) RootImports.javaList + else if (settings.nopredef.value || treeInfo.noPredefImportForUnit(unit.body)) RootImports.javaAndScalaList + else RootImports.completeList } def rootContext(unit: CompilationUnit): Context = rootContext(unit, EmptyTree, false) diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala index d724164715..7016474a90 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala @@ -1641,7 +1641,7 @@ trait Infer { // for functional values, the `apply` method might be overloaded val mtypes = followApply(alt.tpe) match { case OverloadedType(_, alts) => alts map (_.tpe) - case t => List(t) + case t => t :: Nil } // Drop those that use a default; keep those that use vararg/tupling conversion. mtypes exists (t => diff --git a/src/compiler/scala/tools/nsc/typechecker/Macros.scala b/src/compiler/scala/tools/nsc/typechecker/Macros.scala index 4765bbabc9..02d95544e8 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Macros.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Macros.scala @@ -797,7 +797,7 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces { collectMacroArgs(expandee) val argcDoesntMatch = macroDef.paramss.length != exprArgs.length - val nullaryArgsEmptyParams = exprArgs.isEmpty && macroDef.paramss == List(List()) + val nullaryArgsEmptyParams = exprArgs.isEmpty && macroDef.paramss == ListOfNil if (argcDoesntMatch && !nullaryArgsEmptyParams) { typer.TyperErrorGen.MacroPartialApplicationError(expandee); return None } var argss: List[List[Any]] = List(context) :: exprArgs.toList diff --git a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala index f7ba189e0f..4f597f97c9 100644 --- a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala +++ b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala @@ -242,7 +242,7 @@ trait MethodSynthesis { abort("No synthetics for " + meth + ": synthetics contains " + context.unit.synthetics.keys.mkString(", ")) } case _ => - List(stat) + stat :: Nil } def standardAccessors(vd: ValDef): List[DerivedFromValDef] = ( @@ -491,7 +491,7 @@ trait MethodSynthesis { // Derives a tree without attempting to use the original tree's symbol. override def derivedTree = { atPos(tree.pos.focus) { - DefDef(derivedMods, name, Nil, List(Nil), tree.tpt.duplicate, + DefDef(derivedMods, name, Nil, ListOfNil, tree.tpt.duplicate, if (isDeferred) EmptyTree else Select(This(owner), tree.name) ) } diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index 92d0d4e228..77d1260564 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -973,7 +973,7 @@ trait Namers extends MethodSynthesis { // Add a () parameter section if this overrides some method with () parameters. if (clazz.isClass && vparamss.isEmpty && overriddenSymbol.alternatives.exists( _.info.isInstanceOf[MethodType])) { - vparamSymss = List(List()) + vparamSymss = ListOfNil } mforeach(vparamss) { vparam => if (vparam.tpt.isEmpty) { @@ -1032,7 +1032,7 @@ trait Namers extends MethodSynthesis { var baseParamss = (vparamss, overridden.tpe.paramss) match { // match empty and missing parameter list case (Nil, List(Nil)) => Nil - case (List(Nil), Nil) => List(Nil) + case (List(Nil), Nil) => ListOfNil case (_, paramss) => paramss } assert( diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index 41387b7507..601ceaaa53 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -1298,13 +1298,12 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R def transformStat(tree: Tree, index: Int): List[Tree] = tree match { case t if treeInfo.isSelfConstrCall(t) => assert(index == 0, index) - val t = transform(tree) - if (currentLevel.maxindex > 0) { + try transform(tree) :: Nil + finally if (currentLevel.maxindex > 0) { // An implementation restriction to avoid VerifyErrors and lazyvals mishaps; see SI-4717 debuglog("refsym = " + currentLevel.refsym) unit.error(currentLevel.refpos, "forward reference not allowed from self constructor invocation") } - List(t) case ModuleDef(_, _, _) => eliminateModuleDefs(tree) case ValDef(_, _, _, _) => val tree1 @ ValDef(_, _, _, rhs) = transform(tree) // important to do before forward reference check @@ -1316,11 +1315,11 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R debuglog("refsym = " + currentLevel.refsym) unit.error(currentLevel.refpos, "forward reference extends over definition of " + lazySym) } - List(tree1) + tree1 :: Nil } case Import(_, _) => Nil case DefDef(mods, _, _, _, _, _) if (mods hasFlag MACRO) || (tree.symbol hasFlag MACRO) => Nil - case _ => List(transform(tree)) + case _ => transform(tree) :: Nil } /* Check whether argument types conform to bounds of type parameters */ diff --git a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala index d2a89eb9ff..77c1bedc8e 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala @@ -70,7 +70,7 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT storeAccessorDefinition(clazz, DefDef(acc, EmptyTree)) acc } - + atPos(sel.pos)(Select(gen.mkAttributedThis(clazz), superAcc) setType sel.tpe) } @@ -290,7 +290,7 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT log("Ensuring accessor for call to protected " + sym.fullLocationString + " from " + currentClass) ensureAccessor(sel) } else - mayNeedProtectedAccessor(sel, List(EmptyTree), false) + mayNeedProtectedAccessor(sel, EmptyTree.asList, false) } case Super(_, mix) => @@ -303,7 +303,7 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT transformSuperSelect(sel) case _ => - mayNeedProtectedAccessor(sel, List(EmptyTree), true) + mayNeedProtectedAccessor(sel, EmptyTree.asList, true) } case DefDef(mods, name, tparams, vparamss, tpt, rhs) if tree.symbol.isMethodWithExtension => @@ -500,7 +500,7 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT ) true } - isCandidate && !host.isPackageClass && !isSelfType + isCandidate && !host.isPackageClass && !isSelfType } /** Return the innermost enclosing class C of referencingClass for which either diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 9b07eed5d7..b056b16e32 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -194,16 +194,14 @@ trait Typers extends Modes with Adaptations with Tags { case PolyType(_, _) => EmptyTree case _ => def wrapImplicit(from: Type): Tree = { - val result = inferImplicit(tree, functionType(List(from), to), reportAmbiguous, true, context, saveErrors) + val result = inferImplicit(tree, functionType(from :: Nil, to), reportAmbiguous, true, context, saveErrors) if (result.subst != EmptyTreeTypeSubstituter) { result.subst traverse tree notifyUndetparamsInferred(result.subst.from, result.subst.to) } result.tree } - val result = wrapImplicit(from) - if (result != EmptyTree) result - else wrapImplicit(byNameType(from)) + wrapImplicit(from) orElse wrapImplicit(byNameType(from)) } } @@ -2504,7 +2502,7 @@ trait Typers extends Modes with Adaptations with Tags { def translated = if (members.head eq EmptyTree) setError(tree) - else typed(atPos(tree.pos)(Block(List(ClassDef(anonClass, NoMods, List(List()), List(List()), members, tree.pos.focus)), atPos(tree.pos.focus)(New(anonClass.tpe)))), mode, pt) + else typed(atPos(tree.pos)(Block(List(ClassDef(anonClass, NoMods, ListOfNil, ListOfNil, members, tree.pos.focus)), atPos(tree.pos.focus)(New(anonClass.tpe)))), mode, pt) } // Function(params, Match(sel, cases)) ==> new <Partial>Function { def apply<OrElse>(params) = `translateMatch('sel match { cases }')` } @@ -4032,9 +4030,9 @@ trait Typers extends Modes with Adaptations with Tags { } else { var thenp1 = typed(thenp, pt) var elsep1 = typed(elsep, pt) + def thenTp = packedType(thenp1, context.owner) + def elseTp = packedType(elsep1, context.owner) - lazy val thenTp = packedType(thenp1, context.owner) - lazy val elseTp = packedType(elsep1, context.owner) // println("typedIf: "+(thenp1.tpe, elsep1.tpe, ptOrLub(List(thenp1.tpe, elsep1.tpe)),"\n", thenTp, elseTp, thenTp =:= elseTp)) val (owntype, needAdapt) = // in principle we should pack the types of each branch before lubbing, but lub doesn't really work for existentials anyway @@ -4046,7 +4044,7 @@ trait Typers extends Modes with Adaptations with Tags { && thenTp =:= elseTp ) (thenp1.tpe, false) // use unpacked type // TODO: skolemize (lub of packed types) when that no longer crashes on files/pos/t4070b.scala - else ptOrLub(List(thenp1.tpe, elsep1.tpe), pt) + else ptOrLub(thenp1.tpe :: elsep1.tpe :: Nil, pt) if (needAdapt) { //isNumericValueType(owntype)) { thenp1 = adapt(thenp1, mode, owntype) diff --git a/src/compiler/scala/tools/nsc/typechecker/Unapplies.scala b/src/compiler/scala/tools/nsc/typechecker/Unapplies.scala index 4871ef199c..5db1863f67 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Unapplies.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Unapplies.scala @@ -115,7 +115,7 @@ trait Unapplies extends ast.TreeDSL Modifiers(OVERRIDE | FINAL), nme.toString_, Nil, - List(Nil), + ListOfNil, TypeTree(), Literal(Constant(cdef.name.decode))) @@ -126,7 +126,7 @@ trait Unapplies extends ast.TreeDSL ModuleDef( Modifiers(cdef.mods.flags & AccessFlags | SYNTHETIC, cdef.mods.privateWithin), cdef.name.toTermName, - Template(parents, emptyValDef, NoMods, Nil, List(Nil), body, cdef.impl.pos.focus)) + Template(parents, emptyValDef, NoMods, Nil, ListOfNil, body, cdef.impl.pos.focus)) } private val caseMods = Modifiers(SYNTHETIC | CASE) |