summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/reflect/macros/runtime/FrontEnds.scala4
-rw-r--r--src/compiler/scala/reflect/macros/runtime/Settings.scala2
-rw-r--r--src/compiler/scala/reflect/macros/util/Traces.scala4
-rw-r--r--src/compiler/scala/tools/nsc/ast/TreeDSL.scala4
-rw-r--r--src/compiler/scala/tools/nsc/ast/TreeGen.scala8
-rw-r--r--src/compiler/scala/tools/nsc/ast/Trees.scala2
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Parsers.scala22
-rwxr-xr-xsrc/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala2
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala4
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/GenICode.scala25
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/ICodes.scala5
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/Opcodes.scala28
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala14
-rw-r--r--src/compiler/scala/tools/nsc/interpreter/Imports.scala4
-rw-r--r--src/compiler/scala/tools/nsc/javac/JavaParsers.scala6
-rw-r--r--src/compiler/scala/tools/nsc/package.scala2
-rw-r--r--src/compiler/scala/tools/nsc/transform/CleanUp.scala51
-rw-r--r--src/compiler/scala/tools/nsc/transform/Constructors.scala4
-rw-r--r--src/compiler/scala/tools/nsc/transform/Mixin.scala40
-rw-r--r--src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala6
-rw-r--r--src/compiler/scala/tools/nsc/transform/UnCurry.scala18
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Contexts.scala16
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Infer.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Macros.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala4
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Namers.scala4
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/RefChecks.scala9
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala8
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala14
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Unapplies.scala4
-rw-r--r--src/library/scala/Option.scala2
-rw-r--r--src/library/scala/collection/GenTraversableLike.scala12
-rw-r--r--src/library/scala/collection/mutable/Queue.scala12
-rw-r--r--src/library/scala/reflect/base/Base.scala1
-rw-r--r--src/reflect/scala/reflect/internal/Definitions.scala5
-rw-r--r--src/reflect/scala/reflect/internal/Symbols.scala43
-rw-r--r--src/reflect/scala/reflect/internal/TreeGen.scala2
-rw-r--r--src/reflect/scala/reflect/internal/TreeInfo.scala12
-rw-r--r--src/reflect/scala/reflect/internal/Trees.scala6
-rw-r--r--src/reflect/scala/reflect/internal/Types.scala4
-rw-r--r--src/reflect/scala/reflect/internal/util/Collections.scala4
-rw-r--r--src/scalap/scala/tools/scalap/Main.scala6
-rw-r--r--test/files/neg/static-annot.scala6
-rw-r--r--test/files/pos/t6208.scala4
-rw-r--r--test/files/run/static-annot-repl.check32
-rw-r--r--test/files/run/static-annot-repl.scala22
-rw-r--r--test/files/run/static-annot/field.scala13
-rw-r--r--test/files/run/t6236.check2
-rw-r--r--test/files/run/t6236/file_1.scala9
-rw-r--r--test/files/run/t6236/file_2.scala10
50 files changed, 327 insertions, 198 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)
diff --git a/src/library/scala/Option.scala b/src/library/scala/Option.scala
index f651461fe6..b7420f4447 100644
--- a/src/library/scala/Option.scala
+++ b/src/library/scala/Option.scala
@@ -266,7 +266,7 @@ sealed abstract class Option[+A] extends Product with Serializable {
* if it is nonempty, or the empty list if the $option is empty.
*/
def toList: List[A] =
- if (isEmpty) List() else List(this.get)
+ if (isEmpty) List() else new ::(this.get, Nil)
/** Returns a [[scala.util.Left]] containing the given
* argument `left` if this $option is empty, or
diff --git a/src/library/scala/collection/GenTraversableLike.scala b/src/library/scala/collection/GenTraversableLike.scala
index 903de4a247..9b04256c8d 100644
--- a/src/library/scala/collection/GenTraversableLike.scala
+++ b/src/library/scala/collection/GenTraversableLike.scala
@@ -65,14 +65,14 @@ trait GenTraversableLike[+A, +Repr] extends Any with GenTraversableOnce[A] with
* @throws `NoSuchElementException` if the $coll is empty.
*/
def head: A
-
+
/** Optionally selects the first element.
* $orderDependent
* @return the first element of this $coll if it is nonempty,
* `None` if it is empty.
*/
def headOption: Option[A]
-
+
/** Tests whether this $coll can be repeatedly traversed.
* @return `true`
*/
@@ -92,14 +92,14 @@ trait GenTraversableLike[+A, +Repr] extends Any with GenTraversableOnce[A] with
* @throws NoSuchElementException If the $coll is empty.
*/
def last: A
-
+
/** Optionally selects the last element.
* $orderDependent
* @return the last element of this $coll$ if it is nonempty,
* `None` if it is empty.
*/
def lastOption: Option[A]
-
+
/** Selects all elements except the last.
* $orderDependent
* @return a $coll consisting of all elements of this $coll
@@ -107,7 +107,7 @@ trait GenTraversableLike[+A, +Repr] extends Any with GenTraversableOnce[A] with
* @throws `UnsupportedOperationException` if the $coll is empty.
*/
def init: Repr
-
+
/** Computes a prefix scan of the elements of the collection.
*
* Note: The neutral element `z` may be applied more than once.
@@ -210,7 +210,7 @@ trait GenTraversableLike[+A, +Repr] extends Any with GenTraversableOnce[A] with
def collect[B, That](pf: PartialFunction[A, B])(implicit bf: CanBuildFrom[Repr, B, That]): That
/** Builds a new collection by applying a function to all elements of this $coll
- * and using the elements of the resulting collections.
+ * and using the elements of the resulting collections.
*
* @param f the function to apply to each element.
* @tparam B the element type of the returned collection.
diff --git a/src/library/scala/collection/mutable/Queue.scala b/src/library/scala/collection/mutable/Queue.scala
index 2aa19d6cb0..21c3a84699 100644
--- a/src/library/scala/collection/mutable/Queue.scala
+++ b/src/library/scala/collection/mutable/Queue.scala
@@ -32,6 +32,7 @@ import generic._
*/
class Queue[A]
extends MutableList[A]
+ with LinearSeqOptimized[A, Queue[A]]
with GenericTraversableTemplate[A, Queue]
with Cloneable[Queue[A]]
with Serializable
@@ -165,6 +166,17 @@ extends MutableList[A]
* @return the first element.
*/
def front: A = head
+
+
+ // TODO - Don't override this just for new to create appropriate type....
+ override def tail: Queue[A] = {
+ require(nonEmpty, "tail of empty list")
+ val tl = new Queue[A]
+ tl.first0 = first0.tail
+ tl.last0 = last0
+ tl.len = len - 1
+ tl
+ }
}
diff --git a/src/library/scala/reflect/base/Base.scala b/src/library/scala/reflect/base/Base.scala
index 798e257d1e..28ebdf4377 100644
--- a/src/library/scala/reflect/base/Base.scala
+++ b/src/library/scala/reflect/base/Base.scala
@@ -487,6 +487,7 @@ class Base extends Universe { self =>
}
case object EmptyTree extends TermTree {
+ val asList = List(this)
override def isEmpty = true
}
diff --git a/src/reflect/scala/reflect/internal/Definitions.scala b/src/reflect/scala/reflect/internal/Definitions.scala
index fcbe7d0ed9..7fa098a328 100644
--- a/src/reflect/scala/reflect/internal/Definitions.scala
+++ b/src/reflect/scala/reflect/internal/Definitions.scala
@@ -137,9 +137,8 @@ trait Definitions extends api.StandardDefinitions {
lazy val BooleanTpe = BooleanClass.toTypeConstructor
lazy val ScalaNumericValueClasses = ScalaValueClasses filterNot Set[Symbol](UnitClass, BooleanClass)
-
- def ScalaValueClassesNoUnit = ScalaValueClasses filterNot (_ eq UnitClass)
- def ScalaValueClasses: List[ClassSymbol] = List(
+ lazy val ScalaValueClassesNoUnit = ScalaValueClasses filterNot (_ eq UnitClass)
+ lazy val ScalaValueClasses: List[ClassSymbol] = List(
UnitClass,
BooleanClass,
ByteClass,
diff --git a/src/reflect/scala/reflect/internal/Symbols.scala b/src/reflect/scala/reflect/internal/Symbols.scala
index d52afed28a..5da4942a89 100644
--- a/src/reflect/scala/reflect/internal/Symbols.scala
+++ b/src/reflect/scala/reflect/internal/Symbols.scala
@@ -294,14 +294,31 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
final def newExistential(name: TypeName, pos: Position = NoPosition, newFlags: Long = 0L): TypeSymbol =
newAbstractType(name, pos, EXISTENTIAL | newFlags)
- /** Synthetic value parameters when parameter symbols are not available
- */
- final def newSyntheticValueParamss(argtypess: List[List[Type]]): List[List[TermSymbol]] = {
+ private def freshNamer: () => TermName = {
var cnt = 0
- def freshName() = { cnt += 1; nme.syntheticParamName(cnt) }
- mmap(argtypess)(tp => newValueParameter(freshName(), owner.pos.focus, SYNTHETIC) setInfo tp)
+ () => { cnt += 1; nme.syntheticParamName(cnt) }
}
+ /** Synthetic value parameters when parameter symbols are not available
+ */
+ final def newSyntheticValueParamss(argtypess: List[List[Type]]): List[List[TermSymbol]] =
+ argtypess map (xs => newSyntheticValueParams(xs, freshNamer))
+
+ /** Synthetic value parameters when parameter symbols are not available.
+ * Calling this method multiple times will re-use the same parameter names.
+ */
+ final def newSyntheticValueParams(argtypes: List[Type]): List[TermSymbol] =
+ newSyntheticValueParams(argtypes, freshNamer)
+
+ final def newSyntheticValueParams(argtypes: List[Type], freshName: () => TermName): List[TermSymbol] =
+ argtypes map (tp => newSyntheticValueParam(tp, freshName()))
+
+ /** Synthetic value parameter when parameter symbol is not available.
+ * Calling this method multiple times will re-use the same parameter name.
+ */
+ final def newSyntheticValueParam(argtype: Type, name: TermName = nme.syntheticParamName(1)): TermSymbol =
+ newValueParameter(name, owner.pos.focus, SYNTHETIC) setInfo argtype
+
def newSyntheticTypeParam(): TypeSymbol = newSyntheticTypeParam("T0", 0L)
def newSyntheticTypeParam(name: String, newFlags: Long): TypeSymbol = newTypeParameter(newTypeName(name), NoPosition, newFlags) setInfo TypeBounds.empty
def newSyntheticTypeParams(num: Int): List[TypeSymbol] = (0 until num).toList map (n => newSyntheticTypeParam("T" + n, 0L))
@@ -328,18 +345,6 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
final def freshExistential(suffix: String): TypeSymbol =
newExistential(freshExistentialName(suffix), pos)
- /** Synthetic value parameters when parameter symbols are not available.
- * Calling this method multiple times will re-use the same parameter names.
- */
- final def newSyntheticValueParams(argtypes: List[Type]): List[TermSymbol] =
- newSyntheticValueParamss(List(argtypes)).head
-
- /** Synthetic value parameter when parameter symbol is not available.
- * Calling this method multiple times will re-use the same parameter name.
- */
- final def newSyntheticValueParam(argtype: Type): Symbol =
- newSyntheticValueParams(List(argtype)).head
-
/** Type skolems are type parameters ''seen from the inside''
* Assuming a polymorphic method m[T], its type is a PolyType which has a TypeParameter
* with name `T` in its typeParams list. While type checking the parameters, result type and
@@ -1522,7 +1527,7 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
def alternatives: List[Symbol] =
if (isOverloaded) info.asInstanceOf[OverloadedType].alternatives
- else List(this)
+ else this :: Nil
def filter(cond: Symbol => Boolean): Symbol =
if (isOverloaded) {
@@ -1626,7 +1631,7 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
(info.decls filter (_.isCaseAccessorMethod)).toList
final def constrParamAccessors: List[Symbol] =
- info.decls.toList filter (sym => !sym.isMethod && sym.isParamAccessor)
+ info.decls.filter(sym => !sym.isMethod && sym.isParamAccessor).toList
/** The symbol accessed by this accessor (getter or setter) function. */
final def accessed: Symbol = accessed(owner.info)
diff --git a/src/reflect/scala/reflect/internal/TreeGen.scala b/src/reflect/scala/reflect/internal/TreeGen.scala
index d160695e67..f953e9b757 100644
--- a/src/reflect/scala/reflect/internal/TreeGen.scala
+++ b/src/reflect/scala/reflect/internal/TreeGen.scala
@@ -194,7 +194,7 @@ abstract class TreeGen extends macros.TreeBuilder {
mkTypeApply(mkAttributedSelect(target, method), targs map TypeTree)
private def mkSingleTypeApply(value: Tree, tpe: Type, what: Symbol, wrapInApply: Boolean) = {
- val tapp = mkAttributedTypeApply(value, what, List(tpe.normalize))
+ val tapp = mkAttributedTypeApply(value, what, tpe.normalize :: Nil)
if (wrapInApply) Apply(tapp, Nil) else tapp
}
private def typeTestSymbol(any: Boolean) = if (any) Any_isInstanceOf else Object_isInstanceOf
diff --git a/src/reflect/scala/reflect/internal/TreeInfo.scala b/src/reflect/scala/reflect/internal/TreeInfo.scala
index 19f264f60e..5e3f0c2aee 100644
--- a/src/reflect/scala/reflect/internal/TreeInfo.scala
+++ b/src/reflect/scala/reflect/internal/TreeInfo.scala
@@ -521,20 +521,18 @@ abstract class TreeInfo {
*/
def noPredefImportForUnit(body: Tree) = {
// Top-level definition whose leading imports include Predef.
- def containsLeadingPredefImport(defs: List[Tree]): Boolean = defs match {
- case PackageDef(_, defs1) :: _ => containsLeadingPredefImport(defs1)
- case Import(expr, _) :: rest => isReferenceToPredef(expr) || containsLeadingPredefImport(rest)
- case _ => false
+ def isLeadingPredefImport(defn: Tree): Boolean = defn match {
+ case PackageDef(_, defs1) => defs1 exists isLeadingPredefImport
+ case Import(expr, _) => isReferenceToPredef(expr)
+ case _ => false
}
-
// Compilation unit is class or object 'name' in package 'scala'
def isUnitInScala(tree: Tree, name: Name) = tree match {
case PackageDef(Ident(nme.scala_), defs) => firstDefinesClassOrObject(defs, name)
case _ => false
}
- ( isUnitInScala(body, nme.Predef)
- || containsLeadingPredefImport(List(body)))
+ isUnitInScala(body, nme.Predef) || isLeadingPredefImport(body)
}
def isAbsTypeDef(tree: Tree) = tree match {
diff --git a/src/reflect/scala/reflect/internal/Trees.scala b/src/reflect/scala/reflect/internal/Trees.scala
index 3894870252..b21a28eea8 100644
--- a/src/reflect/scala/reflect/internal/Trees.scala
+++ b/src/reflect/scala/reflect/internal/Trees.scala
@@ -230,6 +230,7 @@ trait Trees extends api.Trees { self: SymbolTable =>
}
case object EmptyTree extends TermTree {
+ val asList = List(this)
super.tpe_=(NoType)
override def tpe_=(t: Type) =
if (t != NoType) throw new UnsupportedOperationException("tpe_=("+t+") inapplicable for <empty>")
@@ -290,7 +291,10 @@ trait Trees extends api.Trees { self: SymbolTable =>
object LabelDef extends LabelDefExtractor
case class ImportSelector(name: Name, namePos: Int, rename: Name, renamePos: Int) extends ImportSelectorApi
- object ImportSelector extends ImportSelectorExtractor
+ object ImportSelector extends ImportSelectorExtractor {
+ val wild = ImportSelector(nme.WILDCARD, -1, null, -1)
+ val wildList = List(wild)
+ }
case class Import(expr: Tree, selectors: List[ImportSelector])
extends SymTree with ImportApi
diff --git a/src/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala
index 50c857d6c1..9514898ce5 100644
--- a/src/reflect/scala/reflect/internal/Types.scala
+++ b/src/reflect/scala/reflect/internal/Types.scala
@@ -442,7 +442,7 @@ trait Types extends api.Types { self: SymbolTable =>
if (phase.erasedTypes) this
else {
val cowner = commonOwner(this)
- refinedType(List(this), cowner, EmptyScope, cowner.pos).narrow
+ refinedType(this :: Nil, cowner, EmptyScope, cowner.pos).narrow
}
/** For a TypeBounds type, itself;
@@ -1007,7 +1007,7 @@ trait Types extends api.Types { self: SymbolTable =>
if (!e.sym.hasFlag(excludedFlags)) {
if (sym == NoSymbol) sym = e.sym
else {
- if (alts.isEmpty) alts = List(sym)
+ if (alts.isEmpty) alts = sym :: Nil
alts = e.sym :: alts
}
}
diff --git a/src/reflect/scala/reflect/internal/util/Collections.scala b/src/reflect/scala/reflect/internal/util/Collections.scala
index 2ac0e64edd..14b5d3003d 100644
--- a/src/reflect/scala/reflect/internal/util/Collections.scala
+++ b/src/reflect/scala/reflect/internal/util/Collections.scala
@@ -69,7 +69,7 @@ trait Collections {
}
lb.toList
}
-
+
final def flatCollect[A, B](elems: List[A])(pf: PartialFunction[A, Traversable[B]]): List[B] = {
val lb = new ListBuffer[B]
for (x <- elems ; if pf isDefinedAt x)
@@ -104,7 +104,7 @@ trait Collections {
index += 1
}
}
-
+
// @inline
final def findOrElse[A](xs: TraversableOnce[A])(p: A => Boolean)(orElse: => A): A = {
xs find p getOrElse orElse
diff --git a/src/scalap/scala/tools/scalap/Main.scala b/src/scalap/scala/tools/scalap/Main.scala
index a8a9c65f63..49c272cc28 100644
--- a/src/scalap/scala/tools/scalap/Main.scala
+++ b/src/scalap/scala/tools/scalap/Main.scala
@@ -10,10 +10,10 @@ package scala.tools.scalap
import java.io.{ PrintStream, OutputStreamWriter, ByteArrayOutputStream }
import scala.reflect.NameTransformer
import scalax.rules.scalasig._
-import tools.nsc.util.{ ClassPath, JavaClassPath }
-import tools.util.PathResolver
+import scala.tools.nsc.util.{ ClassPath, JavaClassPath }
+import scala.tools.util.PathResolver
import ClassPath.DefaultJavaContext
-import tools.nsc.io.{ PlainFile, AbstractFile }
+import scala.tools.nsc.io.{ PlainFile, AbstractFile }
/**The main object used to execute scalap on the command-line.
*
diff --git a/test/files/neg/static-annot.scala b/test/files/neg/static-annot.scala
index c6c626d42b..c0b5ed30d8 100644
--- a/test/files/neg/static-annot.scala
+++ b/test/files/neg/static-annot.scala
@@ -45,3 +45,9 @@ class PrivateProtectedLazy {
println(PrivateProtectedLazy.baz)
println(PrivateProtectedLazy.bam)
}
+
+
+class StaticDef {
+ // this should not crash the compiler
+ @static def x = 42
+}
diff --git a/test/files/pos/t6208.scala b/test/files/pos/t6208.scala
new file mode 100644
index 0000000000..dac571346d
--- /dev/null
+++ b/test/files/pos/t6208.scala
@@ -0,0 +1,4 @@
+object Test {
+ val col = collection.mutable.Queue(1,2,3)
+ val WORK: collection.mutable.Queue[Int] = col filterNot (_ % 2 == 0)
+}
diff --git a/test/files/run/static-annot-repl.check b/test/files/run/static-annot-repl.check
new file mode 100644
index 0000000000..d1029a9809
--- /dev/null
+++ b/test/files/run/static-annot-repl.check
@@ -0,0 +1,32 @@
+Type in expressions to have them evaluated.
+Type :help for more information.
+
+scala>
+
+scala> import annotation.static
+import annotation.static
+
+scala> @static var x1 = 42
+x1: Int = 42
+
+scala> @static val x2 = 43
+x2: Int = 43
+
+scala> @static def x3 = 44
+x3: Int
+
+scala> x1
+res0: Int = 42
+
+scala> x2
+res1: Int = 43
+
+scala> x3
+res2: Int = 44
+
+scala> class Test {
+ @static def x = 42
+}
+defined class Test
+
+scala> \ No newline at end of file
diff --git a/test/files/run/static-annot-repl.scala b/test/files/run/static-annot-repl.scala
new file mode 100644
index 0000000000..1d2e9b2d7e
--- /dev/null
+++ b/test/files/run/static-annot-repl.scala
@@ -0,0 +1,22 @@
+
+
+
+import scala.tools.partest.ReplTest
+
+
+
+object Test extends ReplTest {
+ def code = """
+import annotation.static
+@static var x1 = 42
+@static val x2 = 43
+@static def x3 = 44
+x1
+x2
+x3
+class Test {
+ @static def x = 42
+}
+"""
+
+}
diff --git a/test/files/run/static-annot/field.scala b/test/files/run/static-annot/field.scala
index a7d8158321..8408a51800 100644
--- a/test/files/run/static-annot/field.scala
+++ b/test/files/run/static-annot/field.scala
@@ -23,8 +23,10 @@ class Foo
trait Check {
def checkStatic(cls: Class[_]) {
cls.getDeclaredFields.find(_.getName == "bar") match {
- case Some(f) => assert(Modifier.isStatic(f.getModifiers), "no static modifier")
- case None => assert(false, "no static field bar in class")
+ case Some(f) =>
+ assert(Modifier.isStatic(f.getModifiers), "no static modifier")
+ case None =>
+ assert(false, "no static field bar in class")
}
}
@@ -170,6 +172,10 @@ object Foo7 {
@static val bar = "string"
}
class AndHisFriend
+
+ object AndHisLonelyFriend {
+ @static val bar = "another"
+ }
}
@@ -177,6 +183,9 @@ object Test7 extends Check {
def test() {
checkStatic(classOf[Foo7.AndHisFriend])
assert(Foo7.AndHisFriend.bar == "string")
+
+ checkStatic(Class.forName("Foo7$AndHisLonelyFriend"))
+ assert(Foo7.AndHisLonelyFriend.bar == "another")
}
}
diff --git a/test/files/run/t6236.check b/test/files/run/t6236.check
new file mode 100644
index 0000000000..a0a2e88d0a
--- /dev/null
+++ b/test/files/run/t6236.check
@@ -0,0 +1,2 @@
+353
+353 \ No newline at end of file
diff --git a/test/files/run/t6236/file_1.scala b/test/files/run/t6236/file_1.scala
new file mode 100644
index 0000000000..92d22799fc
--- /dev/null
+++ b/test/files/run/t6236/file_1.scala
@@ -0,0 +1,9 @@
+
+
+package p {
+ object y {
+ object x {
+ @scala.annotation.static val foo: Int = 353
+ }
+ }
+}
diff --git a/test/files/run/t6236/file_2.scala b/test/files/run/t6236/file_2.scala
new file mode 100644
index 0000000000..51823004ca
--- /dev/null
+++ b/test/files/run/t6236/file_2.scala
@@ -0,0 +1,10 @@
+
+
+
+object Test {
+ def main(args: Array[String]): Unit = {
+ println(p.y.x.foo)
+ println(p.y.x.foo)
+ }
+}
+