diff options
Diffstat (limited to 'src')
497 files changed, 1719 insertions, 1322 deletions
diff --git a/src/build/genprod.scala b/src/build/genprod.scala index 8c91128de0..83a65e6876 100644 --- a/src/build/genprod.scala +++ b/src/build/genprod.scala @@ -6,6 +6,8 @@ ** |/ ** \* */ +import language.postfixOps + /** This program generates the ProductN, TupleN, FunctionN, * and AbstractFunctionN, where 0 <= N <= MAX_ARITY. * @@ -75,7 +77,7 @@ package %s if (args.length != 1) { println("please give path of output directory") - exit(-1) + sys.exit(-1) } val out = args(0) def writeFile(node: scala.xml.Node) { @@ -96,7 +98,7 @@ zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz */ object FunctionZero extends Function(0) { override def genprodString = "\n// genprod generated these sources at: " + new java.util.Date() - override def covariantSpecs = "@specialized " + override def covariantSpecs = "@specialized(Specializable.Primitives) " override def descriptiveComment = " " + functionNTemplate.format("javaVersion", "anonfun0", """ * val javaVersion = () => sys.props("java.version") @@ -111,8 +113,8 @@ object FunctionZero extends Function(0) { object FunctionOne extends Function(1) { override def classAnnotation = "@annotation.implicitNotFound(msg = \"No implicit view available from ${T1} => ${R}.\")\n" - override def contravariantSpecs = "@specialized(scala.Int, scala.Long, scala.Float, scala.Double, scala.AnyRef) " - override def covariantSpecs = "@specialized(scala.Unit, scala.Boolean, scala.Int, scala.Float, scala.Long, scala.Double, scala.AnyRef) " + override def contravariantSpecs = "@specialized(scala.Int, scala.Long, scala.Float, scala.Double/*, scala.AnyRef*/) " + override def covariantSpecs = "@specialized(scala.Unit, scala.Boolean, scala.Int, scala.Float, scala.Long, scala.Double/*, scala.AnyRef*/) " override def descriptiveComment = " " + functionNTemplate.format("succ", "anonfun1", """ @@ -169,7 +171,7 @@ object Function { class Function(val i: Int) extends Group("Function") with Arity { def descriptiveComment = "" - def functionNTemplate = + def functionNTemplate = """ * In the following example, the definition of %s is a * shorthand for the anonymous class definition %s: @@ -226,7 +228,7 @@ class Function(val i: Int) extends Group("Function") with Arity { } def tupleMethod = { - def comment = + def comment = """ /** Creates a tupled version of this function: instead of %d arguments, * it accepts a single [[scala.Tuple%d]] argument. * @@ -275,7 +277,7 @@ object TupleOne extends Tuple(1) object TupleTwo extends Tuple(2) { override def imports = Tuple.zipImports - override def covariantSpecs = "@specialized(Int, Long, Double, Char, Boolean, AnyRef) " + override def covariantSpecs = "@specialized(Int, Long, Double, Char, Boolean/*, AnyRef*/) " override def moreMethods = """ /** Swaps the elements of this `Tuple`. * @return a new Tuple where the first element is the second element of this Tuple and the diff --git a/src/compiler/scala/reflect/makro/runtime/AbortMacroException.scala b/src/compiler/scala/reflect/macros/runtime/AbortMacroException.scala index a68910859d..f45dde8a85 100644 --- a/src/compiler/scala/reflect/makro/runtime/AbortMacroException.scala +++ b/src/compiler/scala/reflect/macros/runtime/AbortMacroException.scala @@ -1,4 +1,4 @@ -package scala.reflect.makro +package scala.reflect.macros package runtime import scala.reflect.internal.util.Position diff --git a/src/compiler/scala/reflect/makro/runtime/Aliases.scala b/src/compiler/scala/reflect/macros/runtime/Aliases.scala index 760f7fc54d..8b742755cd 100644 --- a/src/compiler/scala/reflect/makro/runtime/Aliases.scala +++ b/src/compiler/scala/reflect/macros/runtime/Aliases.scala @@ -1,4 +1,4 @@ -package scala.reflect.makro +package scala.reflect.macros package runtime trait Aliases { diff --git a/src/compiler/scala/reflect/makro/runtime/CapturedVariables.scala b/src/compiler/scala/reflect/macros/runtime/CapturedVariables.scala index 021b93ceee..78fb7100b0 100644 --- a/src/compiler/scala/reflect/makro/runtime/CapturedVariables.scala +++ b/src/compiler/scala/reflect/macros/runtime/CapturedVariables.scala @@ -1,4 +1,4 @@ -package scala.reflect.makro +package scala.reflect.macros package runtime trait CapturedVariables { diff --git a/src/compiler/scala/reflect/makro/runtime/Context.scala b/src/compiler/scala/reflect/macros/runtime/Context.scala index 68964b7abb..8bbfef44a3 100644 --- a/src/compiler/scala/reflect/makro/runtime/Context.scala +++ b/src/compiler/scala/reflect/macros/runtime/Context.scala @@ -1,9 +1,9 @@ -package scala.reflect.makro +package scala.reflect.macros package runtime import scala.tools.nsc.Global -abstract class Context extends scala.reflect.makro.Context +abstract class Context extends scala.reflect.macros.Context with Aliases with CapturedVariables with Infrastructure diff --git a/src/compiler/scala/reflect/makro/runtime/Enclosures.scala b/src/compiler/scala/reflect/macros/runtime/Enclosures.scala index 360a4b8e8a..ebde4447d7 100644 --- a/src/compiler/scala/reflect/makro/runtime/Enclosures.scala +++ b/src/compiler/scala/reflect/macros/runtime/Enclosures.scala @@ -1,4 +1,4 @@ -package scala.reflect.makro +package scala.reflect.macros package runtime trait Enclosures { diff --git a/src/compiler/scala/reflect/makro/runtime/Evals.scala b/src/compiler/scala/reflect/macros/runtime/Evals.scala index 0574359a19..348e29cdd7 100644 --- a/src/compiler/scala/reflect/makro/runtime/Evals.scala +++ b/src/compiler/scala/reflect/macros/runtime/Evals.scala @@ -1,4 +1,4 @@ -package scala.reflect.makro +package scala.reflect.macros package runtime import scala.reflect.runtime.{universe => ru} diff --git a/src/compiler/scala/reflect/makro/runtime/ExprUtils.scala b/src/compiler/scala/reflect/macros/runtime/ExprUtils.scala index e301dfc2a4..672699f00e 100644 --- a/src/compiler/scala/reflect/makro/runtime/ExprUtils.scala +++ b/src/compiler/scala/reflect/macros/runtime/ExprUtils.scala @@ -1,4 +1,4 @@ -package scala.reflect.makro +package scala.reflect.macros package runtime trait ExprUtils { @@ -29,7 +29,7 @@ trait ExprUtils { def literal(x: Double) = Expr[Double](Literal(Constant(x)))(TypeTag.Double) - def literal(x: String) = Expr[String](Literal(Constant(x)))(TypeTag[String](definitions.StringClass.asTypeConstructor)) + def literal(x: String) = Expr[String](Literal(Constant(x)))(TypeTag[String](definitions.StringClass.toTypeConstructor)) def literal(x: Char) = Expr[Char](Literal(Constant(x)))(TypeTag.Char) } diff --git a/src/compiler/scala/reflect/makro/runtime/Exprs.scala b/src/compiler/scala/reflect/macros/runtime/Exprs.scala index b680b56bab..4217a6a404 100644 --- a/src/compiler/scala/reflect/makro/runtime/Exprs.scala +++ b/src/compiler/scala/reflect/macros/runtime/Exprs.scala @@ -1,4 +1,4 @@ -package scala.reflect.makro +package scala.reflect.macros package runtime trait Exprs { diff --git a/src/compiler/scala/reflect/makro/runtime/FrontEnds.scala b/src/compiler/scala/reflect/macros/runtime/FrontEnds.scala index 6644c579ac..69fa416f8f 100644 --- a/src/compiler/scala/reflect/makro/runtime/FrontEnds.scala +++ b/src/compiler/scala/reflect/macros/runtime/FrontEnds.scala @@ -1,4 +1,4 @@ -package scala.reflect.makro +package scala.reflect.macros package runtime trait FrontEnds extends scala.tools.reflect.FrontEnds { diff --git a/src/compiler/scala/reflect/makro/runtime/Infrastructure.scala b/src/compiler/scala/reflect/macros/runtime/Infrastructure.scala index 76c4b21731..19fb03364e 100644 --- a/src/compiler/scala/reflect/makro/runtime/Infrastructure.scala +++ b/src/compiler/scala/reflect/macros/runtime/Infrastructure.scala @@ -1,4 +1,4 @@ -package scala.reflect.makro +package scala.reflect.macros package runtime import scala.tools.nsc.util.ScalaClassLoader diff --git a/src/compiler/scala/reflect/makro/runtime/Names.scala b/src/compiler/scala/reflect/macros/runtime/Names.scala index 3f43b15d90..ee9f3a56d3 100644 --- a/src/compiler/scala/reflect/makro/runtime/Names.scala +++ b/src/compiler/scala/reflect/macros/runtime/Names.scala @@ -1,4 +1,4 @@ -package scala.reflect.makro +package scala.reflect.macros package runtime trait Names { diff --git a/src/compiler/scala/reflect/makro/runtime/Parsers.scala b/src/compiler/scala/reflect/macros/runtime/Parsers.scala index ac8d09f592..6d89b71f39 100644 --- a/src/compiler/scala/reflect/makro/runtime/Parsers.scala +++ b/src/compiler/scala/reflect/macros/runtime/Parsers.scala @@ -1,4 +1,4 @@ -package scala.reflect.makro +package scala.reflect.macros package runtime import language.existentials diff --git a/src/compiler/scala/reflect/makro/runtime/Reifiers.scala b/src/compiler/scala/reflect/macros/runtime/Reifiers.scala index 10b5ae5f42..ab1de4288b 100644 --- a/src/compiler/scala/reflect/makro/runtime/Reifiers.scala +++ b/src/compiler/scala/reflect/macros/runtime/Reifiers.scala @@ -1,9 +1,9 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Gilles Dubochet */ -package scala.reflect.makro +package scala.reflect.macros package runtime trait Reifiers { diff --git a/src/compiler/scala/reflect/makro/runtime/Settings.scala b/src/compiler/scala/reflect/macros/runtime/Settings.scala index 8288180b8d..9c24273cd7 100644 --- a/src/compiler/scala/reflect/makro/runtime/Settings.scala +++ b/src/compiler/scala/reflect/macros/runtime/Settings.scala @@ -1,13 +1,13 @@ -package scala.reflect.makro +package scala.reflect.macros package runtime trait Settings { self: Context => def settings: List[String] = { - val optionName = universe.settings.XmacroSettings.name - val settings = compilerSettings.find(opt => opt.startsWith(optionName)).map(opt => opt.substring(optionName.length + 1)).getOrElse("") - settings.split(",").toList + val us = universe.settings + import us._ + userSetSettings collectFirst { case x: MultiStringSetting if x.name == XmacroSettings.name => x.value } getOrElse Nil } def compilerSettings: List[String] = universe.settings.recreateArgs @@ -33,4 +33,4 @@ trait Settings { try op finally setCompilerSettings(old) } -}
\ No newline at end of file +} diff --git a/src/compiler/scala/reflect/makro/runtime/Traces.scala b/src/compiler/scala/reflect/macros/runtime/Traces.scala index 225ee1f62b..0238e9f84e 100644 --- a/src/compiler/scala/reflect/makro/runtime/Traces.scala +++ b/src/compiler/scala/reflect/macros/runtime/Traces.scala @@ -1,4 +1,4 @@ -package scala.reflect.makro +package scala.reflect.macros package runtime trait Traces extends util.Traces { diff --git a/src/compiler/scala/reflect/makro/runtime/TypeTags.scala b/src/compiler/scala/reflect/macros/runtime/TypeTags.scala index 4f9b287674..2bc2fe6384 100644 --- a/src/compiler/scala/reflect/makro/runtime/TypeTags.scala +++ b/src/compiler/scala/reflect/macros/runtime/TypeTags.scala @@ -1,4 +1,4 @@ -package scala.reflect.makro +package scala.reflect.macros package runtime trait TypeTags { diff --git a/src/compiler/scala/reflect/makro/runtime/Typers.scala b/src/compiler/scala/reflect/macros/runtime/Typers.scala index e43b0459ea..9fa8567ada 100644 --- a/src/compiler/scala/reflect/makro/runtime/Typers.scala +++ b/src/compiler/scala/reflect/macros/runtime/Typers.scala @@ -1,4 +1,4 @@ -package scala.reflect.makro +package scala.reflect.macros package runtime trait Typers { @@ -37,7 +37,7 @@ trait Typers { def inferImplicitView(tree: Tree, from: Type, to: Type, silent: Boolean = true, withMacrosDisabled: Boolean = false, pos: Position = enclosingPosition): Tree = { macroLogVerbose("inferring implicit view from %s to %s for %s, macros = %s".format(from, to, tree, !withMacrosDisabled)) - val viewTpe = universe.appliedType(universe.definitions.FunctionClass(1).asTypeConstructor, List(from, to)) + val viewTpe = universe.appliedType(universe.definitions.FunctionClass(1).toTypeConstructor, List(from, to)) inferImplicit(tree, viewTpe, isView = true, silent = silent, withMacrosDisabled = withMacrosDisabled, pos = pos) } diff --git a/src/compiler/scala/reflect/makro/util/Traces.scala b/src/compiler/scala/reflect/macros/util/Traces.scala index 2363cc4bac..6c2f115994 100644 --- a/src/compiler/scala/reflect/makro/util/Traces.scala +++ b/src/compiler/scala/reflect/macros/util/Traces.scala @@ -1,4 +1,4 @@ -package scala.reflect.makro +package scala.reflect.macros package util trait Traces { diff --git a/src/compiler/scala/reflect/reify/Errors.scala b/src/compiler/scala/reflect/reify/Errors.scala index 1b72b3075b..5e15c5ad3a 100644 --- a/src/compiler/scala/reflect/reify/Errors.scala +++ b/src/compiler/scala/reflect/reify/Errors.scala @@ -1,7 +1,7 @@ package scala.reflect.reify -import scala.reflect.makro.ReificationError -import scala.reflect.makro.UnexpectedReificationError +import scala.reflect.macros.ReificationError +import scala.reflect.macros.UnexpectedReificationError trait Errors { self: Reifier => diff --git a/src/compiler/scala/reflect/reify/Reifier.scala b/src/compiler/scala/reflect/reify/Reifier.scala index 8fba7274be..53e01309cb 100644 --- a/src/compiler/scala/reflect/reify/Reifier.scala +++ b/src/compiler/scala/reflect/reify/Reifier.scala @@ -1,8 +1,8 @@ package scala.reflect.reify import scala.tools.nsc.Global -import scala.reflect.makro.ReificationError -import scala.reflect.makro.UnexpectedReificationError +import scala.reflect.macros.ReificationError +import scala.reflect.macros.UnexpectedReificationError import scala.reflect.reify.utils.Utils /** Given a tree or a type, generate a tree that when executed at runtime produces the original tree or type. @@ -115,7 +115,7 @@ abstract class Reifier extends States // todo. maybe try `resetLocalAttrs` once the dust settles var importantSymbols = Set[Symbol]( NothingClass, AnyClass, SingletonClass, PredefModule, ScalaRunTimeModule, TypeCreatorClass, TreeCreatorClass, MirrorOfClass, - BaseUniverseClass, ApiUniverseClass, JavaUniverseClass, ReflectRuntimePackage, ReflectRuntimeCurrentMirror) + BaseUniverseClass, JavaUniverseClass, ReflectRuntimePackage, ReflectRuntimeCurrentMirror) importantSymbols ++= importantSymbols map (_.companionSymbol) importantSymbols ++= importantSymbols map (_.moduleClass) importantSymbols ++= importantSymbols map (_.linkedClassOfClass) diff --git a/src/compiler/scala/reflect/reify/Taggers.scala b/src/compiler/scala/reflect/reify/Taggers.scala index 4e30d0acf8..a8523fe686 100644 --- a/src/compiler/scala/reflect/reify/Taggers.scala +++ b/src/compiler/scala/reflect/reify/Taggers.scala @@ -1,7 +1,7 @@ package scala.reflect.reify -import scala.reflect.makro.{ReificationError, UnexpectedReificationError} -import scala.reflect.makro.runtime.Context +import scala.reflect.macros.{ReificationError, UnexpectedReificationError} +import scala.reflect.macros.runtime.Context abstract class Taggers { val c: Context diff --git a/src/compiler/scala/reflect/reify/codegen/GenSymbols.scala b/src/compiler/scala/reflect/reify/codegen/GenSymbols.scala index 38c8fedac5..59651bcdf9 100644 --- a/src/compiler/scala/reflect/reify/codegen/GenSymbols.scala +++ b/src/compiler/scala/reflect/reify/codegen/GenSymbols.scala @@ -36,7 +36,7 @@ trait GenSymbols { else if (sym.isEmptyPackageClass) mirrorMirrorSelect(nme.EmptyPackageClass) else if (sym.isModuleClass) - Select(Select(reify(sym.sourceModule), nme.asModuleSymbol), nme.moduleClass) + Select(Select(reify(sym.sourceModule), nme.asModule), nme.moduleClass) else if (sym.isPackage) mirrorMirrorCall(nme.staticPackage, reify(sym.fullName)) else if (sym.isLocatable) { diff --git a/src/compiler/scala/reflect/reify/codegen/GenTypes.scala b/src/compiler/scala/reflect/reify/codegen/GenTypes.scala index c49e5b3342..c762a28f99 100644 --- a/src/compiler/scala/reflect/reify/codegen/GenTypes.scala +++ b/src/compiler/scala/reflect/reify/codegen/GenTypes.scala @@ -30,7 +30,7 @@ trait GenTypes { val tsym = tpe.typeSymbolDirect if (tsym.isClass && tpe == tsym.typeConstructor && tsym.isStatic) - Select(Select(reify(tsym), nme.asTypeSymbol), nme.asTypeConstructor) + Select(Select(reify(tsym), nme.asType), nme.toTypeConstructor) else tpe match { case tpe @ NoType => reifyMirrorObject(tpe) @@ -42,7 +42,7 @@ trait GenTypes { mirrorBuildCall(nme.thisPrefix, mirrorMirrorSelect(nme.EmptyPackageClass)) case tpe @ ThisType(clazz) if clazz.isModuleClass && clazz.isStatic => val module = reify(clazz.sourceModule) - val moduleClass = Select(Select(module, nme.asModuleSymbol), nme.moduleClass) + val moduleClass = Select(Select(module, nme.asModule), nme.moduleClass) mirrorFactoryCall(nme.ThisType, moduleClass) case tpe @ ThisType(_) => reifyProduct(tpe) @@ -94,7 +94,7 @@ trait GenTypes { } case success => if (reifyDebug) println("implicit search has produced a result: " + success) - state.reificationIsConcrete &= concrete || success.tpe <:< TypeTagClass.asTypeConstructor + state.reificationIsConcrete &= concrete || success.tpe <:< TypeTagClass.toTypeConstructor Select(Apply(Select(success, nme.in), List(Ident(nme.MIRROR_SHORT))), nme.tpe) } if (result != EmptyTree) return result @@ -109,7 +109,7 @@ trait GenTypes { def searchForManifest(typer: analyzer.Typer): Tree = analyzer.inferImplicit( EmptyTree, - appliedType(FullManifestClass.asTypeConstructor, List(tpe)), + appliedType(FullManifestClass.toTypeConstructor, List(tpe)), reportAmbiguous = false, isView = false, context = typer.context, diff --git a/src/compiler/scala/reflect/reify/package.scala b/src/compiler/scala/reflect/reify/package.scala index 80011368a8..a253effc1c 100644 --- a/src/compiler/scala/reflect/reify/package.scala +++ b/src/compiler/scala/reflect/reify/package.scala @@ -1,9 +1,8 @@ package scala.reflect import language.implicitConversions -import language.experimental.macros import scala.reflect.base.{Universe => BaseUniverse} -import scala.reflect.makro.{Context, ReificationError, UnexpectedReificationError} +import scala.reflect.macros.{Context, ReificationError, UnexpectedReificationError} import scala.tools.nsc.Global package object reify { @@ -29,7 +28,7 @@ package object reify { import definitions._ val enclosingErasure = reifyEnclosingRuntimeClass(global)(typer0) // JavaUniverse is defined in scala-reflect.jar, so we must be very careful in case someone reifies stuff having only scala-library.jar on the classpath - val isJavaUniverse = JavaUniverseClass != NoSymbol && universe.tpe <:< JavaUniverseClass.asTypeConstructor + val isJavaUniverse = JavaUniverseClass != NoSymbol && universe.tpe <:< JavaUniverseClass.toTypeConstructor if (isJavaUniverse && !enclosingErasure.isEmpty) Apply(Select(universe, nme.runtimeMirror), List(Select(enclosingErasure, sn.GetClassLoader))) else Select(universe, nme.rootMirror) } @@ -69,7 +68,7 @@ package object reify { if (isThisInScope) { val enclosingClasses = typer0.context.enclosingContextChain map (_.tree) collect { case classDef: ClassDef => classDef } val classInScope = enclosingClasses.headOption getOrElse EmptyTree - if (!classInScope.isEmpty) reifyRuntimeClass(global)(typer0, classInScope.symbol.asTypeConstructor, concrete = true) + if (!classInScope.isEmpty) reifyRuntimeClass(global)(typer0, classInScope.symbol.toTypeConstructor, concrete = true) else Select(This(tpnme.EMPTY), sn.GetClass) } else EmptyTree } diff --git a/src/compiler/scala/reflect/reify/utils/Extractors.scala b/src/compiler/scala/reflect/reify/utils/Extractors.scala index 86265ec77a..ebe3957e69 100644 --- a/src/compiler/scala/reflect/reify/utils/Extractors.scala +++ b/src/compiler/scala/reflect/reify/utils/Extractors.scala @@ -20,11 +20,6 @@ trait Extractors { // () // }; // def apply[U >: Nothing <: scala.reflect.base.Universe with Singleton]($m$untyped: scala.reflect.base.MirrorOf[U]): U#Tree = { - // val $u: scala.reflect.api.Universe = $m$untyped.universe.asInstanceOf[scala.reflect.api.Universe]; - // val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror]; - // applyImpl($m).asInstanceOf[U#Tree]; - // } - // def applyImpl[U >: Nothing <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.base.MirrorOf[U]): U#Tree = { // val $u: U = $m$untyped.universe; // val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror]; // $u.Apply($u.Select($u.Select($u.build.This($m.staticPackage("scala.collection.immutable").moduleClass), $u.newTermName("List")), $u.newTermName("apply")), List($u.Literal($u.Constant(1)), $u.Literal($u.Constant(2)))) @@ -40,7 +35,7 @@ trait Extractors { // def apply[U >: Nothing <: scala.reflect.base.Universe with Singleton]($m$untyped: scala.reflect.base.MirrorOf[U]): U#Type = { // val $u: U = $m$untyped.universe; // val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror]; - // $u.TypeRef($u.ThisType($m.staticPackage("scala.collection.immutable").moduleClass), $m.staticClass("scala.collection.immutable.List"), List($m.staticClass("scala.Int").asTypeConstructor)) + // $u.TypeRef($u.ThisType($m.staticPackage("scala.collection.immutable").moduleClass), $m.staticClass("scala.collection.immutable.List"), List($m.staticClass("scala.Int").toTypeConstructor)) // } // }; // new $typecreator1() @@ -51,23 +46,7 @@ trait Extractors { val tparamu = newTypeName("U") val (reifierBase, reifierName, reifierTpt, reifierUniverse) = flavor match { case tpnme.REIFY_TYPECREATOR_PREFIX => (TypeCreatorClass, nme.apply, SelectFromTypeTree(Ident(tparamu), tpnme.Type), BaseUniverseClass) - case tpnme.REIFY_TREECREATOR_PREFIX => (TreeCreatorClass, nme.applyImpl, SelectFromTypeTree(Ident(BaseUniverseClass), tpnme.Tree), ApiUniverseClass) - case _ => throw new Error(s"unexpected flavor $flavor") - } - val reifierPreamble = flavor match { - case tpnme.REIFY_TYPECREATOR_PREFIX => Nil - case tpnme.REIFY_TREECREATOR_PREFIX => List[Tree]( - DefDef(NoMods, - nme.apply, - List(TypeDef(Modifiers(PARAM), tparamu, List(), TypeBoundsTree(Ident(NothingClass), CompoundTypeTree(Template(List(Ident(BaseUniverseClass), Ident(SingletonClass)), emptyValDef, List()))))), - List(List(ValDef(Modifiers(PARAM), nme.MIRROR_UNTYPED, AppliedTypeTree(Ident(MirrorOfClass), List(Ident(tparamu))), EmptyTree))), - SelectFromTypeTree(Ident(tparamu), tpnme.Tree), - Block( - ValDef(NoMods, nme.UNIVERSE_SHORT, Ident(ApiUniverseClass), TypeApply(Select(Select(Ident(nme.MIRROR_UNTYPED), nme.universe), nme.asInstanceOf_), List(Ident(ApiUniverseClass)))), - ValDef(NoMods, nme.MIRROR_SHORT, Select(Ident(nme.UNIVERSE_SHORT), tpnme.Mirror), TypeApply(Select(Ident(nme.MIRROR_UNTYPED), nme.asInstanceOf_), List(Select(Ident(nme.UNIVERSE_SHORT), tpnme.Mirror)))), - TypeApply(Select(Apply(TypeApply(Ident(reifierName), List(SingletonTypeTree(Ident(nme.UNIVERSE_SHORT)))), List(Ident(nme.MIRROR_SHORT))), nme.asInstanceOf_), List(SelectFromTypeTree(Ident(tparamu), tpnme.Tree))) - )) - ) + case tpnme.REIFY_TREECREATOR_PREFIX => (TreeCreatorClass, nme.apply, SelectFromTypeTree(Ident(tparamu), tpnme.Tree), BaseUniverseClass) case _ => throw new Error(s"unexpected flavor $flavor") } val reifierBody = { @@ -98,8 +77,7 @@ trait Extractors { Template(List(Ident(reifierBase)), emptyValDef, List( - DefDef(NoMods, nme.CONSTRUCTOR, List(), List(List()), TypeTree(), Block(List(Apply(Select(Super(This(tpnme.EMPTY), tpnme.EMPTY), nme.CONSTRUCTOR), List())), Literal(Constant(())))) - ) ++ reifierPreamble ++ List( + DefDef(NoMods, nme.CONSTRUCTOR, List(), List(List()), TypeTree(), Block(List(Apply(Select(Super(This(tpnme.EMPTY), tpnme.EMPTY), nme.CONSTRUCTOR), List())), Literal(Constant(())))), DefDef(NoMods, reifierName, List(TypeDef(Modifiers(PARAM), tparamu, List(), TypeBoundsTree(Ident(NothingClass), CompoundTypeTree(Template(List(Ident(reifierUniverse), Ident(SingletonClass)), emptyValDef, List()))))), @@ -128,7 +106,7 @@ trait Extractors { case Block( List(udef @ ValDef(_, _, _, universe), mdef @ ValDef(_, _, _, mirror)), Apply( - Apply(TypeApply(_, List(ttpe @ TypeTree())), List(_, Block(List(ClassDef(_, _, _, Template(_, _, List(_, _, DefDef(_, _, _, _, _, Block(_ :: _ :: symbolTable1, rtree)))))), _))), + Apply(TypeApply(_, List(ttpe @ TypeTree())), List(_, Block(List(ClassDef(_, _, _, Template(_, _, List(_, DefDef(_, _, _, _, _, Block(_ :: _ :: symbolTable1, rtree)))))), _))), // todo. doesn't take into account optimizations such as $u.TypeTag.Int or the upcoming closure optimization List(Apply(TypeApply(tagFactory @ Select(_, _), _), List(_, Block(List(ClassDef(_, _, _, Template(_, _, List(_, DefDef(_, _, _, _, _, Block(_ :: _ :: symbolTable2, rtpe)))))), _)))))) if udef.name == nme.UNIVERSE_SHORT && mdef.name == nme.MIRROR_SHORT => diff --git a/src/compiler/scala/reflect/reify/utils/NodePrinters.scala b/src/compiler/scala/reflect/reify/utils/NodePrinters.scala index 6394e1eac2..420f55c0e0 100644 --- a/src/compiler/scala/reflect/reify/utils/NodePrinters.scala +++ b/src/compiler/scala/reflect/reify/utils/NodePrinters.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ package scala.reflect.reify diff --git a/src/compiler/scala/tools/ant/templates/tool-unix.tmpl b/src/compiler/scala/tools/ant/templates/tool-unix.tmpl index 256b5088e9..4f0646c6fb 100644 --- a/src/compiler/scala/tools/ant/templates/tool-unix.tmpl +++ b/src/compiler/scala/tools/ant/templates/tool-unix.tmpl @@ -1,7 +1,7 @@ #!/usr/bin/env bash # ############################################################################## -# Copyright 2002-2011, LAMP/EPFL +# Copyright 2002-2012 LAMP/EPFL # # This is free software; see the distribution for copying conditions. # There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A diff --git a/src/compiler/scala/tools/ant/templates/tool-windows.tmpl b/src/compiler/scala/tools/ant/templates/tool-windows.tmpl index 5949689b24..3c0d1d77ca 100644 --- a/src/compiler/scala/tools/ant/templates/tool-windows.tmpl +++ b/src/compiler/scala/tools/ant/templates/tool-windows.tmpl @@ -1,7 +1,7 @@ @@echo off
rem ##########################################################################
-rem # Copyright 2002-2011, LAMP/EPFL
+rem # Copyright 2002-2012 LAMP/EPFL
rem #
rem # This is free software; see the distribution for copying conditions.
rem # There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
diff --git a/src/compiler/scala/tools/cmd/CommandLine.scala b/src/compiler/scala/tools/cmd/CommandLine.scala index ced3a97380..1359274748 100644 --- a/src/compiler/scala/tools/cmd/CommandLine.scala +++ b/src/compiler/scala/tools/cmd/CommandLine.scala @@ -1,5 +1,5 @@ /* NEST (New Scala Test) - * Copyright 2007-2011 LAMP/EPFL + * Copyright 2007-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/cmd/Demo.scala b/src/compiler/scala/tools/cmd/Demo.scala index 61d63eb246..439c21e4a0 100644 --- a/src/compiler/scala/tools/cmd/Demo.scala +++ b/src/compiler/scala/tools/cmd/Demo.scala @@ -1,5 +1,5 @@ /* NEST (New Scala Test) - * Copyright 2007-2011 LAMP/EPFL + * Copyright 2007-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/cmd/FromString.scala b/src/compiler/scala/tools/cmd/FromString.scala index d473796f39..d4b828fd0a 100644 --- a/src/compiler/scala/tools/cmd/FromString.scala +++ b/src/compiler/scala/tools/cmd/FromString.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/cmd/Instance.scala b/src/compiler/scala/tools/cmd/Instance.scala index c22294aed5..966211805e 100644 --- a/src/compiler/scala/tools/cmd/Instance.scala +++ b/src/compiler/scala/tools/cmd/Instance.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/cmd/Interpolation.scala b/src/compiler/scala/tools/cmd/Interpolation.scala index f08ebe0e1a..e9cf37761a 100644 --- a/src/compiler/scala/tools/cmd/Interpolation.scala +++ b/src/compiler/scala/tools/cmd/Interpolation.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/cmd/Meta.scala b/src/compiler/scala/tools/cmd/Meta.scala index d06586e25c..98d5e1f953 100644 --- a/src/compiler/scala/tools/cmd/Meta.scala +++ b/src/compiler/scala/tools/cmd/Meta.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/cmd/Opt.scala b/src/compiler/scala/tools/cmd/Opt.scala index 3c494134db..b5633f6e03 100644 --- a/src/compiler/scala/tools/cmd/Opt.scala +++ b/src/compiler/scala/tools/cmd/Opt.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/cmd/Parser.scala b/src/compiler/scala/tools/cmd/Parser.scala index 46204c172a..9e7c9b7805 100644 --- a/src/compiler/scala/tools/cmd/Parser.scala +++ b/src/compiler/scala/tools/cmd/Parser.scala @@ -1,5 +1,5 @@ /* NEST (New Scala Test) - * Copyright 2007-2011 LAMP/EPFL + * Copyright 2007-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/cmd/Property.scala b/src/compiler/scala/tools/cmd/Property.scala index 8df8c66d72..aae5bebcc8 100644 --- a/src/compiler/scala/tools/cmd/Property.scala +++ b/src/compiler/scala/tools/cmd/Property.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/cmd/Reference.scala b/src/compiler/scala/tools/cmd/Reference.scala index 204ca22b69..77fe01051e 100644 --- a/src/compiler/scala/tools/cmd/Reference.scala +++ b/src/compiler/scala/tools/cmd/Reference.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/cmd/Spec.scala b/src/compiler/scala/tools/cmd/Spec.scala index 929f52673a..d503cb7cb7 100644 --- a/src/compiler/scala/tools/cmd/Spec.scala +++ b/src/compiler/scala/tools/cmd/Spec.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/cmd/gen/AnyVals.scala b/src/compiler/scala/tools/cmd/gen/AnyVals.scala index 9d0795b2f6..7842603af7 100644 --- a/src/compiler/scala/tools/cmd/gen/AnyVals.scala +++ b/src/compiler/scala/tools/cmd/gen/AnyVals.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2007-2011 LAMP/EPFL + * Copyright 2007-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/cmd/gen/Codegen.scala b/src/compiler/scala/tools/cmd/gen/Codegen.scala index 59b58563d1..b94c640f1c 100644 --- a/src/compiler/scala/tools/cmd/gen/Codegen.scala +++ b/src/compiler/scala/tools/cmd/gen/Codegen.scala @@ -1,5 +1,5 @@ /* NEST (New Scala Test) - * Copyright 2007-2011 LAMP/EPFL + * Copyright 2007-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/cmd/gen/CodegenSpec.scala b/src/compiler/scala/tools/cmd/gen/CodegenSpec.scala index 7f4b9c1bb0..cca1627a69 100644 --- a/src/compiler/scala/tools/cmd/gen/CodegenSpec.scala +++ b/src/compiler/scala/tools/cmd/gen/CodegenSpec.scala @@ -1,5 +1,5 @@ /* NEST (New Scala Test) - * Copyright 2007-2011 LAMP/EPFL + * Copyright 2007-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/cmd/package.scala b/src/compiler/scala/tools/cmd/package.scala index 8e74e6169e..5be98a460a 100644 --- a/src/compiler/scala/tools/cmd/package.scala +++ b/src/compiler/scala/tools/cmd/package.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/CompilationUnits.scala b/src/compiler/scala/tools/nsc/CompilationUnits.scala index 54b114bf82..6d3fd2e09e 100644 --- a/src/compiler/scala/tools/nsc/CompilationUnits.scala +++ b/src/compiler/scala/tools/nsc/CompilationUnits.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/CompileClient.scala b/src/compiler/scala/tools/nsc/CompileClient.scala index dc65bf780e..af6d2b1536 100644 --- a/src/compiler/scala/tools/nsc/CompileClient.scala +++ b/src/compiler/scala/tools/nsc/CompileClient.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/CompileServer.scala b/src/compiler/scala/tools/nsc/CompileServer.scala index fb278db2bf..d26828650f 100644 --- a/src/compiler/scala/tools/nsc/CompileServer.scala +++ b/src/compiler/scala/tools/nsc/CompileServer.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/CompileSocket.scala b/src/compiler/scala/tools/nsc/CompileSocket.scala index 7d2abd42fd..2dd17025ad 100644 --- a/src/compiler/scala/tools/nsc/CompileSocket.scala +++ b/src/compiler/scala/tools/nsc/CompileSocket.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/CompilerCommand.scala b/src/compiler/scala/tools/nsc/CompilerCommand.scala index 4c8a27083a..eb8a93f33d 100644 --- a/src/compiler/scala/tools/nsc/CompilerCommand.scala +++ b/src/compiler/scala/tools/nsc/CompilerCommand.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/CompilerRun.scala b/src/compiler/scala/tools/nsc/CompilerRun.scala index e6428235e2..278ccdd5a5 100644 --- a/src/compiler/scala/tools/nsc/CompilerRun.scala +++ b/src/compiler/scala/tools/nsc/CompilerRun.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/ConsoleWriter.scala b/src/compiler/scala/tools/nsc/ConsoleWriter.scala index c06db8f0b8..0d25fa9306 100644 --- a/src/compiler/scala/tools/nsc/ConsoleWriter.scala +++ b/src/compiler/scala/tools/nsc/ConsoleWriter.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2006-2011 LAMP/EPFL + * Copyright 2006-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/EvalLoop.scala b/src/compiler/scala/tools/nsc/EvalLoop.scala index 5cbd79839a..da03419d8a 100644 --- a/src/compiler/scala/tools/nsc/EvalLoop.scala +++ b/src/compiler/scala/tools/nsc/EvalLoop.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/GenericRunnerCommand.scala b/src/compiler/scala/tools/nsc/GenericRunnerCommand.scala index 836d22192c..c953824bf7 100644 --- a/src/compiler/scala/tools/nsc/GenericRunnerCommand.scala +++ b/src/compiler/scala/tools/nsc/GenericRunnerCommand.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2007 LAMP/EPFL + * Copyright 2007-2012 LAMP/EPFL * @author Lex Spoon */ diff --git a/src/compiler/scala/tools/nsc/GenericRunnerSettings.scala b/src/compiler/scala/tools/nsc/GenericRunnerSettings.scala index f91cb854c6..b2f27d1925 100644 --- a/src/compiler/scala/tools/nsc/GenericRunnerSettings.scala +++ b/src/compiler/scala/tools/nsc/GenericRunnerSettings.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2006-2011 LAMP/EPFL + * Copyright 2006-2012 LAMP/EPFL * @author Lex Spoon */ diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index 83335c4f62..2b0f082051 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/Main.scala b/src/compiler/scala/tools/nsc/Main.scala index 8b7e76e994..3f9d91a23f 100644 --- a/src/compiler/scala/tools/nsc/Main.scala +++ b/src/compiler/scala/tools/nsc/Main.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/MainBench.scala b/src/compiler/scala/tools/nsc/MainBench.scala index 0037de7b94..48465ba316 100644 --- a/src/compiler/scala/tools/nsc/MainBench.scala +++ b/src/compiler/scala/tools/nsc/MainBench.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/MainGenericRunner.scala b/src/compiler/scala/tools/nsc/MainGenericRunner.scala index cc1139f8a7..bb8a1d11a6 100644 --- a/src/compiler/scala/tools/nsc/MainGenericRunner.scala +++ b/src/compiler/scala/tools/nsc/MainGenericRunner.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2006-2011 LAMP/EPFL + * Copyright 2006-2012 LAMP/EPFL * @author Lex Spoon */ @@ -58,6 +58,10 @@ class MainGenericRunner { def isI = !settings.loadfiles.isDefault def dashi = settings.loadfiles.value + // Deadlocks on startup under -i unless we disable async. + if (isI) + settings.Yreplsync.value = true + def combinedCode = { val files = if (isI) dashi map (file => File(file).slurp()) else Nil val str = if (isE) List(dashe) else Nil diff --git a/src/compiler/scala/tools/nsc/MainTokenMetric.scala b/src/compiler/scala/tools/nsc/MainTokenMetric.scala index 5373638f5b..11d5f4209e 100644 --- a/src/compiler/scala/tools/nsc/MainTokenMetric.scala +++ b/src/compiler/scala/tools/nsc/MainTokenMetric.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/NewLinePrintWriter.scala b/src/compiler/scala/tools/nsc/NewLinePrintWriter.scala index 94df5020c2..6517637620 100644 --- a/src/compiler/scala/tools/nsc/NewLinePrintWriter.scala +++ b/src/compiler/scala/tools/nsc/NewLinePrintWriter.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/ObjectRunner.scala b/src/compiler/scala/tools/nsc/ObjectRunner.scala index 24ae0089a2..3401431ba9 100644 --- a/src/compiler/scala/tools/nsc/ObjectRunner.scala +++ b/src/compiler/scala/tools/nsc/ObjectRunner.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Lex Spoon */ diff --git a/src/compiler/scala/tools/nsc/OfflineCompilerCommand.scala b/src/compiler/scala/tools/nsc/OfflineCompilerCommand.scala index 6d6b99e53e..282de02aba 100644 --- a/src/compiler/scala/tools/nsc/OfflineCompilerCommand.scala +++ b/src/compiler/scala/tools/nsc/OfflineCompilerCommand.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/PhaseAssembly.scala b/src/compiler/scala/tools/nsc/PhaseAssembly.scala index a9e029e485..e69382be21 100644 --- a/src/compiler/scala/tools/nsc/PhaseAssembly.scala +++ b/src/compiler/scala/tools/nsc/PhaseAssembly.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2007-2011 LAMP/EPFL + * Copyright 2007-2012 LAMP/EPFL * @author Anders Bach Nielsen * @version 1.0 */ diff --git a/src/compiler/scala/tools/nsc/Phases.scala b/src/compiler/scala/tools/nsc/Phases.scala index 896fcb3ca1..d2274b108b 100644 --- a/src/compiler/scala/tools/nsc/Phases.scala +++ b/src/compiler/scala/tools/nsc/Phases.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/Properties.scala b/src/compiler/scala/tools/nsc/Properties.scala index c83ccfeef1..701d0c8ac4 100644 --- a/src/compiler/scala/tools/nsc/Properties.scala +++ b/src/compiler/scala/tools/nsc/Properties.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2006-2011 LAMP/EPFL + * Copyright 2006-2012 LAMP/EPFL * @author Stephane Micheloud */ diff --git a/src/compiler/scala/tools/nsc/ScalaDoc.scala b/src/compiler/scala/tools/nsc/ScalaDoc.scala index c6fdb4b891..ea37307ff3 100644 --- a/src/compiler/scala/tools/nsc/ScalaDoc.scala +++ b/src/compiler/scala/tools/nsc/ScalaDoc.scala @@ -1,5 +1,5 @@ /* scaladoc, a documentation generator for Scala - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky * @author Geoffrey Washburn */ diff --git a/src/compiler/scala/tools/nsc/ScriptRunner.scala b/src/compiler/scala/tools/nsc/ScriptRunner.scala index 14c508548a..d64396bec7 100644 --- a/src/compiler/scala/tools/nsc/ScriptRunner.scala +++ b/src/compiler/scala/tools/nsc/ScriptRunner.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/Settings.scala b/src/compiler/scala/tools/nsc/Settings.scala index d57d5546fa..7c062a57bb 100644 --- a/src/compiler/scala/tools/nsc/Settings.scala +++ b/src/compiler/scala/tools/nsc/Settings.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/SubComponent.scala b/src/compiler/scala/tools/nsc/SubComponent.scala index a3e451f32f..fc3316fb7f 100644 --- a/src/compiler/scala/tools/nsc/SubComponent.scala +++ b/src/compiler/scala/tools/nsc/SubComponent.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/ast/DocComments.scala b/src/compiler/scala/tools/nsc/ast/DocComments.scala index d0d0b4b5f4..8526920cd7 100755 --- a/src/compiler/scala/tools/nsc/ast/DocComments.scala +++ b/src/compiler/scala/tools/nsc/ast/DocComments.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/ast/NodePrinters.scala b/src/compiler/scala/tools/nsc/ast/NodePrinters.scala index 4afd3545b9..1fdf4c631e 100644 --- a/src/compiler/scala/tools/nsc/ast/NodePrinters.scala +++ b/src/compiler/scala/tools/nsc/ast/NodePrinters.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/ast/Printers.scala b/src/compiler/scala/tools/nsc/ast/Printers.scala index 94d0c4f45e..8b92f0acd6 100644 --- a/src/compiler/scala/tools/nsc/ast/Printers.scala +++ b/src/compiler/scala/tools/nsc/ast/Printers.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala b/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala index e02d605965..043834ae55 100644 --- a/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala +++ b/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/ast/TreeDSL.scala b/src/compiler/scala/tools/nsc/ast/TreeDSL.scala index 91935854f4..2ee38d4b91 100644 --- a/src/compiler/scala/tools/nsc/ast/TreeDSL.scala +++ b/src/compiler/scala/tools/nsc/ast/TreeDSL.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/ast/TreeGen.scala b/src/compiler/scala/tools/nsc/ast/TreeGen.scala index be5909a67f..ca8a377c6f 100644 --- a/src/compiler/scala/tools/nsc/ast/TreeGen.scala +++ b/src/compiler/scala/tools/nsc/ast/TreeGen.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ @@ -72,8 +72,6 @@ abstract class TreeGen extends reflect.internal.TreeGen with TreeDSL { Annotated(Ident(nme.synthSwitch), expr) } - def hasSynthCaseSymbol(t: Tree) = (t.symbol ne null) && (t.symbol hasFlag (CASE | SYNTHETIC)) - // TODO: would be so much nicer if we would know during match-translation (i.e., type checking) // whether we should emit missingCase-style apply (and isDefinedAt), instead of transforming trees post-factum class MatchMatcher { @@ -94,13 +92,13 @@ abstract class TreeGen extends reflect.internal.TreeGen with TreeDSL { case Apply(Apply(TypeApply(Select(tgt, nme.runOrElse), targs), List(scrut)), List(matcher)) if opt.virtPatmat => // println("virt match: "+ (tgt, targs, scrut, matcher) + "for:\n"+ matchExpr ) caseVirtualizedMatch(matchExpr, tgt, targs, scrut, matcher) // optimized version of virtpatmat - case Block(stats, matchEndDef) if opt.virtPatmat && (stats forall hasSynthCaseSymbol) => + case Block(stats, matchEndDef) if opt.virtPatmat && (stats forall treeInfo.hasSynthCaseSymbol) => // the assumption is once we encounter a case, the remainder of the block will consist of cases // the prologue may be empty, usually it is the valdef that stores the scrut val (prologue, cases) = stats span (s => !s.isInstanceOf[LabelDef]) caseVirtualizedMatchOpt(matchExpr, prologue, cases, matchEndDef, identity) // optimized version of virtpatmat - case Block(outerStats, orig@Block(stats, matchEndDef)) if opt.virtPatmat && (stats forall hasSynthCaseSymbol) => + case Block(outerStats, orig@Block(stats, matchEndDef)) if opt.virtPatmat && (stats forall treeInfo.hasSynthCaseSymbol) => val (prologue, cases) = stats span (s => !s.isInstanceOf[LabelDef]) caseVirtualizedMatchOpt(matchExpr, prologue, cases, matchEndDef, m => copyBlock(matchExpr, outerStats, m)) case other => diff --git a/src/compiler/scala/tools/nsc/ast/TreeInfo.scala b/src/compiler/scala/tools/nsc/ast/TreeInfo.scala index 569cb4977b..e755553e25 100644 --- a/src/compiler/scala/tools/nsc/ast/TreeInfo.scala +++ b/src/compiler/scala/tools/nsc/ast/TreeInfo.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/ast/Trees.scala b/src/compiler/scala/tools/nsc/ast/Trees.scala index 9a6d32be01..381b834a0c 100644 --- a/src/compiler/scala/tools/nsc/ast/Trees.scala +++ b/src/compiler/scala/tools/nsc/ast/Trees.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/ast/parser/BracePair.scala b/src/compiler/scala/tools/nsc/ast/parser/BracePair.scala index 9ec51c3758..a079763aa2 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/BracePair.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/BracePair.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ package scala.tools.nsc diff --git a/src/compiler/scala/tools/nsc/ast/parser/BracePatch.scala b/src/compiler/scala/tools/nsc/ast/parser/BracePatch.scala index 73c8a94a99..28df4ab7ef 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/BracePatch.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/BracePatch.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ package scala.tools.nsc diff --git a/src/compiler/scala/tools/nsc/ast/parser/Change.scala b/src/compiler/scala/tools/nsc/ast/parser/Change.scala index 9b8ed0dfd5..d5eec5c676 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Change.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Change.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ package scala.tools.nsc.ast.parser diff --git a/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala b/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala index 12b39d9e9c..991ee39258 100755 --- a/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Burak Emir */ diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala index cde971085d..391874c488 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/ast/parser/Patch.scala b/src/compiler/scala/tools/nsc/ast/parser/Patch.scala index cee8be2716..9880ca9148 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Patch.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Patch.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ package scala.tools.nsc.ast.parser diff --git a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala index 7ccd6785bb..f99b9a66c9 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ package scala.tools.nsc diff --git a/src/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala b/src/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala index a4b45482de..5afec611e9 100755 --- a/src/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Burak Emir */ diff --git a/src/compiler/scala/tools/nsc/ast/parser/SyntaxAnalyzer.scala b/src/compiler/scala/tools/nsc/ast/parser/SyntaxAnalyzer.scala index e310611e68..2ea34ff532 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/SyntaxAnalyzer.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/SyntaxAnalyzer.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/ast/parser/Tokens.scala b/src/compiler/scala/tools/nsc/ast/parser/Tokens.scala index a4a062609b..7e7972f9dd 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Tokens.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Tokens.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala index 90f9d538c1..ab856f09b8 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/backend/JavaPlatform.scala b/src/compiler/scala/tools/nsc/backend/JavaPlatform.scala index 80b0f640a4..ef020175c4 100644 --- a/src/compiler/scala/tools/nsc/backend/JavaPlatform.scala +++ b/src/compiler/scala/tools/nsc/backend/JavaPlatform.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/backend/MSILPlatform.scala b/src/compiler/scala/tools/nsc/backend/MSILPlatform.scala index f4176c46b8..90b6df635e 100644 --- a/src/compiler/scala/tools/nsc/backend/MSILPlatform.scala +++ b/src/compiler/scala/tools/nsc/backend/MSILPlatform.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/backend/Platform.scala b/src/compiler/scala/tools/nsc/backend/Platform.scala index f770713093..bff4b54446 100644 --- a/src/compiler/scala/tools/nsc/backend/Platform.scala +++ b/src/compiler/scala/tools/nsc/backend/Platform.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/backend/ScalaPrimitives.scala b/src/compiler/scala/tools/nsc/backend/ScalaPrimitives.scala index aab944f65a..5e3ba5d355 100644 --- a/src/compiler/scala/tools/nsc/backend/ScalaPrimitives.scala +++ b/src/compiler/scala/tools/nsc/backend/ScalaPrimitives.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/backend/WorklistAlgorithm.scala b/src/compiler/scala/tools/nsc/backend/WorklistAlgorithm.scala index d6fab2eb63..c6d9f8713a 100644 --- a/src/compiler/scala/tools/nsc/backend/WorklistAlgorithm.scala +++ b/src/compiler/scala/tools/nsc/backend/WorklistAlgorithm.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala b/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala index 86533c713e..3f0cef6703 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/backend/icode/CheckerException.scala b/src/compiler/scala/tools/nsc/backend/icode/CheckerException.scala index 0a7a155970..feb1939827 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/CheckerException.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/CheckerException.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/backend/icode/ExceptionHandlers.scala b/src/compiler/scala/tools/nsc/backend/icode/ExceptionHandlers.scala index ffc6640743..62b25ad069 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/ExceptionHandlers.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/ExceptionHandlers.scala @@ -1,5 +1,5 @@ /* NSC -- new scala compiler - * Copyright 2005 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala index c46b650949..a480429026 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/backend/icode/ICodeCheckers.scala b/src/compiler/scala/tools/nsc/backend/icode/ICodeCheckers.scala index 8f7fdab64c..0d688d51f2 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/ICodeCheckers.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/ICodeCheckers.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/backend/icode/ICodes.scala b/src/compiler/scala/tools/nsc/backend/icode/ICodes.scala index 631b71d83a..81fd285cdb 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/ICodes.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/ICodes.scala @@ -1,9 +1,9 @@ /* NSC -- new scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ /* NSC -- new scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/backend/icode/Linearizers.scala b/src/compiler/scala/tools/nsc/backend/icode/Linearizers.scala index f71c8de449..1c5c9224f2 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/Linearizers.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/Linearizers.scala @@ -1,5 +1,5 @@ /* NSC -- new scala compiler - * Copyright 2005 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/backend/icode/Members.scala b/src/compiler/scala/tools/nsc/backend/icode/Members.scala index 00f4a9d262..8f475a4198 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/Members.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/Members.scala @@ -1,5 +1,5 @@ /* NSC -- new scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ @@ -170,6 +170,7 @@ trait Members { var sourceFile: SourceFile = NoSourceFile var returnType: TypeKind = _ var recursive: Boolean = false + var bytecodeHasEHs = false // set by ICodeReader only, used by Inliner to prevent inlining (SI-6188) /** local variables and method parameters */ var locals: List[Local] = Nil diff --git a/src/compiler/scala/tools/nsc/backend/icode/Opcodes.scala b/src/compiler/scala/tools/nsc/backend/icode/Opcodes.scala index 13457bfe58..4311fe9df5 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/Opcodes.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/Opcodes.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/backend/icode/Primitives.scala b/src/compiler/scala/tools/nsc/backend/icode/Primitives.scala index 72220184d2..3e4b453fd8 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/Primitives.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/Primitives.scala @@ -1,5 +1,5 @@ /* NSC -- new scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/backend/icode/Printers.scala b/src/compiler/scala/tools/nsc/backend/icode/Printers.scala index d34d93f147..bcffb23b40 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/Printers.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/Printers.scala @@ -1,5 +1,5 @@ /* NSC -- new scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/backend/icode/Repository.scala b/src/compiler/scala/tools/nsc/backend/icode/Repository.scala index 663b626bef..4e06b96d2a 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/Repository.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/Repository.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala b/src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala index 1ec2cf017a..0cacce10f9 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/backend/icode/TypeStacks.scala b/src/compiler/scala/tools/nsc/backend/icode/TypeStacks.scala index 8a2ec9a191..041c597b0c 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/TypeStacks.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/TypeStacks.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/CopyPropagation.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/CopyPropagation.scala index 4427da92c8..d1d8e4a385 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/analysis/CopyPropagation.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/CopyPropagation.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/DataFlowAnalysis.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/DataFlowAnalysis.scala index 9f43e1b84c..74745fe6fc 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/analysis/DataFlowAnalysis.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/DataFlowAnalysis.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/Liveness.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/Liveness.scala index 5f261ba05e..38d4cd414f 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/analysis/Liveness.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/Liveness.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/LubException.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/LubException.scala index ec0553209f..8a9104044f 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/analysis/LubException.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/LubException.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/ProgramPoint.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/ProgramPoint.scala index a8c69eb71a..19e6b16283 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/analysis/ProgramPoint.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/ProgramPoint.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/ReachingDefinitions.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/ReachingDefinitions.scala index 69de0dfa90..6f9302c97b 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/analysis/ReachingDefinitions.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/ReachingDefinitions.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/SemiLattice.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/SemiLattice.scala index cfce0878ed..8a1b411451 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/analysis/SemiLattice.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/SemiLattice.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala index 962c47f443..6bd3ac5791 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ @@ -736,7 +736,13 @@ abstract class TypeFlowAnalysis { val succs = point.successors filter relevantBBs succs foreach { p => assert((p.predecessors filter isOnPerimeter).isEmpty) - val updated = lattice.lub(List(output, in(p)), p.exceptionHandlerStart) + val existing = in(p) + // TODO move the following assertion to typeFlowLattice.lub2 for wider applicability (ie MethodTFA in addition to MTFAGrowable). + assert(existing == lattice.bottom || + p.exceptionHandlerStart || + (output.stack.length == existing.stack.length), + "Trying to merge non-bottom type-stacks with different stack heights. For a possible cause see SI-6157.") + val updated = lattice.lub(List(output, existing), p.exceptionHandlerStart) if(updated != in(p)) { in(p) = updated enqueue(p) diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BytecodeWriters.scala b/src/compiler/scala/tools/nsc/backend/jvm/BytecodeWriters.scala index ff68aba845..485864d8e3 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/BytecodeWriters.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/BytecodeWriters.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala index f681de93b6..194ceca504 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ @@ -932,7 +932,6 @@ abstract class GenASM extends SubComponent with BytecodeWriters { ca } - // TODO this method isn't exercised during bootstrapping. Open question: is it bug free? private def arrEncode(sb: ScalaSigBytes): Array[String] = { var strs: List[String] = Nil val bSeven: Array[Byte] = sb.sevenBitsMayBeZero @@ -941,14 +940,15 @@ abstract class GenASM extends SubComponent with BytecodeWriters { var offset = 0 var encLength = 0 while(offset < bSeven.size) { - val newEncLength = encLength.toLong + (if(bSeven(offset) == 0) 2 else 1) - if(newEncLength > 65535) { + val deltaEncLength = (if(bSeven(offset) == 0) 2 else 1) + val newEncLength = encLength.toLong + deltaEncLength + if(newEncLength >= 65535) { val ba = bSeven.slice(prevOffset, offset) strs ::= new java.lang.String(ubytesToCharArray(ba)) encLength = 0 prevOffset = offset } else { - encLength += 1 + encLength += deltaEncLength offset += 1 } } @@ -1173,6 +1173,8 @@ abstract class GenASM extends SubComponent with BytecodeWriters { debuglog("No forwarder for '%s' from %s to '%s'".format(m, jclassName, moduleClass)) else if (conflictingNames(m.name)) log("No forwarder for " + m + " due to conflict with " + linkedClass.info.member(m.name)) + else if (m.hasAccessBoundary) + log(s"No forwarder for non-public member $m") else { log("Adding static forwarder for '%s' from %s to '%s'".format(m, jclassName, moduleClass)) if (m.isAccessor && m.accessed.hasStaticAnnotation) { @@ -2565,6 +2567,19 @@ abstract class GenASM extends SubComponent with BytecodeWriters { case JUMP(whereto) => if (nextBlock != whereto) { jcode goTo labels(whereto) + } else if(m.exh.exists(eh => eh.covers(b))) { + // SI-6102: Determine whether eliding this JUMP results in an empty range being covered by some EH. + // If so, emit a NOP in place of the elided JUMP, to avoid "java.lang.ClassFormatError: Illegal exception table range" + val isSthgLeft = b.toList.exists { + case _: LOAD_EXCEPTION => false + case _: SCOPE_ENTER => false + case _: SCOPE_EXIT => false + case _: JUMP => false + case _ => true + } + if(!isSthgLeft) { + emit(asm.Opcodes.NOP) + } } case CJUMP(success, failure, cond, kind) => diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenAndroid.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenAndroid.scala index e3da5c486b..78bab15724 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenAndroid.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenAndroid.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Stephane Micheloud */ diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala index 0ae2adac84..bad4ecc647 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Iulian Dragos */ diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenJVMUtil.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenJVMUtil.scala index 807a3dd0bb..edcdd8f434 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenJVMUtil.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenJVMUtil.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Iulian Dragos */ diff --git a/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala b/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala index d23571b517..465a0c61e8 100644 --- a/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala +++ b/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala @@ -1,5 +1,5 @@ /* NSC -- new scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Nikolay Mihaylov */ diff --git a/src/compiler/scala/tools/nsc/backend/opt/ClosureElimination.scala b/src/compiler/scala/tools/nsc/backend/opt/ClosureElimination.scala index ff45bb8fd1..7772ccbdd5 100644 --- a/src/compiler/scala/tools/nsc/backend/opt/ClosureElimination.scala +++ b/src/compiler/scala/tools/nsc/backend/opt/ClosureElimination.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Iulian Dragos */ diff --git a/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala b/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala index 5cc6e78e9d..fd949576e1 100644 --- a/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala +++ b/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala @@ -1,5 +1,5 @@ /* NSC -- new scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Iulian Dragos */ diff --git a/src/compiler/scala/tools/nsc/backend/opt/InlineExceptionHandlers.scala b/src/compiler/scala/tools/nsc/backend/opt/InlineExceptionHandlers.scala index 0d47352215..f1f597322e 100644 --- a/src/compiler/scala/tools/nsc/backend/opt/InlineExceptionHandlers.scala +++ b/src/compiler/scala/tools/nsc/backend/opt/InlineExceptionHandlers.scala @@ -1,5 +1,5 @@ /* NSC -- new scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL */ package scala.tools.nsc diff --git a/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala b/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala index cce18d436f..d87a242f1b 100644 --- a/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala +++ b/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Iulian Dragos */ @@ -247,7 +247,7 @@ abstract class Inliners extends SubComponent { debuglog("Analyzing " + cls) this.currentIClazz = cls - val ms = cls.methods filterNot { _.symbol.isConstructor } sorted imethodOrdering + val ms = cls.methods sorted imethodOrdering ms foreach { im => if(hasInline(im.symbol)) { log("Not inlining into " + im.symbol.originalName.decode + " because it is marked @inline.") @@ -405,6 +405,12 @@ abstract class Inliners extends SubComponent { val inc = new IMethodInfo(callee) val pair = new CallerCalleeInfo(caller, inc, fresh, inlinedMethodCount) + if(inc.hasHandlers && (stackLength == -1)) { + // no inlining is done, yet don't warn about it, stackLength == -1 indicates we're trying to inlineWithoutTFA. + // Shortly, a TFA will be computed and an error message reported if indeed inlining not possible. + return false + } + (pair isStampedForInlining stackLength) match { case inlInfo if inlInfo.isSafe => @@ -605,7 +611,7 @@ abstract class Inliners extends SubComponent { def isSmall = (length <= SMALL_METHOD_SIZE) && blocks(0).length < 10 def isLarge = length > MAX_INLINE_SIZE def isRecursive = m.recursive - def hasHandlers = handlers.nonEmpty + def hasHandlers = handlers.nonEmpty || m.bytecodeHasEHs def isSynchronized = sym.hasFlag(Flags.SYNCHRONIZED) def hasNonFinalizerHandler = handlers exists { @@ -941,6 +947,7 @@ abstract class Inliners extends SubComponent { if(inc.isRecursive) { rs ::= "is recursive" } if(isInlineForbidden) { rs ::= "is annotated @noinline" } if(inc.isSynchronized) { rs ::= "is synchronized method" } + if(inc.m.bytecodeHasEHs) { rs ::= "bytecode contains exception handlers / finally clause" } // SI-6188 if(rs.isEmpty) null else rs.mkString("", ", and ", "") } @@ -974,6 +981,10 @@ abstract class Inliners extends SubComponent { return DontInlineHere("too low score (heuristics)") } + if(inc.hasHandlers && (stackLength > inc.minimumStack)) { + return DontInlineHere("callee contains exception handlers / finally clause, and is invoked with non-empty operand stack") // SI-6157 + } + if(isKnownToInlineSafely) { return InlineableAtThisCaller } if(stackLength > inc.minimumStack && inc.hasNonFinalizerHandler) { diff --git a/src/compiler/scala/tools/nsc/doc/DocFactory.scala b/src/compiler/scala/tools/nsc/doc/DocFactory.scala index 27a03d5381..cd0c242f22 100644 --- a/src/compiler/scala/tools/nsc/doc/DocFactory.scala +++ b/src/compiler/scala/tools/nsc/doc/DocFactory.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2007-2011 LAMP/EPFL + * Copyright 2007-2012 LAMP/EPFL * @author David Bernard, Manohar Jonnalagedda */ diff --git a/src/compiler/scala/tools/nsc/doc/DocParser.scala b/src/compiler/scala/tools/nsc/doc/DocParser.scala index 119a2c06e9..4726f1cc2c 100644 --- a/src/compiler/scala/tools/nsc/doc/DocParser.scala +++ b/src/compiler/scala/tools/nsc/doc/DocParser.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/doc/Index.scala b/src/compiler/scala/tools/nsc/doc/Index.scala index b0ca23fea6..7b0bdac2d1 100644 --- a/src/compiler/scala/tools/nsc/doc/Index.scala +++ b/src/compiler/scala/tools/nsc/doc/Index.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/doc/Settings.scala b/src/compiler/scala/tools/nsc/doc/Settings.scala index ad178b8158..720b1347ef 100644 --- a/src/compiler/scala/tools/nsc/doc/Settings.scala +++ b/src/compiler/scala/tools/nsc/doc/Settings.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/doc/Uncompilable.scala b/src/compiler/scala/tools/nsc/doc/Uncompilable.scala index fef753b12c..7e57f9fd9f 100644 --- a/src/compiler/scala/tools/nsc/doc/Uncompilable.scala +++ b/src/compiler/scala/tools/nsc/doc/Uncompilable.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/doc/Universe.scala b/src/compiler/scala/tools/nsc/doc/Universe.scala index fe0ef71680..0a91301500 100644 --- a/src/compiler/scala/tools/nsc/doc/Universe.scala +++ b/src/compiler/scala/tools/nsc/doc/Universe.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/doc/html/Doclet.scala b/src/compiler/scala/tools/nsc/doc/html/Doclet.scala index 5b722b5dd1..c18cc521f3 100644 --- a/src/compiler/scala/tools/nsc/doc/html/Doclet.scala +++ b/src/compiler/scala/tools/nsc/doc/html/Doclet.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2007-2011 LAMP/EPFL + * Copyright 2007-2012 LAMP/EPFL * @author David Bernard, Manohar Jonnalagedda */ diff --git a/src/compiler/scala/tools/nsc/doc/html/HtmlFactory.scala b/src/compiler/scala/tools/nsc/doc/html/HtmlFactory.scala index 436425df83..845de1a23c 100644 --- a/src/compiler/scala/tools/nsc/doc/html/HtmlFactory.scala +++ b/src/compiler/scala/tools/nsc/doc/html/HtmlFactory.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2007-2011 LAMP/EPFL + * Copyright 2007-2012 LAMP/EPFL * @author David Bernard, Manohar Jonnalagedda */ diff --git a/src/compiler/scala/tools/nsc/doc/html/HtmlPage.scala b/src/compiler/scala/tools/nsc/doc/html/HtmlPage.scala index aa2df57967..7a74c569f3 100644 --- a/src/compiler/scala/tools/nsc/doc/html/HtmlPage.scala +++ b/src/compiler/scala/tools/nsc/doc/html/HtmlPage.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2007-2011 LAMP/EPFL + * Copyright 2007-2012 LAMP/EPFL * @author David Bernard, Manohar Jonnalagedda */ diff --git a/src/compiler/scala/tools/nsc/doc/html/Page.scala b/src/compiler/scala/tools/nsc/doc/html/Page.scala index d30ca5dc08..baeb9e40ed 100644 --- a/src/compiler/scala/tools/nsc/doc/html/Page.scala +++ b/src/compiler/scala/tools/nsc/doc/html/Page.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2007-2011 LAMP/EPFL + * Copyright 2007-2012 LAMP/EPFL * @author David Bernard, Manohar Jonnalagedda */ diff --git a/src/compiler/scala/tools/nsc/doc/html/SyntaxHigh.scala b/src/compiler/scala/tools/nsc/doc/html/SyntaxHigh.scala index 629ac84b34..f1eab841f9 100644 --- a/src/compiler/scala/tools/nsc/doc/html/SyntaxHigh.scala +++ b/src/compiler/scala/tools/nsc/doc/html/SyntaxHigh.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2010-2011 LAMP/EPFL + * Copyright 2010-2012 LAMP/EPFL * @author Stephane Micheloud */ diff --git a/src/compiler/scala/tools/nsc/doc/html/page/Index.scala b/src/compiler/scala/tools/nsc/doc/html/page/Index.scala index b15d602b57..21c5dc1c25 100644 --- a/src/compiler/scala/tools/nsc/doc/html/page/Index.scala +++ b/src/compiler/scala/tools/nsc/doc/html/page/Index.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2007-2011 LAMP/EPFL + * Copyright 2007-2012 LAMP/EPFL * @author David Bernard, Manohar Jonnalagedda */ diff --git a/src/compiler/scala/tools/nsc/doc/html/page/IndexScript.scala b/src/compiler/scala/tools/nsc/doc/html/page/IndexScript.scala index a37dd3fb8b..3a45b9fbcd 100644 --- a/src/compiler/scala/tools/nsc/doc/html/page/IndexScript.scala +++ b/src/compiler/scala/tools/nsc/doc/html/page/IndexScript.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2007-2011 LAMP/EPFL + * Copyright 2007-2012 LAMP/EPFL * @author David Bernard, Manohar Jonnalagedda */ diff --git a/src/compiler/scala/tools/nsc/doc/html/page/ReferenceIndex.scala b/src/compiler/scala/tools/nsc/doc/html/page/ReferenceIndex.scala index effaee711d..6d83b4e6a5 100755 --- a/src/compiler/scala/tools/nsc/doc/html/page/ReferenceIndex.scala +++ b/src/compiler/scala/tools/nsc/doc/html/page/ReferenceIndex.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2007-2011 LAMP/EPFL + * Copyright 2007-2012 LAMP/EPFL * @author Pedro Furlanetto */ diff --git a/src/compiler/scala/tools/nsc/doc/html/page/Source.scala b/src/compiler/scala/tools/nsc/doc/html/page/Source.scala index 7914daa9d5..a51d66c6cc 100644 --- a/src/compiler/scala/tools/nsc/doc/html/page/Source.scala +++ b/src/compiler/scala/tools/nsc/doc/html/page/Source.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2007-2011 LAMP/EPFL + * Copyright 2007-2012 LAMP/EPFL * @author David Bernard, Manohar Jonnalagedda */ diff --git a/src/compiler/scala/tools/nsc/doc/html/page/Template.scala b/src/compiler/scala/tools/nsc/doc/html/page/Template.scala index 422ea5ef1c..5977acc0c2 100644 --- a/src/compiler/scala/tools/nsc/doc/html/page/Template.scala +++ b/src/compiler/scala/tools/nsc/doc/html/page/Template.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2007-2011 LAMP/EPFL + * Copyright 2007-2012 LAMP/EPFL * @author David Bernard, Manohar Jonnalagedda */ @@ -264,7 +264,7 @@ class Template(universe: doc.Universe, generator: DiagramGenerator, tpl: DocTemp { if (Set("epfl", "EPFL").contains(tpl.universe.settings.docfooter.value)) - <div id="footer">Scala programming documentation. Copyright (c) 2003-2011 <a href="http://www.epfl.ch" target="_top">EPFL</a>, with contributions from <a href="http://typesafe.com" target="_top">Typesafe</a>.</div> + <div id="footer">Scala programming documentation. Copyright (c) 2003-2012 <a href="http://www.epfl.ch" target="_top">EPFL</a>, with contributions from <a href="http://typesafe.com" target="_top">Typesafe</a>.</div> else <div id="footer"> { tpl.universe.settings.docfooter.value } </div> } diff --git a/src/compiler/scala/tools/nsc/doc/model/Entity.scala b/src/compiler/scala/tools/nsc/doc/model/Entity.scala index 16ade0787e..46b2a11d4a 100644 --- a/src/compiler/scala/tools/nsc/doc/model/Entity.scala +++ b/src/compiler/scala/tools/nsc/doc/model/Entity.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2007-2011 LAMP/EPFL + * Copyright 2007-2012 LAMP/EPFL * @author Manohar Jonnalagedda * @author Gilles Dubochet */ diff --git a/src/compiler/scala/tools/nsc/doc/model/IndexModelFactory.scala b/src/compiler/scala/tools/nsc/doc/model/IndexModelFactory.scala index 9d141efe0a..6ad3ddf438 100755 --- a/src/compiler/scala/tools/nsc/doc/model/IndexModelFactory.scala +++ b/src/compiler/scala/tools/nsc/doc/model/IndexModelFactory.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2007-2011 LAMP/EPFL + * Copyright 2007-2012 LAMP/EPFL * @author Pedro Furlanetto */ diff --git a/src/compiler/scala/tools/nsc/doc/model/LinkTo.scala b/src/compiler/scala/tools/nsc/doc/model/LinkTo.scala index b76dee0f14..664567872e 100644 --- a/src/compiler/scala/tools/nsc/doc/model/LinkTo.scala +++ b/src/compiler/scala/tools/nsc/doc/model/LinkTo.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2007-2011 LAMP/EPFL + * Copyright 2007-2012 LAMP/EPFL */ package scala.tools.nsc diff --git a/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala b/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala index 00e6f3769e..a962ec4007 100644 --- a/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala +++ b/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala @@ -1,4 +1,4 @@ -/* NSC -- new Scala compiler -- Copyright 2007-2011 LAMP/EPFL */ +/* NSC -- new Scala compiler -- Copyright 2007-2012 LAMP/EPFL */ package scala.tools.nsc package doc @@ -380,7 +380,7 @@ class ModelFactory(val global: Global, val settings: doc.Settings) { if (settings.docImplicits.value) makeImplicitConversions(sym, this) else Nil // members as given by the compiler - lazy val memberSyms = sym.info.members.filter(s => membersShouldDocument(s, this)) + lazy val memberSyms = sym.info.members.filter(s => membersShouldDocument(s, this)).toList // the inherited templates (classes, traits or objects) var memberSymsLazy = memberSyms.filter(t => templateShouldDocument(t, this) && !inOriginalOwner(t, this)) @@ -712,7 +712,7 @@ class ModelFactory(val global: Global, val settings: doc.Settings) { override def inheritedFrom = Nil override def isRootPackage = true override lazy val memberSyms = - (bSym.info.members ++ EmptyPackage.info.members) filter { s => + (bSym.info.members ++ EmptyPackage.info.members).toList filter { s => s != EmptyPackage && s != RootPackage } }) diff --git a/src/compiler/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala b/src/compiler/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala index a12b67c9ed..5a0cc602e5 100644 --- a/src/compiler/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala +++ b/src/compiler/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala @@ -386,7 +386,7 @@ trait ModelFactoryImplicitSupport { lazy val memberImpls: List[MemberImpl] = { // Obtain the members inherited by the implicit conversion - val memberSyms = toType.members.filter(implicitShouldDocument(_)) + val memberSyms = toType.members.filter(implicitShouldDocument(_)).toList val existingSyms = sym.info.members // Debugging part :) diff --git a/src/compiler/scala/tools/nsc/doc/model/ModelFactoryTypeSupport.scala b/src/compiler/scala/tools/nsc/doc/model/ModelFactoryTypeSupport.scala index d2a26d1309..6c80c85efe 100644 --- a/src/compiler/scala/tools/nsc/doc/model/ModelFactoryTypeSupport.scala +++ b/src/compiler/scala/tools/nsc/doc/model/ModelFactoryTypeSupport.scala @@ -1,4 +1,4 @@ -/* NSC -- new Scala compiler -- Copyright 2007-2011 LAMP/EPFL */ +/* NSC -- new Scala compiler -- Copyright 2007-2012 LAMP/EPFL */ package scala.tools.nsc package doc diff --git a/src/compiler/scala/tools/nsc/doc/model/TreeEntity.scala b/src/compiler/scala/tools/nsc/doc/model/TreeEntity.scala index 23a4e17a9a..e12afebbf8 100644 --- a/src/compiler/scala/tools/nsc/doc/model/TreeEntity.scala +++ b/src/compiler/scala/tools/nsc/doc/model/TreeEntity.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2007-2011 LAMP/EPFL + * Copyright 2007-2012 LAMP/EPFL * @author Chris James */ diff --git a/src/compiler/scala/tools/nsc/doc/model/TypeEntity.scala b/src/compiler/scala/tools/nsc/doc/model/TypeEntity.scala index 643067cca5..9b23971395 100644 --- a/src/compiler/scala/tools/nsc/doc/model/TypeEntity.scala +++ b/src/compiler/scala/tools/nsc/doc/model/TypeEntity.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2007-2011 LAMP/EPFL + * Copyright 2007-2012 LAMP/EPFL * @author Manohar Jonnalagedda */ diff --git a/src/compiler/scala/tools/nsc/doc/model/ValueArgument.scala b/src/compiler/scala/tools/nsc/doc/model/ValueArgument.scala index 781ff113fb..8f26114fbd 100644 --- a/src/compiler/scala/tools/nsc/doc/model/ValueArgument.scala +++ b/src/compiler/scala/tools/nsc/doc/model/ValueArgument.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2007-2011 LAMP/EPFL + * Copyright 2007-2012 LAMP/EPFL * @author Gilles Dubochet */ diff --git a/src/compiler/scala/tools/nsc/doc/model/Visibility.scala b/src/compiler/scala/tools/nsc/doc/model/Visibility.scala index 657d34ee54..ffd69ca115 100644 --- a/src/compiler/scala/tools/nsc/doc/model/Visibility.scala +++ b/src/compiler/scala/tools/nsc/doc/model/Visibility.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2007-2011 LAMP/EPFL + * Copyright 2007-2012 LAMP/EPFL * @author Gilles Dubochet */ diff --git a/src/compiler/scala/tools/nsc/doc/model/comment/Body.scala b/src/compiler/scala/tools/nsc/doc/model/comment/Body.scala index 3f0024cb68..34928ab398 100644 --- a/src/compiler/scala/tools/nsc/doc/model/comment/Body.scala +++ b/src/compiler/scala/tools/nsc/doc/model/comment/Body.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2007-2011 LAMP/EPFL + * Copyright 2007-2012 LAMP/EPFL * @author Manohar Jonnalagedda */ diff --git a/src/compiler/scala/tools/nsc/doc/model/comment/Comment.scala b/src/compiler/scala/tools/nsc/doc/model/comment/Comment.scala index c8f4c2f285..87d73f8c5b 100644 --- a/src/compiler/scala/tools/nsc/doc/model/comment/Comment.scala +++ b/src/compiler/scala/tools/nsc/doc/model/comment/Comment.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2007-2011 LAMP/EPFL + * Copyright 2007-2012 LAMP/EPFL * @author Manohar Jonnalagedda */ diff --git a/src/compiler/scala/tools/nsc/doc/model/comment/CommentFactory.scala b/src/compiler/scala/tools/nsc/doc/model/comment/CommentFactory.scala index 85d6a8911e..59cdf05957 100644 --- a/src/compiler/scala/tools/nsc/doc/model/comment/CommentFactory.scala +++ b/src/compiler/scala/tools/nsc/doc/model/comment/CommentFactory.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2007-2011 LAMP/EPFL + * Copyright 2007-2012 LAMP/EPFL * @author Manohar Jonnalagedda */ diff --git a/src/compiler/scala/tools/nsc/interactive/BuildManager.scala b/src/compiler/scala/tools/nsc/interactive/BuildManager.scala index 7d36d17a18..e31c5eda31 100644 --- a/src/compiler/scala/tools/nsc/interactive/BuildManager.scala +++ b/src/compiler/scala/tools/nsc/interactive/BuildManager.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2009-2011 Scxala Solutions and LAMP/EPFL + * Copyright 2009-2012 Scala Solutions and LAMP/EPFL * @author Iulian Dragos * @author Hubert Plocinicak */ diff --git a/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala b/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala index aab1c8fb7e..6acd6d2382 100644 --- a/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala +++ b/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2009-2011 Scala Solutions and LAMP/EPFL + * Copyright 2009-2012 Scala Solutions and LAMP/EPFL * @author Martin Odersky */ package scala.tools.nsc diff --git a/src/compiler/scala/tools/nsc/interactive/ContextTrees.scala b/src/compiler/scala/tools/nsc/interactive/ContextTrees.scala index 80d2796801..4a60211254 100644 --- a/src/compiler/scala/tools/nsc/interactive/ContextTrees.scala +++ b/src/compiler/scala/tools/nsc/interactive/ContextTrees.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2009-2011 Scala Solutions and LAMP/EPFL + * Copyright 2009-2012 Scala Solutions and LAMP/EPFL * @author Martin Odersky */ package scala.tools.nsc diff --git a/src/compiler/scala/tools/nsc/interactive/Global.scala b/src/compiler/scala/tools/nsc/interactive/Global.scala index 77bc77e966..cb2e7d641b 100644 --- a/src/compiler/scala/tools/nsc/interactive/Global.scala +++ b/src/compiler/scala/tools/nsc/interactive/Global.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2009-2011 Scala Solutions and LAMP/EPFL + * Copyright 2009-2012 Scala Solutions and LAMP/EPFL * @author Martin Odersky */ package scala.tools.nsc diff --git a/src/compiler/scala/tools/nsc/interactive/InteractiveReporter.scala b/src/compiler/scala/tools/nsc/interactive/InteractiveReporter.scala index df8fc3b21e..f57786578a 100644 --- a/src/compiler/scala/tools/nsc/interactive/InteractiveReporter.scala +++ b/src/compiler/scala/tools/nsc/interactive/InteractiveReporter.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2009-2011 Scala Solutions and LAMP/EPFL + * Copyright 2009-2012 Scala Solutions and LAMP/EPFL * @author Martin Odersky */ package scala.tools.nsc diff --git a/src/compiler/scala/tools/nsc/interactive/Picklers.scala b/src/compiler/scala/tools/nsc/interactive/Picklers.scala index bf920191c8..f4ec03bb47 100644 --- a/src/compiler/scala/tools/nsc/interactive/Picklers.scala +++ b/src/compiler/scala/tools/nsc/interactive/Picklers.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2009-2011 Scala Solutions and LAMP/EPFL + * Copyright 2009-2012 Scala Solutions and LAMP/EPFL * @author Martin Odersky */ package scala.tools.nsc diff --git a/src/compiler/scala/tools/nsc/interactive/PresentationCompilerThread.scala b/src/compiler/scala/tools/nsc/interactive/PresentationCompilerThread.scala index 70d8a826d0..309508246c 100644 --- a/src/compiler/scala/tools/nsc/interactive/PresentationCompilerThread.scala +++ b/src/compiler/scala/tools/nsc/interactive/PresentationCompilerThread.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2009-2011 Scala Solutions and LAMP/EPFL + * Copyright 2009-2012 Scala Solutions and LAMP/EPFL * @author Martin Odersky * @author Iulian Dragos */ diff --git a/src/compiler/scala/tools/nsc/interactive/REPL.scala b/src/compiler/scala/tools/nsc/interactive/REPL.scala index 6876ea14e0..2d93c77ca4 100644 --- a/src/compiler/scala/tools/nsc/interactive/REPL.scala +++ b/src/compiler/scala/tools/nsc/interactive/REPL.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2009-2011 Scala Solutions and LAMP/EPFL + * Copyright 2009-2012 Scala Solutions and LAMP/EPFL * @author Martin Odersky */ package scala.tools.nsc @@ -124,9 +124,9 @@ object REPL { * @param iContents An Array[Char] containing the instrumented source * @return The name of the instrumented source file */ - def writeInstrumented(iFullName: String, iContents: Array[Char]): String = { + def writeInstrumented(iFullName: String, suffix: String, iContents: Array[Char]): String = { val iSimpleName = iFullName drop ((iFullName lastIndexOf '.') + 1) - val iSourceName = iSimpleName + "$instrumented.scala" + val iSourceName = iSimpleName + suffix val ifile = new FileWriter(iSourceName) ifile.write(iContents) ifile.close() @@ -186,18 +186,20 @@ object REPL { * and outputs in the right column, or None if the presentation compiler * does not respond to askInstrumented. */ - def instrument(arguments: List[String], line: Int): Option[String] = { + def instrument(arguments: List[String], line: Int): Option[(String, String)] = { val source = toSourceFile(arguments.head) // strip right hand side comment column and any trailing spaces from all lines - val strippedSource = new BatchSourceFile(source.file, SourceInserter.stripRight(source.content)) + val strippedContents = SourceInserter.stripRight(source.content) + val strippedSource = new BatchSourceFile(source.file, strippedContents) println("stripped source = "+strippedSource) comp.askReload(List(strippedSource), reloadResult) comp.askInstrumented(strippedSource, line, instrumentedResult) using(instrumentedResult) { case (iFullName, iContents) => println(s"instrumented source $iFullName = ${iContents.mkString}") - val iSourceName = writeInstrumented(iFullName, iContents) - iSourceName + val iSourceName = writeInstrumented(iFullName, "$instrumented.scala", iContents) + val sSourceName = writeInstrumented(iFullName, "$stripped.scala", strippedContents) + (iSourceName, sSourceName) /* * val vdirOpt = compileInstrumented(iSourceName, arguments.tail) runInstrumented(vdirOpt, iFullName, strippedSource.content) @@ -227,9 +229,9 @@ object REPL { case List("complete", file, off1) => doComplete(makePos(file, off1, off1)) case "instrument" :: arguments => - println(instrument(arguments, -1).map(_.mkString)) + println(instrument(arguments, -1)) case "instrumentTo" :: line :: arguments => - println(instrument(arguments, line.toInt).map(_.mkString)) + println(instrument(arguments, line.toInt)) case List("quit") => comp.askShutdown() exit(1) // Don't use sys yet as this has to run on 2.8.2 also. diff --git a/src/compiler/scala/tools/nsc/interactive/RangePositions.scala b/src/compiler/scala/tools/nsc/interactive/RangePositions.scala index b702d2787c..c74cd1bbcc 100644 --- a/src/compiler/scala/tools/nsc/interactive/RangePositions.scala +++ b/src/compiler/scala/tools/nsc/interactive/RangePositions.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2009-2011 Scala Solutions and LAMP/EPFL + * Copyright 2009-2012 Scala Solutions and LAMP/EPFL * @author Martin Odersky */ package scala.tools.nsc diff --git a/src/compiler/scala/tools/nsc/interactive/RefinedBuildManager.scala b/src/compiler/scala/tools/nsc/interactive/RefinedBuildManager.scala index 57f0835edd..de6974cbb2 100644 --- a/src/compiler/scala/tools/nsc/interactive/RefinedBuildManager.scala +++ b/src/compiler/scala/tools/nsc/interactive/RefinedBuildManager.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2009-2011 Scala Solutions and LAMP/EPFL + * Copyright 2009-2012 Scala Solutions and LAMP/EPFL * @author Iulian Dragos * @author Hubert Plocinicak */ diff --git a/src/compiler/scala/tools/nsc/interactive/Response.scala b/src/compiler/scala/tools/nsc/interactive/Response.scala index fbb07b15ad..c90793781f 100644 --- a/src/compiler/scala/tools/nsc/interactive/Response.scala +++ b/src/compiler/scala/tools/nsc/interactive/Response.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2009-2011 Scala Solutions and LAMP/EPFL + * Copyright 2009-2012 Scala Solutions and LAMP/EPFL * @author Martin Odersky */ package scala.tools.nsc diff --git a/src/compiler/scala/tools/nsc/interactive/RichCompilationUnits.scala b/src/compiler/scala/tools/nsc/interactive/RichCompilationUnits.scala index 9b2fee5f1f..0f52258b7e 100644 --- a/src/compiler/scala/tools/nsc/interactive/RichCompilationUnits.scala +++ b/src/compiler/scala/tools/nsc/interactive/RichCompilationUnits.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2009-2011 Scala Solutions and LAMP/EPFL + * Copyright 2009-2012 Scala Solutions and LAMP/EPFL * @author Martin Odersky */ package scala.tools.nsc diff --git a/src/compiler/scala/tools/nsc/interactive/ScratchPadMaker.scala b/src/compiler/scala/tools/nsc/interactive/ScratchPadMaker.scala index bd1869e1a4..efc393c812 100644 --- a/src/compiler/scala/tools/nsc/interactive/ScratchPadMaker.scala +++ b/src/compiler/scala/tools/nsc/interactive/ScratchPadMaker.scala @@ -3,7 +3,7 @@ package interactive import scala.reflect.internal.util.{SourceFile, BatchSourceFile, RangePosition} import collection.mutable.ArrayBuffer -import reflect.internal.Chars.isLineBreakChar +import reflect.internal.Chars.{isLineBreakChar, isWhitespace} trait ScratchPadMaker { self: Global => @@ -40,14 +40,28 @@ trait ScratchPadMaker { self: Global => toPrint.clear() } + /** The position where to insert an instrumentation statement in front of giuven statement. + * This is at the latest `stat.pos.start`. But in order not to mess with column numbers + * in position we try to insert it at the end of the preceding line instead. + * To be safe, this can be done only if there's only whitespace between that position and + * statement's start position. + */ + private def instrumentPos(stat: Tree): Int = { + var start = stat.pos.start + while (start > 0 && isWhitespace(contents(start - 1))) start -= 1 + if (start > 0 && isLineBreakChar(contents(start - 1))) start -= 1 + start + } + private def addSkip(stat: Tree): Unit = { - if (stat.pos.start > skipped) applyPendingPatches(stat.pos.start) + val ipos = instrumentPos(stat) + if (stat.pos.start > skipped) applyPendingPatches(ipos) if (stat.pos.start >= endOffset) - patches += Patch(stat.pos.start, ";$stop()") + patches += Patch(ipos, ";$stop()") var end = stat.pos.end if (end > skipped) { - while (end < contents.length && !(isLineBreakChar(contents(end)))) end += 1 - patches += Patch(stat.pos.start, ";$skip("+(end-skipped)+"); ") + while (end < contents.length && !isLineBreakChar(contents(end))) end += 1 + patches += Patch(ipos, ";$skip("+(end-skipped)+"); ") skipped = end } } diff --git a/src/compiler/scala/tools/nsc/interactive/SimpleBuildManager.scala b/src/compiler/scala/tools/nsc/interactive/SimpleBuildManager.scala index 6c9c7249e8..b98a305cd9 100644 --- a/src/compiler/scala/tools/nsc/interactive/SimpleBuildManager.scala +++ b/src/compiler/scala/tools/nsc/interactive/SimpleBuildManager.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2009-2011 Scala Solutions and LAMP/EPFL + * Copyright 2009-2012 Scala Solutions and LAMP/EPFL * @author Martin Odersky */ package scala.tools.nsc diff --git a/src/compiler/scala/tools/nsc/interactive/tests/InteractiveTest.scala b/src/compiler/scala/tools/nsc/interactive/tests/InteractiveTest.scala index afb8985700..deeb398d39 100644 --- a/src/compiler/scala/tools/nsc/interactive/tests/InteractiveTest.scala +++ b/src/compiler/scala/tools/nsc/interactive/tests/InteractiveTest.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2009-2011 Scala Solutions and LAMP/EPFL + * Copyright 2009-2012 Scala Solutions and LAMP/EPFL * @author Martin Odersky */ package scala.tools.nsc diff --git a/src/compiler/scala/tools/nsc/interactive/tests/Tester.scala b/src/compiler/scala/tools/nsc/interactive/tests/Tester.scala index 55198e3617..5270b1971a 100644 --- a/src/compiler/scala/tools/nsc/interactive/tests/Tester.scala +++ b/src/compiler/scala/tools/nsc/interactive/tests/Tester.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2009-2011 Scala Solutions and LAMP/EPFL + * Copyright 2009-2012 Scala Solutions and LAMP/EPFL * @author Martin Odersky */ package scala.tools.nsc diff --git a/src/compiler/scala/tools/nsc/interactive/tests/core/AskCommand.scala b/src/compiler/scala/tools/nsc/interactive/tests/core/AskCommand.scala index 0cf32a8d8a..dfd2f23a19 100644 --- a/src/compiler/scala/tools/nsc/interactive/tests/core/AskCommand.scala +++ b/src/compiler/scala/tools/nsc/interactive/tests/core/AskCommand.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2009-2011 Scala Solutions and LAMP/EPFL + * Copyright 2009-2012 Scala Solutions and LAMP/EPFL * @author Martin Odersky */ package scala.tools.nsc diff --git a/src/compiler/scala/tools/nsc/interpreter/AbstractFileClassLoader.scala b/src/compiler/scala/tools/nsc/interpreter/AbstractFileClassLoader.scala index 7289a947f4..7047608c8f 100644 --- a/src/compiler/scala/tools/nsc/interpreter/AbstractFileClassLoader.scala +++ b/src/compiler/scala/tools/nsc/interpreter/AbstractFileClassLoader.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL */ package scala.tools.nsc diff --git a/src/compiler/scala/tools/nsc/interpreter/AbstractOrMissingHandler.scala b/src/compiler/scala/tools/nsc/interpreter/AbstractOrMissingHandler.scala index 2f47685757..c8468686ca 100644 --- a/src/compiler/scala/tools/nsc/interpreter/AbstractOrMissingHandler.scala +++ b/src/compiler/scala/tools/nsc/interpreter/AbstractOrMissingHandler.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/interpreter/ByteCode.scala b/src/compiler/scala/tools/nsc/interpreter/ByteCode.scala index 3059a8fb10..5f84b0daf3 100644 --- a/src/compiler/scala/tools/nsc/interpreter/ByteCode.scala +++ b/src/compiler/scala/tools/nsc/interpreter/ByteCode.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/interpreter/CodeHandlers.scala b/src/compiler/scala/tools/nsc/interpreter/CodeHandlers.scala index fc68998225..a348478f93 100644 --- a/src/compiler/scala/tools/nsc/interpreter/CodeHandlers.scala +++ b/src/compiler/scala/tools/nsc/interpreter/CodeHandlers.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/interpreter/CommandLine.scala b/src/compiler/scala/tools/nsc/interpreter/CommandLine.scala index e96918c90c..afb1927305 100644 --- a/src/compiler/scala/tools/nsc/interpreter/CommandLine.scala +++ b/src/compiler/scala/tools/nsc/interpreter/CommandLine.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Lex Spoon */ diff --git a/src/compiler/scala/tools/nsc/interpreter/Completion.scala b/src/compiler/scala/tools/nsc/interpreter/Completion.scala index 7a3e1913b6..0906e7ad93 100644 --- a/src/compiler/scala/tools/nsc/interpreter/Completion.scala +++ b/src/compiler/scala/tools/nsc/interpreter/Completion.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/interpreter/CompletionAware.scala b/src/compiler/scala/tools/nsc/interpreter/CompletionAware.scala index b3bbeb3169..abf326e746 100644 --- a/src/compiler/scala/tools/nsc/interpreter/CompletionAware.scala +++ b/src/compiler/scala/tools/nsc/interpreter/CompletionAware.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/interpreter/CompletionOutput.scala b/src/compiler/scala/tools/nsc/interpreter/CompletionOutput.scala index 808f549304..f0060b0c6c 100644 --- a/src/compiler/scala/tools/nsc/interpreter/CompletionOutput.scala +++ b/src/compiler/scala/tools/nsc/interpreter/CompletionOutput.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/interpreter/ConsoleReaderHelper.scala b/src/compiler/scala/tools/nsc/interpreter/ConsoleReaderHelper.scala index cfe932ad0b..1be2c86faf 100644 --- a/src/compiler/scala/tools/nsc/interpreter/ConsoleReaderHelper.scala +++ b/src/compiler/scala/tools/nsc/interpreter/ConsoleReaderHelper.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/interpreter/Delimited.scala b/src/compiler/scala/tools/nsc/interpreter/Delimited.scala index 9d30c47820..f29b8032bb 100644 --- a/src/compiler/scala/tools/nsc/interpreter/Delimited.scala +++ b/src/compiler/scala/tools/nsc/interpreter/Delimited.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/interpreter/ExprTyper.scala b/src/compiler/scala/tools/nsc/interpreter/ExprTyper.scala index f2438dcc20..f49e8d6b59 100644 --- a/src/compiler/scala/tools/nsc/interpreter/ExprTyper.scala +++ b/src/compiler/scala/tools/nsc/interpreter/ExprTyper.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/interpreter/Formatting.scala b/src/compiler/scala/tools/nsc/interpreter/Formatting.scala index 6339dca72f..2bc95e0ca3 100644 --- a/src/compiler/scala/tools/nsc/interpreter/Formatting.scala +++ b/src/compiler/scala/tools/nsc/interpreter/Formatting.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/interpreter/ILoop.scala b/src/compiler/scala/tools/nsc/interpreter/ILoop.scala index b567293a3f..4cc58d3f25 100644 --- a/src/compiler/scala/tools/nsc/interpreter/ILoop.scala +++ b/src/compiler/scala/tools/nsc/interpreter/ILoop.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Alexander Spoon */ @@ -438,7 +438,10 @@ class ILoop(in0: Option[BufferedReader], protected val out: JPrintWriter) } private def warningsCommand(): Result = { - intp.lastWarnings foreach { case (pos, msg) => intp.reporter.warning(pos, msg) } + if (intp.lastWarnings.isEmpty) + "Can't find any cached warnings." + else + intp.lastWarnings foreach { case (pos, msg) => intp.reporter.warning(pos, msg) } } private def javapCommand(line: String): Result = { diff --git a/src/compiler/scala/tools/nsc/interpreter/ILoopInit.scala b/src/compiler/scala/tools/nsc/interpreter/ILoopInit.scala index 7f5e09842a..2c16a754cb 100644 --- a/src/compiler/scala/tools/nsc/interpreter/ILoopInit.scala +++ b/src/compiler/scala/tools/nsc/interpreter/ILoopInit.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/interpreter/IMain.scala b/src/compiler/scala/tools/nsc/interpreter/IMain.scala index 7bdbff8627..6eadc1e63b 100644 --- a/src/compiler/scala/tools/nsc/interpreter/IMain.scala +++ b/src/compiler/scala/tools/nsc/interpreter/IMain.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ @@ -108,27 +108,19 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends else new PathResolver(settings).result.asURLs // the compiler's classpath ) def settings = currentSettings - def savingSettings[T](fn: Settings => Unit)(body: => T): T = { - val saved = currentSettings - currentSettings = saved.copy() - fn(currentSettings) - try body - finally currentSettings = saved - } def mostRecentLine = prevRequestList match { case Nil => "" case req :: _ => req.originalLine } - def rerunWith(names: String*) = { - savingSettings((ss: Settings) => { - import ss._ - names flatMap lookupSetting foreach { - case s: BooleanSetting => s.value = true - case _ => () - } - })(interpret(mostRecentLine)) + // Run the code body with the given boolean settings flipped to true. + def withoutWarnings[T](body: => T): T = beQuietDuring { + val saved = settings.nowarn.value + if (!saved) + settings.nowarn.value = true + + try body + finally if (!saved) settings.nowarn.value = false } - def rerunForWarnings = rerunWith("-deprecation", "-unchecked", "-Xlint") /** construct an interpreter that reports to Console */ def this(settings: Settings) = this(settings, new NewLinePrintWriter(new ConsoleWriter, true)) @@ -699,6 +691,10 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends class ReadEvalPrint(lineId: Int) { def this() = this(freshLineId()) + private var lastRun: Run = _ + private var evalCaught: Option[Throwable] = None + private var conditionalWarnings: List[ConditionalWarning] = Nil + val packageName = sessionNames.line + lineId val readName = sessionNames.read val evalName = sessionNames.eval @@ -754,7 +750,6 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends catch { case ex: Throwable => evalError(path, unwrap(ex)) } } - var evalCaught: Option[Throwable] = None lazy val evalClass = load(evalPath) lazy val evalValue = callEither(resultName) match { case Left(ex) => evalCaught = Some(ex) ; None @@ -776,27 +771,25 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends /** We get a bunch of repeated warnings for reasons I haven't * entirely figured out yet. For now, squash. */ - private def removeDupWarnings(xs: List[(Position, String)]): List[(Position, String)] = { - if (xs.isEmpty) - return Nil - - val ((pos, msg)) :: rest = xs - val filtered = rest filter { case (pos0, msg0) => - (msg != msg0) || (pos.lineContent.trim != pos0.lineContent.trim) || { - // same messages and same line content after whitespace removal - // but we want to let through multiple warnings on the same line - // from the same run. The untrimmed line will be the same since - // there's no whitespace indenting blowing it. - (pos.lineContent == pos0.lineContent) - } + private def updateRecentWarnings(run: Run) { + def loop(xs: List[(Position, String)]): List[(Position, String)] = xs match { + case Nil => Nil + case ((pos, msg)) :: rest => + val filtered = rest filter { case (pos0, msg0) => + (msg != msg0) || (pos.lineContent.trim != pos0.lineContent.trim) || { + // same messages and same line content after whitespace removal + // but we want to let through multiple warnings on the same line + // from the same run. The untrimmed line will be the same since + // there's no whitespace indenting blowing it. + (pos.lineContent == pos0.lineContent) + } + } + ((pos, msg)) :: loop(filtered) } - ((pos, msg)) :: removeDupWarnings(filtered) + val warnings = loop(run.allConditionalWarnings flatMap (_.warnings)) + if (warnings.nonEmpty) + mostRecentWarnings = warnings } - def lastWarnings: List[(Position, String)] = ( - if (lastRun == null) Nil - else removeDupWarnings(lastRun.allConditionalWarnings flatMap (_.warnings)) - ) - private var lastRun: Run = _ private def evalMethod(name: String) = evalClass.getMethods filter (_.getName == name) match { case Array(method) => method case xs => sys.error("Internal error: eval object " + evalClass + ", " + xs.mkString("\n", "\n", "")) @@ -804,6 +797,7 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends private def compileAndSaveRun(label: String, code: String) = { showCodeIfDebugging(code) val (success, run) = compileSourcesKeepingRun(new BatchSourceFile(label, packaged(code))) + updateRecentWarnings(run) lastRun = run success } @@ -953,11 +947,7 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends } // compile the result-extraction object - beQuietDuring { - savingSettings(_.nowarn.value = true) { - lineRep compile ResultObjectSourceCode(handlers) - } - } + withoutWarnings(lineRep compile ResultObjectSourceCode(handlers)) } } @@ -1008,12 +998,8 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends case _ => naming.mostRecentVar }) - def lastWarnings: List[(global.Position, String)] = ( - prevRequests.reverseIterator - map (_.lineRep.lastWarnings) - find (_.nonEmpty) - getOrElse Nil - ) + private var mostRecentWarnings: List[(global.Position, String)] = Nil + def lastWarnings = mostRecentWarnings def treesForRequestId(id: Int): List[Tree] = requestForReqId(id).toList flatMap (_.trees) diff --git a/src/compiler/scala/tools/nsc/interpreter/ISettings.scala b/src/compiler/scala/tools/nsc/interpreter/ISettings.scala index d68a2becfb..b65a1ac889 100644 --- a/src/compiler/scala/tools/nsc/interpreter/ISettings.scala +++ b/src/compiler/scala/tools/nsc/interpreter/ISettings.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Alexander Spoon */ diff --git a/src/compiler/scala/tools/nsc/interpreter/Imports.scala b/src/compiler/scala/tools/nsc/interpreter/Imports.scala index d579e0369e..5193166889 100644 --- a/src/compiler/scala/tools/nsc/interpreter/Imports.scala +++ b/src/compiler/scala/tools/nsc/interpreter/Imports.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ @@ -191,5 +191,5 @@ trait Imports { prevRequestList flatMap (req => req.handlers map (req -> _)) private def membersAtPickler(sym: Symbol): List[Symbol] = - beforePickler(sym.info.nonPrivateMembers) + beforePickler(sym.info.nonPrivateMembers.toList) }
\ No newline at end of file diff --git a/src/compiler/scala/tools/nsc/interpreter/InteractiveReader.scala b/src/compiler/scala/tools/nsc/interpreter/InteractiveReader.scala index 241ba5fa4a..2c894e5b47 100644 --- a/src/compiler/scala/tools/nsc/interpreter/InteractiveReader.scala +++ b/src/compiler/scala/tools/nsc/interpreter/InteractiveReader.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Stepan Koltsov */ diff --git a/src/compiler/scala/tools/nsc/interpreter/JLineCompletion.scala b/src/compiler/scala/tools/nsc/interpreter/JLineCompletion.scala index c429e3b196..edb95f7526 100644 --- a/src/compiler/scala/tools/nsc/interpreter/JLineCompletion.scala +++ b/src/compiler/scala/tools/nsc/interpreter/JLineCompletion.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ @@ -52,10 +52,10 @@ class JLineCompletion(val intp: IMain) extends Completion with CompletionOutput // XXX we'd like to say "filterNot (_.isDeprecated)" but this causes the // compiler to crash for reasons not yet known. - def members = afterTyper((effectiveTp.nonPrivateMembers ++ anyMembers) filter (_.isPublic)) - def methods = members filter (_.isMethod) - def packages = members filter (_.isPackage) - def aliases = members filter (_.isAliasType) + def members = afterTyper((effectiveTp.nonPrivateMembers.toList ++ anyMembers) filter (_.isPublic)) + def methods = members.toList filter (_.isMethod) + def packages = members.toList filter (_.isPackage) + def aliases = members.toList filter (_.isAliasType) def memberNames = members map tos def methodNames = methods map tos diff --git a/src/compiler/scala/tools/nsc/interpreter/JLineReader.scala b/src/compiler/scala/tools/nsc/interpreter/JLineReader.scala index 758f6e2abc..d8454db0ab 100644 --- a/src/compiler/scala/tools/nsc/interpreter/JLineReader.scala +++ b/src/compiler/scala/tools/nsc/interpreter/JLineReader.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Stepan Koltsov */ diff --git a/src/compiler/scala/tools/nsc/interpreter/Logger.scala b/src/compiler/scala/tools/nsc/interpreter/Logger.scala index d6cba5da6a..4016e0a6fc 100644 --- a/src/compiler/scala/tools/nsc/interpreter/Logger.scala +++ b/src/compiler/scala/tools/nsc/interpreter/Logger.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/interpreter/LoopCommands.scala b/src/compiler/scala/tools/nsc/interpreter/LoopCommands.scala index 3520a60ee5..2dc394a081 100644 --- a/src/compiler/scala/tools/nsc/interpreter/LoopCommands.scala +++ b/src/compiler/scala/tools/nsc/interpreter/LoopCommands.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/interpreter/MemberHandlers.scala b/src/compiler/scala/tools/nsc/interpreter/MemberHandlers.scala index 236f3f23c5..c041f02859 100644 --- a/src/compiler/scala/tools/nsc/interpreter/MemberHandlers.scala +++ b/src/compiler/scala/tools/nsc/interpreter/MemberHandlers.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ @@ -9,6 +9,7 @@ package interpreter import scala.collection.{ mutable, immutable } import scala.PartialFunction.cond import scala.reflect.internal.Chars +import scala.reflect.internal.Flags._ import language.implicitConversions trait MemberHandlers { @@ -126,7 +127,7 @@ trait MemberHandlers { class DefHandler(member: DefDef) extends MemberDefHandler(member) { private def vparamss = member.vparamss - private def isMacro = member.mods.hasFlag(scala.reflect.internal.Flags.MACRO) + private def isMacro = member.symbol hasFlag MACRO // true if not a macro and 0-arity override def definesValue = !isMacro && flattensToEmpty(vparamss) override def resultExtractionCode(req: Request) = @@ -211,7 +212,7 @@ trait MemberHandlers { beforePickler(individualNames map (targetType nonPrivateMember _)) lazy val wildcardSymbols: List[Symbol] = - if (importsWildcard) beforePickler(targetType.nonPrivateMembers) + if (importsWildcard) beforePickler(targetType.nonPrivateMembers.toList) else Nil /** Complete list of names imported by a wildcard */ diff --git a/src/compiler/scala/tools/nsc/interpreter/NamedParam.scala b/src/compiler/scala/tools/nsc/interpreter/NamedParam.scala index 3a69ea86b5..a2b42aeefc 100644 --- a/src/compiler/scala/tools/nsc/interpreter/NamedParam.scala +++ b/src/compiler/scala/tools/nsc/interpreter/NamedParam.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/interpreter/Naming.scala b/src/compiler/scala/tools/nsc/interpreter/Naming.scala index c3f51c74ec..35ee51ad10 100644 --- a/src/compiler/scala/tools/nsc/interpreter/Naming.scala +++ b/src/compiler/scala/tools/nsc/interpreter/Naming.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/interpreter/Parsed.scala b/src/compiler/scala/tools/nsc/interpreter/Parsed.scala index 6eccf1e1c5..7f2492204c 100644 --- a/src/compiler/scala/tools/nsc/interpreter/Parsed.scala +++ b/src/compiler/scala/tools/nsc/interpreter/Parsed.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/interpreter/Pasted.scala b/src/compiler/scala/tools/nsc/interpreter/Pasted.scala index 83321356a3..8ead419db3 100644 --- a/src/compiler/scala/tools/nsc/interpreter/Pasted.scala +++ b/src/compiler/scala/tools/nsc/interpreter/Pasted.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/interpreter/Phased.scala b/src/compiler/scala/tools/nsc/interpreter/Phased.scala index f39c025a86..9124eace05 100644 --- a/src/compiler/scala/tools/nsc/interpreter/Phased.scala +++ b/src/compiler/scala/tools/nsc/interpreter/Phased.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/interpreter/Power.scala b/src/compiler/scala/tools/nsc/interpreter/Power.scala index 57d7cef726..4ba0c59112 100644 --- a/src/compiler/scala/tools/nsc/interpreter/Power.scala +++ b/src/compiler/scala/tools/nsc/interpreter/Power.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ @@ -62,7 +62,7 @@ class Power[ReplValsImpl <: ReplVals : ru.TypeTag: ClassTag](val intp: IMain, re def discarded = seen.size - keep.size def members(x: Symbol): List[Symbol] = - if (x.rawInfo.isComplete) x.info.members + if (x.rawInfo.isComplete) x.info.members.toList else Nil var lastCount = -1 @@ -216,7 +216,7 @@ class Power[ReplValsImpl <: ReplVals : ru.TypeTag: ClassTag](val intp: IMain, re def declsOriginal = membersDeclared filterNot (_.isOverride) def members = membersUnabridged filterNot excludeMember - def membersUnabridged = tpe.members + def membersUnabridged = tpe.members.toList def membersDeclared = members filterNot excludeMember def membersInherited = members filterNot (membersDeclared contains _) def memberTypes = members filter (_.name.isTypeName) diff --git a/src/compiler/scala/tools/nsc/interpreter/ReplConfig.scala b/src/compiler/scala/tools/nsc/interpreter/ReplConfig.scala index adb1a2be04..e96dc63adb 100644 --- a/src/compiler/scala/tools/nsc/interpreter/ReplConfig.scala +++ b/src/compiler/scala/tools/nsc/interpreter/ReplConfig.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/interpreter/ReplGlobal.scala b/src/compiler/scala/tools/nsc/interpreter/ReplGlobal.scala index 05321dd7e6..6a0978d954 100644 --- a/src/compiler/scala/tools/nsc/interpreter/ReplGlobal.scala +++ b/src/compiler/scala/tools/nsc/interpreter/ReplGlobal.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/interpreter/ReplProps.scala b/src/compiler/scala/tools/nsc/interpreter/ReplProps.scala index 218e02193a..1a63430f0e 100644 --- a/src/compiler/scala/tools/nsc/interpreter/ReplProps.scala +++ b/src/compiler/scala/tools/nsc/interpreter/ReplProps.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/interpreter/ReplReporter.scala b/src/compiler/scala/tools/nsc/interpreter/ReplReporter.scala index fb61dfb672..8bd3fd67b6 100644 --- a/src/compiler/scala/tools/nsc/interpreter/ReplReporter.scala +++ b/src/compiler/scala/tools/nsc/interpreter/ReplReporter.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2002-2011 LAMP/EPFL + * Copyright 2002-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/interpreter/ReplStrings.scala b/src/compiler/scala/tools/nsc/interpreter/ReplStrings.scala index 0c9f4fcd47..c5358179f1 100644 --- a/src/compiler/scala/tools/nsc/interpreter/ReplStrings.scala +++ b/src/compiler/scala/tools/nsc/interpreter/ReplStrings.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/interpreter/ReplVals.scala b/src/compiler/scala/tools/nsc/interpreter/ReplVals.scala index 588d0647d2..5b8e4c3d92 100644 --- a/src/compiler/scala/tools/nsc/interpreter/ReplVals.scala +++ b/src/compiler/scala/tools/nsc/interpreter/ReplVals.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/interpreter/Results.scala b/src/compiler/scala/tools/nsc/interpreter/Results.scala index f582d47485..7c9d803d89 100644 --- a/src/compiler/scala/tools/nsc/interpreter/Results.scala +++ b/src/compiler/scala/tools/nsc/interpreter/Results.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/interpreter/RichClass.scala b/src/compiler/scala/tools/nsc/interpreter/RichClass.scala index 32eb1e95c1..1306afb1a0 100644 --- a/src/compiler/scala/tools/nsc/interpreter/RichClass.scala +++ b/src/compiler/scala/tools/nsc/interpreter/RichClass.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/interpreter/SimpleReader.scala b/src/compiler/scala/tools/nsc/interpreter/SimpleReader.scala index a57b047bc0..e144ed71be 100644 --- a/src/compiler/scala/tools/nsc/interpreter/SimpleReader.scala +++ b/src/compiler/scala/tools/nsc/interpreter/SimpleReader.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Stepan Koltsov */ diff --git a/src/compiler/scala/tools/nsc/interpreter/TypeStrings.scala b/src/compiler/scala/tools/nsc/interpreter/TypeStrings.scala index 56b9c7011c..d6604499b4 100644 --- a/src/compiler/scala/tools/nsc/interpreter/TypeStrings.scala +++ b/src/compiler/scala/tools/nsc/interpreter/TypeStrings.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ @@ -212,8 +212,7 @@ trait TypeStrings { } private def tparamString[T: ru.TypeTag] : String = { - // [Eugene++ to Paul] needs review!! - def typeArguments: List[ru.Type] = ru.typeOf[T].typeArguments + def typeArguments: List[ru.Type] = ru.typeOf[T] match { case ru.TypeRef(_, _, args) => args; case _ => Nil } // [Eugene++] todo. need to use not the `rootMirror`, but a mirror with the REPL's classloader // how do I get to it? acquiring context classloader seems unreliable because of multithreading def typeVariables: List[java.lang.Class[_]] = typeArguments map (targ => ru.rootMirror.runtimeClass(targ)) diff --git a/src/compiler/scala/tools/nsc/interpreter/package.scala b/src/compiler/scala/tools/nsc/interpreter/package.scala index 7d2610e3c8..98129aded8 100644 --- a/src/compiler/scala/tools/nsc/interpreter/package.scala +++ b/src/compiler/scala/tools/nsc/interpreter/package.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/interpreter/session/FileBackedHistory.scala b/src/compiler/scala/tools/nsc/interpreter/session/FileBackedHistory.scala index e238bdf654..c81b24c59b 100644 --- a/src/compiler/scala/tools/nsc/interpreter/session/FileBackedHistory.scala +++ b/src/compiler/scala/tools/nsc/interpreter/session/FileBackedHistory.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/interpreter/session/History.scala b/src/compiler/scala/tools/nsc/interpreter/session/History.scala index 5e1aba20f1..81b8b9efd6 100644 --- a/src/compiler/scala/tools/nsc/interpreter/session/History.scala +++ b/src/compiler/scala/tools/nsc/interpreter/session/History.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/interpreter/session/JLineHistory.scala b/src/compiler/scala/tools/nsc/interpreter/session/JLineHistory.scala index 795ca79668..86c25748d6 100644 --- a/src/compiler/scala/tools/nsc/interpreter/session/JLineHistory.scala +++ b/src/compiler/scala/tools/nsc/interpreter/session/JLineHistory.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/interpreter/session/SimpleHistory.scala b/src/compiler/scala/tools/nsc/interpreter/session/SimpleHistory.scala index 28173534e4..aa66311963 100644 --- a/src/compiler/scala/tools/nsc/interpreter/session/SimpleHistory.scala +++ b/src/compiler/scala/tools/nsc/interpreter/session/SimpleHistory.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/interpreter/session/package.scala b/src/compiler/scala/tools/nsc/interpreter/session/package.scala index 4e5b08c8cb..c1cd599941 100644 --- a/src/compiler/scala/tools/nsc/interpreter/session/package.scala +++ b/src/compiler/scala/tools/nsc/interpreter/session/package.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/io/DaemonThreadFactory.scala b/src/compiler/scala/tools/nsc/io/DaemonThreadFactory.scala index fa1218cc82..0e75ac3baa 100644 --- a/src/compiler/scala/tools/nsc/io/DaemonThreadFactory.scala +++ b/src/compiler/scala/tools/nsc/io/DaemonThreadFactory.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/io/Fileish.scala b/src/compiler/scala/tools/nsc/io/Fileish.scala index e12fcedc39..a05d9afe2a 100644 --- a/src/compiler/scala/tools/nsc/io/Fileish.scala +++ b/src/compiler/scala/tools/nsc/io/Fileish.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/io/Jar.scala b/src/compiler/scala/tools/nsc/io/Jar.scala index b322df986c..12ba3e4bd7 100644 --- a/src/compiler/scala/tools/nsc/io/Jar.scala +++ b/src/compiler/scala/tools/nsc/io/Jar.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/io/MsilFile.scala b/src/compiler/scala/tools/nsc/io/MsilFile.scala index d970d0e9c9..1835c8044b 100644 --- a/src/compiler/scala/tools/nsc/io/MsilFile.scala +++ b/src/compiler/scala/tools/nsc/io/MsilFile.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/io/Socket.scala b/src/compiler/scala/tools/nsc/io/Socket.scala index b7920921fa..b268b00dd5 100644 --- a/src/compiler/scala/tools/nsc/io/Socket.scala +++ b/src/compiler/scala/tools/nsc/io/Socket.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/io/SourceReader.scala b/src/compiler/scala/tools/nsc/io/SourceReader.scala index 2e146becdf..f784f751f5 100644 --- a/src/compiler/scala/tools/nsc/io/SourceReader.scala +++ b/src/compiler/scala/tools/nsc/io/SourceReader.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/io/package.scala b/src/compiler/scala/tools/nsc/io/package.scala index d29030603e..3c4f004198 100644 --- a/src/compiler/scala/tools/nsc/io/package.scala +++ b/src/compiler/scala/tools/nsc/io/package.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/javac/JavaParsers.scala b/src/compiler/scala/tools/nsc/javac/JavaParsers.scala index 3797d32d8b..d1c404b3e3 100644 --- a/src/compiler/scala/tools/nsc/javac/JavaParsers.scala +++ b/src/compiler/scala/tools/nsc/javac/JavaParsers.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ //todo: allow infix type patterns diff --git a/src/compiler/scala/tools/nsc/javac/JavaScanners.scala b/src/compiler/scala/tools/nsc/javac/JavaScanners.scala index 58c2426602..0367119547 100644 --- a/src/compiler/scala/tools/nsc/javac/JavaScanners.scala +++ b/src/compiler/scala/tools/nsc/javac/JavaScanners.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/javac/JavaTokens.scala b/src/compiler/scala/tools/nsc/javac/JavaTokens.scala index 796f96eccd..ae88a56398 100644 --- a/src/compiler/scala/tools/nsc/javac/JavaTokens.scala +++ b/src/compiler/scala/tools/nsc/javac/JavaTokens.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/matching/MatchSupport.scala b/src/compiler/scala/tools/nsc/matching/MatchSupport.scala index 16761144d7..6d8c80d1d0 100644 --- a/src/compiler/scala/tools/nsc/matching/MatchSupport.scala +++ b/src/compiler/scala/tools/nsc/matching/MatchSupport.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * Author: Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/matching/Matrix.scala b/src/compiler/scala/tools/nsc/matching/Matrix.scala index b29fac225a..1cf4bccb40 100644 --- a/src/compiler/scala/tools/nsc/matching/Matrix.scala +++ b/src/compiler/scala/tools/nsc/matching/Matrix.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * Author: Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/matching/MatrixAdditions.scala b/src/compiler/scala/tools/nsc/matching/MatrixAdditions.scala index ef17367ce0..5a0621ea20 100644 --- a/src/compiler/scala/tools/nsc/matching/MatrixAdditions.scala +++ b/src/compiler/scala/tools/nsc/matching/MatrixAdditions.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * Author: Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala b/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala index 0d1356a6b0..71deb2d356 100644 --- a/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala +++ b/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * Copyright 2007 Google Inc. All Rights Reserved. * Author: bqe@google.com (Burak Emir) */ diff --git a/src/compiler/scala/tools/nsc/matching/PatternBindings.scala b/src/compiler/scala/tools/nsc/matching/PatternBindings.scala index b2a721c586..8e043613b8 100644 --- a/src/compiler/scala/tools/nsc/matching/PatternBindings.scala +++ b/src/compiler/scala/tools/nsc/matching/PatternBindings.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * Author: Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/matching/Patterns.scala b/src/compiler/scala/tools/nsc/matching/Patterns.scala index 28dfd3fc77..af77d3fe3f 100644 --- a/src/compiler/scala/tools/nsc/matching/Patterns.scala +++ b/src/compiler/scala/tools/nsc/matching/Patterns.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * Author: Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/package.scala b/src/compiler/scala/tools/nsc/package.scala index 88d600c113..9ad0d9ba1f 100644 --- a/src/compiler/scala/tools/nsc/package.scala +++ b/src/compiler/scala/tools/nsc/package.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/plugins/Plugin.scala b/src/compiler/scala/tools/nsc/plugins/Plugin.scala index 7f9df2235a..de47e1b828 100644 --- a/src/compiler/scala/tools/nsc/plugins/Plugin.scala +++ b/src/compiler/scala/tools/nsc/plugins/Plugin.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2007-2011 LAMP/EPFL + * Copyright 2007-2012 LAMP/EPFL * @author Lex Spoon */ diff --git a/src/compiler/scala/tools/nsc/plugins/PluginComponent.scala b/src/compiler/scala/tools/nsc/plugins/PluginComponent.scala index 3c683d59ad..d5c0dd287a 100644 --- a/src/compiler/scala/tools/nsc/plugins/PluginComponent.scala +++ b/src/compiler/scala/tools/nsc/plugins/PluginComponent.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2007-2011 LAMP/EPFL + * Copyright 2007-2012 LAMP/EPFL * @author Lex Spoon * Updated by Anders Bach Nielsen */ diff --git a/src/compiler/scala/tools/nsc/plugins/PluginDescription.scala b/src/compiler/scala/tools/nsc/plugins/PluginDescription.scala index 0fa925baa7..b5f52e50ea 100644 --- a/src/compiler/scala/tools/nsc/plugins/PluginDescription.scala +++ b/src/compiler/scala/tools/nsc/plugins/PluginDescription.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2007-2011 LAMP/EPFL + * Copyright 2007-2012 LAMP/EPFL * @author Lex Spoon */ diff --git a/src/compiler/scala/tools/nsc/plugins/PluginLoadException.scala b/src/compiler/scala/tools/nsc/plugins/PluginLoadException.scala index 77c8d44347..cc7c575e38 100644 --- a/src/compiler/scala/tools/nsc/plugins/PluginLoadException.scala +++ b/src/compiler/scala/tools/nsc/plugins/PluginLoadException.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2007-2011 LAMP/EPFL + * Copyright 2007-2012 LAMP/EPFL * @author Lex Spoon */ diff --git a/src/compiler/scala/tools/nsc/plugins/Plugins.scala b/src/compiler/scala/tools/nsc/plugins/Plugins.scala index ba042b7b78..5eba9034d6 100644 --- a/src/compiler/scala/tools/nsc/plugins/Plugins.scala +++ b/src/compiler/scala/tools/nsc/plugins/Plugins.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2007-2011 LAMP/EPFL + * Copyright 2007-2012 LAMP/EPFL * @author Lex Spoon * Updated by Anders Bach Nielsen */ diff --git a/src/compiler/scala/tools/nsc/reporters/AbstractReporter.scala b/src/compiler/scala/tools/nsc/reporters/AbstractReporter.scala index cb85e49d55..491718bc0d 100644 --- a/src/compiler/scala/tools/nsc/reporters/AbstractReporter.scala +++ b/src/compiler/scala/tools/nsc/reporters/AbstractReporter.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2002-2011 LAMP/EPFL + * Copyright 2002-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala b/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala index dff900383e..6fae641487 100644 --- a/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala +++ b/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2002-2011 LAMP/EPFL + * Copyright 2002-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/reporters/Reporter.scala b/src/compiler/scala/tools/nsc/reporters/Reporter.scala index 303a477491..d756c1cb2c 100644 --- a/src/compiler/scala/tools/nsc/reporters/Reporter.scala +++ b/src/compiler/scala/tools/nsc/reporters/Reporter.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2002-2011 LAMP/EPFL + * Copyright 2002-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/reporters/StoreReporter.scala b/src/compiler/scala/tools/nsc/reporters/StoreReporter.scala index 5c3f7b8965..919d2ac377 100644 --- a/src/compiler/scala/tools/nsc/reporters/StoreReporter.scala +++ b/src/compiler/scala/tools/nsc/reporters/StoreReporter.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2002-2011 LAMP/EPFL + * Copyright 2002-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/scratchpad/Mixer.scala b/src/compiler/scala/tools/nsc/scratchpad/Mixer.scala index 46ccc32097..67ff916b11 100644 --- a/src/compiler/scala/tools/nsc/scratchpad/Mixer.scala +++ b/src/compiler/scala/tools/nsc/scratchpad/Mixer.scala @@ -23,7 +23,7 @@ class Mixer { val nextSpace = comments indexOf (' ', idx) var nextNL = comments indexOf ('\n', nextSpace + 1) if (nextNL < 0) nextNL = comments.length - val result = + val result = (new String(comments.slice(idx, nextSpace)).toInt, comments.slice(nextSpace + 1, nextNL)) idx = nextNL + 1 result @@ -46,7 +46,10 @@ class Mixer { mixed += '\n' col = 0 } - mixed ++= (" " * (sepColumn - col)) + while (col < sepColumn) { + mixed += ' ' + col += 1 + } } for ((offset, cs) <- parseComments(comments)) { val sep = diff --git a/src/compiler/scala/tools/nsc/settings/AbsScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/AbsScalaSettings.scala index d4ac490134..a96ddb11a2 100644 --- a/src/compiler/scala/tools/nsc/settings/AbsScalaSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/AbsScalaSettings.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/settings/AbsSettings.scala b/src/compiler/scala/tools/nsc/settings/AbsSettings.scala index c1dad2da82..120ada965a 100644 --- a/src/compiler/scala/tools/nsc/settings/AbsSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/AbsSettings.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/settings/AdvancedScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/AdvancedScalaSettings.scala index 08b1f7374e..1e5e0bd25c 100644 --- a/src/compiler/scala/tools/nsc/settings/AdvancedScalaSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/AdvancedScalaSettings.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/settings/AestheticSettings.scala b/src/compiler/scala/tools/nsc/settings/AestheticSettings.scala index 2baff0bb1c..5d324903e9 100644 --- a/src/compiler/scala/tools/nsc/settings/AestheticSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/AestheticSettings.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/settings/FscSettings.scala b/src/compiler/scala/tools/nsc/settings/FscSettings.scala index bb6e2ad920..ae7cacd049 100644 --- a/src/compiler/scala/tools/nsc/settings/FscSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/FscSettings.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/settings/MutableSettings.scala b/src/compiler/scala/tools/nsc/settings/MutableSettings.scala index fc833e2c26..116eed0f31 100644 --- a/src/compiler/scala/tools/nsc/settings/MutableSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/MutableSettings.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ // $Id$ @@ -68,7 +68,7 @@ class MutableSettings(val errorFn: String => Unit) if (isOpt) { val newArgs = parseParams(args) if (args eq newArgs) { - errorFn("bad option: '" + x + "'") + errorFn(s"bad option: '$x'") (false, args) } // discard empties, sometimes they appear because of ant or etc. @@ -536,7 +536,7 @@ class MutableSettings(val errorFn: String => Unit) } override def tryToSetColon(args: List[String]) = tryToSet(args) override def tryToSetFromPropertyValue(s: String) = tryToSet(s.trim.split(',').toList) - def unparse: List[String] = value map { name + ":" + _ } + def unparse: List[String] = name :: value withHelpSyntax(name + ":<" + arg + ">") } diff --git a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala index aa30a7a45b..19392ec23a 100644 --- a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ // $Id$ @@ -205,8 +205,6 @@ trait ScalaSettings extends AbsScalaSettings // Feature extensions val XmacroSettings = MultiStringSetting("-Xmacro-settings", "option", "Custom settings for macros.") - val XmacroPrimaryClasspath = PathSetting("-Xmacro-primary-classpath", "Classpath to load macros implementations from, defaults to compilation classpath (aka \"library classpath\".", "") - val XmacroFallbackClasspath = PathSetting("-Xmacro-fallback-classpath", "Classpath to load macros implementations from if they cannot be loaded from library classpath.", "") /** * IDE-specific settings diff --git a/src/compiler/scala/tools/nsc/settings/StandardScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/StandardScalaSettings.scala index 0991577829..ead9fc2d83 100644 --- a/src/compiler/scala/tools/nsc/settings/StandardScalaSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/StandardScalaSettings.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ @@ -43,7 +43,7 @@ trait StandardScalaSettings { val target = ChoiceSetting ("-target", "target", "Target platform for object files. All JVM 1.5 targets are deprecated.", List("jvm-1.5", "jvm-1.5-fjbg", "jvm-1.5-asm", "jvm-1.6", "jvm-1.7", "msil"), "jvm-1.6") - val unchecked = BooleanSetting ("-unchecked", "Enable detailed unchecked (erasure) warnings.") + val unchecked = BooleanSetting ("-unchecked", "Enable additional warnings where generated code depends on assumptions.") val uniqid = BooleanSetting ("-uniqid", "Uniquely tag all identifiers in debugging output.") val usejavacp = BooleanSetting ("-usejavacp", "Utilize the java.class.path in classpath resolution.") val verbose = BooleanSetting ("-verbose", "Output messages about what the compiler is doing.") diff --git a/src/compiler/scala/tools/nsc/settings/Warnings.scala b/src/compiler/scala/tools/nsc/settings/Warnings.scala index b2e3d51ad4..16f8685a87 100644 --- a/src/compiler/scala/tools/nsc/settings/Warnings.scala +++ b/src/compiler/scala/tools/nsc/settings/Warnings.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/symtab/BrowsingLoaders.scala b/src/compiler/scala/tools/nsc/symtab/BrowsingLoaders.scala index 84d601bfed..e087a93511 100644 --- a/src/compiler/scala/tools/nsc/symtab/BrowsingLoaders.scala +++ b/src/compiler/scala/tools/nsc/symtab/BrowsingLoaders.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala b/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala index 46c52e68a2..213a995e96 100644 --- a/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala +++ b/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/symtab/SymbolTable.scala b/src/compiler/scala/tools/nsc/symtab/SymbolTable.scala index 75b486ca7d..c6bd236e8a 100644 --- a/src/compiler/scala/tools/nsc/symtab/SymbolTable.scala +++ b/src/compiler/scala/tools/nsc/symtab/SymbolTable.scala @@ -1,5 +1,5 @@ /* NSC -- new scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/symtab/SymbolTrackers.scala b/src/compiler/scala/tools/nsc/symtab/SymbolTrackers.scala index 3cf5cc2f54..c596eb014a 100644 --- a/src/compiler/scala/tools/nsc/symtab/SymbolTrackers.scala +++ b/src/compiler/scala/tools/nsc/symtab/SymbolTrackers.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/AbstractFileReader.scala b/src/compiler/scala/tools/nsc/symtab/classfile/AbstractFileReader.scala index a75a03bff9..ac0b5012e7 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/AbstractFileReader.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/AbstractFileReader.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala index a035a346e6..32c9bff21b 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala index ecd1a3918a..437a5e1434 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Iulian Dragos */ @@ -594,6 +594,7 @@ abstract class ICodeReader extends ClassfileParser { while (pc < codeLength) parseInstruction val exceptionEntries = in.nextChar.toInt + code.containsEHs = (exceptionEntries != 0) var i = 0 while (i < exceptionEntries) { // skip start end PC @@ -647,6 +648,7 @@ abstract class ICodeReader extends ClassfileParser { var containsDUPX = false var containsNEW = false + var containsEHs = false def emit(i: Instruction) { instrs += ((pc, i)) @@ -664,6 +666,7 @@ abstract class ICodeReader extends ClassfileParser { val code = new Code(method) method.setCode(code) + method.bytecodeHasEHs = containsEHs var bb = code.startBlock def makeBasicBlocks: mutable.Map[Int, BasicBlock] = diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala index cc5ed0f129..3c34cf1c80 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/symtab/clr/CLRTypes.scala b/src/compiler/scala/tools/nsc/symtab/clr/CLRTypes.scala index d3b6c9238d..22bdff61ab 100644 --- a/src/compiler/scala/tools/nsc/symtab/clr/CLRTypes.scala +++ b/src/compiler/scala/tools/nsc/symtab/clr/CLRTypes.scala @@ -1,5 +1,5 @@ /* NSC -- new scala compiler - * Copyright 2004-2011 LAMP/EPFL + * Copyright 2004-2012 LAMP/EPFL */ diff --git a/src/compiler/scala/tools/nsc/symtab/clr/TypeParser.scala b/src/compiler/scala/tools/nsc/symtab/clr/TypeParser.scala index c5092aa057..5e52415ab2 100644 --- a/src/compiler/scala/tools/nsc/symtab/clr/TypeParser.scala +++ b/src/compiler/scala/tools/nsc/symtab/clr/TypeParser.scala @@ -1,5 +1,5 @@ /* NSC -- new scala compiler - * Copyright 2004-2011 LAMP/EPFL + * Copyright 2004-2012 LAMP/EPFL */ package scala.tools.nsc diff --git a/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala b/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala index 822c819e7d..a8cdee7154 100644 --- a/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala +++ b/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/transform/Constructors.scala b/src/compiler/scala/tools/nsc/transform/Constructors.scala index 70bd0bd21b..f2f4a44b02 100644 --- a/src/compiler/scala/tools/nsc/transform/Constructors.scala +++ b/src/compiler/scala/tools/nsc/transform/Constructors.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author */ diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala index 24a74722b0..eb3c965d7f 100644 --- a/src/compiler/scala/tools/nsc/transform/Erasure.scala +++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala b/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala index 1f7c34b8ad..6fba6dcc39 100644 --- a/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala +++ b/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ @@ -46,13 +46,13 @@ abstract class ExplicitOuter extends InfoTransform private def haveSameOuter(parent: Type, clazz: Symbol) = parent match { case TypeRef(pre, sym, _) => val owner = clazz.owner - + //println(s"have same outer $parent $clazz $sym ${sym.owner} $owner $pre") sym.isClass && owner.isClass && - (owner isSubClass sym.owner) && + (owner isSubClass sym.owner) && owner.thisType =:= pre - + case _ => false } @@ -416,7 +416,7 @@ abstract class ExplicitOuter extends InfoTransform val (checkExhaustive, requireSwitch) = nselector match { case Typed(nselector1, tpt) => - val unchecked = treeInfo.isUncheckedAnnotation(tpt.tpe) + val unchecked = tpt.tpe hasAnnotation UncheckedClass if (unchecked) nselector = nselector1 @@ -497,8 +497,18 @@ abstract class ExplicitOuter extends InfoTransform else atPos(tree.pos)(outerPath(outerValue, currentClass.outerClass, sym)) // (5) case Select(qual, name) => - if (currentClass != sym.owner) // (3) + /** return closest enclosing method, unless shadowed by an enclosing class; + * no use of closures here in the interest of speed. + */ + def closestEnclMethod(from: Symbol): Symbol = + if (from.isSourceMethod) from + else if (from.isClass) NoSymbol + else closestEnclMethod(from.owner) + + if (currentClass != sym.owner || + (closestEnclMethod(currentOwner) hasAnnotation ScalaInlineClass)) sym.makeNotPrivate(sym.owner) + val qsym = qual.tpe.widen.typeSymbol if (sym.isProtected && //(4) (qsym.isTrait || !(qual.isInstanceOf[Super] || (qsym isSubClass currentClass)))) diff --git a/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala b/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala index e937589f54..574c2c7049 100644 --- a/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala +++ b/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ package scala.tools.nsc diff --git a/src/compiler/scala/tools/nsc/transform/Flatten.scala b/src/compiler/scala/tools/nsc/transform/Flatten.scala index c8de25b2ea..94eaba67d7 100644 --- a/src/compiler/scala/tools/nsc/transform/Flatten.scala +++ b/src/compiler/scala/tools/nsc/transform/Flatten.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/transform/InfoTransform.scala b/src/compiler/scala/tools/nsc/transform/InfoTransform.scala index 880f0f0157..ab078421b0 100644 --- a/src/compiler/scala/tools/nsc/transform/InfoTransform.scala +++ b/src/compiler/scala/tools/nsc/transform/InfoTransform.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author */ diff --git a/src/compiler/scala/tools/nsc/transform/LambdaLift.scala b/src/compiler/scala/tools/nsc/transform/LambdaLift.scala index bee5aa5f4f..b6d54f114e 100644 --- a/src/compiler/scala/tools/nsc/transform/LambdaLift.scala +++ b/src/compiler/scala/tools/nsc/transform/LambdaLift.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author */ diff --git a/src/compiler/scala/tools/nsc/transform/Mixin.scala b/src/compiler/scala/tools/nsc/transform/Mixin.scala index fe5bef5009..3c828db7f3 100644 --- a/src/compiler/scala/tools/nsc/transform/Mixin.scala +++ b/src/compiler/scala/tools/nsc/transform/Mixin.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/transform/OverridingPairs.scala b/src/compiler/scala/tools/nsc/transform/OverridingPairs.scala index d8c18c2d50..4401e3bd3e 100644 --- a/src/compiler/scala/tools/nsc/transform/OverridingPairs.scala +++ b/src/compiler/scala/tools/nsc/transform/OverridingPairs.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/transform/SampleTransform.scala b/src/compiler/scala/tools/nsc/transform/SampleTransform.scala index f7d2c9de28..f0548252e7 100644 --- a/src/compiler/scala/tools/nsc/transform/SampleTransform.scala +++ b/src/compiler/scala/tools/nsc/transform/SampleTransform.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala index 63f93aa000..10a946c318 100644 --- a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala +++ b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Iulian Dragos */ @@ -69,7 +69,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { import definitions.{ BooleanClass, UnitClass, ArrayClass, ScalaValueClasses, isPrimitiveValueClass, isPrimitiveValueType, - SpecializedClass, UnspecializedClass, AnyRefClass, ObjectClass, AnyRefModule, + SpecializedClass, UnspecializedClass, AnyRefClass, ObjectClass, GroupOfSpecializable, uncheckedVarianceClass, ScalaInlineClass } import rootMirror.RootClass @@ -326,7 +326,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { } } - lazy val specializableTypes = (ScalaValueClasses :+ AnyRefClass) map (_.tpe) sorted + lazy val specializableTypes = ScalaValueClasses map (_.tpe) sorted /** If the symbol is the companion of a value class, the value class. * Otherwise, AnyRef. diff --git a/src/compiler/scala/tools/nsc/transform/TailCalls.scala b/src/compiler/scala/tools/nsc/transform/TailCalls.scala index 492273dfdc..b1b930ca2d 100644 --- a/src/compiler/scala/tools/nsc/transform/TailCalls.scala +++ b/src/compiler/scala/tools/nsc/transform/TailCalls.scala @@ -1,5 +1,5 @@ /* NSC -- new scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Iulian Dragos */ @@ -36,7 +36,7 @@ abstract class TailCalls extends Transform { } } - import gen.hasSynthCaseSymbol + import treeInfo.hasSynthCaseSymbol /** * A Tail Call Transformer diff --git a/src/compiler/scala/tools/nsc/transform/Transform.scala b/src/compiler/scala/tools/nsc/transform/Transform.scala index 0f793fdb2e..8afff8bcb4 100644 --- a/src/compiler/scala/tools/nsc/transform/Transform.scala +++ b/src/compiler/scala/tools/nsc/transform/Transform.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/transform/TypingTransformers.scala b/src/compiler/scala/tools/nsc/transform/TypingTransformers.scala index 7a4da41f14..9e681b321c 100644 --- a/src/compiler/scala/tools/nsc/transform/TypingTransformers.scala +++ b/src/compiler/scala/tools/nsc/transform/TypingTransformers.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala index 5c0207e5c7..e98bf519fe 100644 --- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala +++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author */ diff --git a/src/compiler/scala/tools/nsc/typechecker/Adaptations.scala b/src/compiler/scala/tools/nsc/typechecker/Adaptations.scala index 99d5363d5e..a81ac45c3d 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Adaptations.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Adaptations.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/typechecker/Analyzer.scala b/src/compiler/scala/tools/nsc/typechecker/Analyzer.scala index 2077ab0997..7f4f61bf80 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Analyzer.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Analyzer.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/typechecker/ConstantFolder.scala b/src/compiler/scala/tools/nsc/typechecker/ConstantFolder.scala index 021ab34c9f..c21a0c008b 100644 --- a/src/compiler/scala/tools/nsc/typechecker/ConstantFolder.scala +++ b/src/compiler/scala/tools/nsc/typechecker/ConstantFolder.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala index ba6c43f9d3..c7728ce389 100644 --- a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala index 0fc298e886..dd5588e9a6 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ @@ -360,7 +360,7 @@ trait Contexts { self: Analyzer => private def unitError(pos: Position, msg: String) = unit.error(pos, if (checking) "\n**** ERROR DURING INTERNAL CHECKING ****\n" + msg else msg) - + @inline private def issueCommon(err: AbsTypeError)(pf: PartialFunction[AbsTypeError, Unit]) { debugwarn("issue error: " + err.errMsg) if (settings.Yissuedebug.value) (new Exception).printStackTrace() @@ -611,8 +611,8 @@ trait Contexts { self: Analyzer => (e ne null) && (e.owner == scope) }) - private def collectImplicits(syms: List[Symbol], pre: Type, imported: Boolean = false): List[ImplicitInfo] = - for (sym <- syms if isQualifyingImplicit(sym.name, sym, pre, imported)) yield + private def collectImplicits(syms: Scope, pre: Type, imported: Boolean = false): List[ImplicitInfo] = + for (sym <- syms.toList if isQualifyingImplicit(sym.name, sym, pre, imported)) yield new ImplicitInfo(sym.name, pre, sym) private def collectImplicitImports(imp: ImportInfo): List[ImplicitInfo] = { @@ -657,7 +657,7 @@ trait Contexts { self: Analyzer => } } else if (scope != nextOuter.scope && !owner.isPackageClass) { debuglog("collect local implicits " + scope.toList)//DEBUG - collectImplicits(scope.toList, NoPrefix) + collectImplicits(scope, NoPrefix) } else if (imports != nextOuter.imports) { assert(imports.tail == nextOuter.imports, (imports, nextOuter.imports)) collectImplicitImports(imports.head) @@ -725,7 +725,7 @@ trait Contexts { self: Analyzer => result } - def allImportedSymbols: List[Symbol] = + def allImportedSymbols: Iterable[Symbol] = qual.tpe.members flatMap (transformImport(tree.selectors, _)) private def transformImport(selectors: List[ImportSelector], sym: Symbol): List[Symbol] = selectors match { diff --git a/src/compiler/scala/tools/nsc/typechecker/Duplicators.scala b/src/compiler/scala/tools/nsc/typechecker/Duplicators.scala index 63d1bd0e9f..e590e7aa30 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Duplicators.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Duplicators.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ @@ -41,7 +41,7 @@ abstract class Duplicators extends Analyzer { } protected def newBodyDuplicator(context: Context) = new BodyDuplicator(context) - + def retypedMethod(context: Context, tree: Tree, oldThis: Symbol, newThis: Symbol): Tree = (newBodyDuplicator(context)).retypedMethod(tree.asInstanceOf[DefDef], oldThis, newThis) @@ -160,7 +160,7 @@ abstract class Duplicators extends Analyzer { newsym.setInfo(fixType(ldef.symbol.info)) ldef.symbol = newsym debuglog("newsym: " + newsym + " info: " + newsym.info) - + case vdef @ ValDef(mods, name, _, rhs) if mods.hasFlag(Flags.LAZY) => debuglog("ValDef " + name + " sym.info: " + vdef.symbol.info) invalidSyms(vdef.symbol) = vdef @@ -170,7 +170,7 @@ abstract class Duplicators extends Analyzer { vdef.symbol = newsym debuglog("newsym: " + newsym + " info: " + newsym.info + ", owner: " + newsym.owner + ", " + newsym.owner.isClass) if (newsym.owner.isClass) newsym.owner.info.decls enter newsym - + case DefDef(_, name, tparams, vparamss, _, rhs) => // invalidate parameters invalidateAll(tparams ::: vparamss.flatten) @@ -215,7 +215,7 @@ abstract class Duplicators extends Analyzer { * Unless overridden, just returns the tree. */ def castType(tree: Tree, pt: Type): Tree = tree - + /** Special typer method for re-type checking trees. It expects a typed tree. * Returns a typed tree that has fresh symbols for all definitions in the original tree. * @@ -278,12 +278,19 @@ abstract class Duplicators extends Analyzer { invalidate(rhs) ldef.tpe = null - // since typer does not create the symbols for a LabelDef's params, - // we do that manually here -- we should really refactor LabelDef to be a subclass of DefDef - def newParam(p: Tree): Ident = { - val newsym = p.symbol.cloneSymbol //(context.owner) // TODO owner? - Ident(newsym.setInfo(fixType(p.symbol.info))) - } + // is this LabelDef generated by tailcalls? + val isTailLabel = (ldef.params.length >= 1) && (ldef.params.head.name == nme.THIS) + + // the typer does not create the symbols for a LabelDef's params, so unless they were created before we need + // to do it manually here -- but for the tailcalls-generated labels, ValDefs are created before the LabelDef, + // so we just need to plug in the name + def newParam(p: Tree): Ident = + if (isTailLabel) + Ident(p.symbol.name) // let the typer pick up the right symbol + else { + val newsym = p.symbol.cloneSymbol //(context.owner) // TODO owner? + Ident(newsym.setInfo(fixType(p.symbol.info))) + } val params1 = params map newParam val rhs1 = (new TreeSubstituter(params map (_.symbol), params1) transform rhs) // TODO: duplicate? rhs1.tpe = null @@ -365,7 +372,7 @@ abstract class Duplicators extends Analyzer { case EmptyTree => // no need to do anything, in particular, don't set the type to null, EmptyTree.tpe_= asserts tree - + case _ => debuglog("Duplicators default case: " + tree.summaryString) debuglog(" ---> " + tree) @@ -376,7 +383,7 @@ abstract class Duplicators extends Analyzer { super.typed(ntree, mode, pt) } } - + } } diff --git a/src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala b/src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala index 69b27045ab..9e175fa516 100644 --- a/src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala +++ b/src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala index da045e1a48..f9035f26b9 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ @@ -957,7 +957,7 @@ trait Implicits { companion.moduleClass match { case mc: ModuleClassSymbol => val infos = - for (im <- mc.implicitMembers) yield new ImplicitInfo(im.name, singleType(pre, companion), im) + for (im <- mc.implicitMembers.toList) yield new ImplicitInfo(im.name, singleType(pre, companion), im) if (infos.nonEmpty) infoMap += (sym -> infos) case _ => @@ -1196,7 +1196,7 @@ trait Implicits { gen.mkAttributedThis(thisSym) case _ => // if ``pre'' is not a PDT, e.g. if someone wrote - // implicitly[scala.reflect.makro.Context#TypeTag[Int]] + // implicitly[scala.reflect.macros.Context#TypeTag[Int]] // then we need to fail, because we don't know the prefix to use during type reification // upd. we also need to fail silently, because this is a very common situation // e.g. quite often we're searching for BaseUniverse#TypeTag, e.g. for a type tag in any universe diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala index e096b75d6d..d724164715 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ @@ -1366,14 +1366,16 @@ trait Infer { else if (param.isContravariant) >:> else =:= ) - val TypeRef(_, sym, args) = arg - - ( isLocalBinding(sym) - || arg.typeSymbol.isTypeParameterOrSkolem - || (sym.name == tpnme.WILDCARD) // avoid spurious warnings on HK types - || check(arg, param.tpe, conforms) - || warn("non-variable type argument " + arg) - ) + (arg hasAnnotation UncheckedClass) || { + val TypeRef(_, sym, args) = arg.withoutAnnotations + + ( isLocalBinding(sym) + || arg.typeSymbol.isTypeParameterOrSkolem + || (sym.name == tpnme.WILDCARD) // avoid spurious warnings on HK types + || check(arg, param.tpe, conforms) + || warn("non-variable type argument " + arg) + ) + } } // Checking if pt (the expected type of the pattern, and the type @@ -1404,8 +1406,11 @@ trait Infer { case _ => def where = ( if (inPattern) "pattern " else "" ) + typeToTest if (check(typeToTest, typeEnsured, =:=)) () + // Note that this is a regular warning, not an uncheckedWarning, + // which is now the province of such notifications as "pattern matcher + // exceeded its analysis budget." else warningMessages foreach (m => - context.unit.uncheckedWarning(tree.pos, s"$m in type $where is unchecked since it is eliminated by erasure")) + context.unit.warning(tree.pos, s"$m in type $where is unchecked since it is eliminated by erasure")) } } diff --git a/src/compiler/scala/tools/nsc/typechecker/Macros.scala b/src/compiler/scala/tools/nsc/typechecker/Macros.scala index d33857371d..7c5d458fee 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Macros.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Macros.scala @@ -8,7 +8,7 @@ import scala.reflect.runtime.ReflectionUtils import scala.collection.mutable.ListBuffer import scala.compat.Platform.EOL import reflect.internal.util.Statistics -import scala.reflect.makro.util._ +import scala.reflect.macros.util._ import java.lang.{Class => jClass} import java.lang.reflect.{Array => jArray, Method => jMethod} @@ -23,8 +23,8 @@ import java.lang.reflect.{Array => jArray, Method => jMethod} * * Then fooBar needs to point to a static method of the following form: * - * def fooBar[T: c.TypeTag] - * (c: scala.reflect.makro.Context) + * def fooBar[T: c.AbsTypeTag] + * (c: scala.reflect.macros.Context) * (xs: c.Expr[List[T]]) * : c.Expr[T] = { * ... @@ -51,7 +51,7 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces { /** A list of compatible macro implementation signatures. * * In the example above: - * (c: scala.reflect.makro.Context)(xs: c.Expr[List[T]]): c.Expr[T] + * (c: scala.reflect.macros.Context)(xs: c.Expr[List[T]]): c.Expr[T] * * @param macroDef The macro definition symbol * @param tparams The type parameters of the macro definition @@ -156,7 +156,7 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces { case TypeRef(SingleType(NoPrefix, contextParam), sym, List(tparam)) => var wannabe = sym while (wannabe.isAliasType) wannabe = wannabe.info.typeSymbol - if (wannabe != definitions.AbsTypeTagClass && wannabe != definitions.TypeTagClass) + if (wannabe != definitions.AbsTypeTagClass) List(param) else transform(param, tparam.typeSymbol) map (_ :: Nil) getOrElse Nil @@ -202,7 +202,6 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces { def abbreviateCoreAliases: String = { // hack! var result = s result = result.replace("c.universe.AbsTypeTag", "c.AbsTypeTag") - result = result.replace("c.universe.TypeTag", "c.TypeTag") result = result.replace("c.universe.Expr", "c.Expr") result } @@ -440,7 +439,7 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces { // we don't have to do this, but it appears to be more clear than allowing them val implicitParams = actparamss.flatten filter (_.isImplicit) if (implicitParams.length > 0) { - reportError(implicitParams.head.pos, "macro implementations cannot have implicit parameters other than TypeTag evidences") + reportError(implicitParams.head.pos, "macro implementations cannot have implicit parameters other than AbsTypeTag evidences") macroTraceVerbose("macro def failed to satisfy trivial preconditions: ")(macroDef) } @@ -591,53 +590,34 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces { runtimeType } - /** Primary classloader that is used to resolve and run macro implementations. - * Loads classes from -Xmacro-primary-classpath, or from -cp if the option is not specified. + /** Macro classloader that is used to resolve and run macro implementations. + * Loads classes from from -cp (aka the library classpath). * Is also capable of detecting REPL and reusing its classloader. */ - private lazy val primaryClassloader: ClassLoader = { + private lazy val macroClassloader: ClassLoader = { if (global.forMSIL) throw new UnsupportedOperationException("Scala reflection not available on this platform") - if (settings.XmacroPrimaryClasspath.value != "") { - macroLogVerbose("primary macro classloader: initializing from -Xmacro-primary-classpath: %s".format(settings.XmacroPrimaryClasspath.value)) - val classpath = toURLs(settings.XmacroPrimaryClasspath.value) - ScalaClassLoader.fromURLs(classpath, self.getClass.getClassLoader) - } else { - macroLogVerbose("primary macro classloader: initializing from -cp: %s".format(global.classPath.asURLs)) - val classpath = global.classPath.asURLs - var loader: ClassLoader = ScalaClassLoader.fromURLs(classpath, self.getClass.getClassLoader) - - // [Eugene] a heuristic to detect the REPL - if (global.settings.exposeEmptyPackage.value) { - macroLogVerbose("primary macro classloader: initializing from a REPL classloader".format(global.classPath.asURLs)) - import scala.tools.nsc.interpreter._ - val virtualDirectory = global.settings.outputDirs.getSingleOutput.get - loader = new AbstractFileClassLoader(virtualDirectory, loader) {} - } + val classpath = global.classPath.asURLs + macroLogVerbose("macro classloader: initializing from -cp: %s".format(classpath)) + val loader = ScalaClassLoader.fromURLs(classpath, self.getClass.getClassLoader) + // [Eugene] a heuristic to detect the REPL + if (global.settings.exposeEmptyPackage.value) { + macroLogVerbose("macro classloader: initializing from a REPL classloader".format(global.classPath.asURLs)) + import scala.tools.nsc.interpreter._ + val virtualDirectory = global.settings.outputDirs.getSingleOutput.get + new AbstractFileClassLoader(virtualDirectory, loader) {} + } else { loader } } - /** Fallback classloader that is used to resolve and run macro implementations when `primaryClassloader` fails. - * Loads classes from -Xmacro-fallback-classpath. - */ - private lazy val fallbackClassloader: ClassLoader = { - if (global.forMSIL) - throw new UnsupportedOperationException("Scala reflection not available on this platform") - - macroLogVerbose("fallback macro classloader: initializing from -Xmacro-fallback-classpath: %s".format(settings.XmacroFallbackClasspath.value)) - val classpath = toURLs(settings.XmacroFallbackClasspath.value) - ScalaClassLoader.fromURLs(classpath, self.getClass.getClassLoader) - } - /** Produces a function that can be used to invoke macro implementation for a given macro definition: * 1) Looks up macro implementation symbol in this universe. - * 2) Loads its enclosing class from the primary classloader. - * 3) Loads the companion of that enclosing class from the primary classloader. + * 2) Loads its enclosing class from the macro classloader. + * 3) Loads the companion of that enclosing class from the macro classloader. * 4) Resolves macro implementation within the loaded companion. - * 5) If 2-4 fails, repeats them for the fallback classloader. * * @return Some(runtime) if macro implementation can be loaded successfully from either of the mirrors, * None otherwise. @@ -742,25 +722,10 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces { } } - val primary = loadMacroImpl(primaryClassloader) - primary match { - case Some((implObj, implMeth)) => + loadMacroImpl(macroClassloader) map { + case (implObj, implMeth) => def runtime(args: List[Any]) = implMeth.invoke(implObj, (args map (_.asInstanceOf[AnyRef])): _*).asInstanceOf[Any] - Some(runtime _) - case None => - if (settings.XmacroFallbackClasspath.value != "") { - macroLogVerbose("trying to load macro implementation from the fallback mirror: %s".format(settings.XmacroFallbackClasspath.value)) - val fallback = loadMacroImpl(fallbackClassloader) - fallback match { - case Some((implObj, implMeth)) => - def runtime(args: List[Any]) = implMeth.invoke(implObj, (args map (_.asInstanceOf[AnyRef])): _*).asInstanceOf[Any] - Some(runtime _) - case None => - None - } - } else { - None - } + runtime _ } } @@ -888,9 +853,6 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces { param.tpe.typeSymbol match { case definitions.AbsTypeTagClass => // do nothing - case definitions.TypeTagClass => - if (!tpe.isConcrete) context.abort(context.enclosingPosition, "cannot create TypeTag from a type %s having unresolved type parameters".format(tpe)) - // otherwise do nothing case _ => throw new Error("unsupported tpe: " + tpe) } @@ -913,7 +875,7 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces { } /** Keeps track of macros in-flight. - * See more informations in comments to ``openMacros'' in ``scala.reflect.makro.Context''. + * See more informations in comments to ``openMacros'' in ``scala.reflect.macros.Context''. */ var openMacros = List[MacroContext]() def enclosingMacroPosition = openMacros map (_.macroApplication.pos) find (_ ne NoPosition) getOrElse NoPosition @@ -1053,7 +1015,7 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces { ) val forgotten = ( if (sym.isTerm) "splice when splicing this variable into a reifee" - else "c.TypeTag annotation for this type parameter" + else "c.AbsTypeTag annotation for this type parameter" ) typer.context.error(expandee.pos, template.replaceAllLiterally("@kind@", sym.name.nameKind).format( @@ -1147,9 +1109,7 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces { val macroDef = expandee.symbol def notFound() = { typer.context.error(expandee.pos, "macro implementation not found: " + macroDef.name + " " + - "(the most common reason for that is that you cannot use macro implementations in the same compilation run that defines them)\n" + - "if you do need to define macro implementations along with the rest of your program, consider two-phase compilation with -Xmacro-fallback-classpath " + - "in the second phase pointing to the output of the first phase") + "(the most common reason for that is that you cannot use macro implementations in the same compilation run that defines them)") None } def fallBackToOverridden(tree: Tree): Option[Tree] = { @@ -1191,7 +1151,7 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces { // [Eugene] any ideas about how to improve this one? val realex = ReflectionUtils.unwrapThrowable(ex) realex match { - case realex: reflect.makro.runtime.AbortMacroException => + case realex: reflect.macros.runtime.AbortMacroException => macroLogVerbose("macro expansion has failed: %s".format(realex.msg)) fail(typer, expandee) // error has been reported by abort case err: TypeError => diff --git a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala index 7bd5f4caeb..dd180e6b76 100644 --- a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala +++ b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ package scala.tools.nsc @@ -70,11 +70,8 @@ trait MethodSynthesis { // [Eugene++->Martin] now this compiles, will soon check it out def newMethodType[F](owner: Symbol)(implicit t: TT[F]): Type = { val fnSymbol = compilerSymbolFromTag(t) - assert(fnSymbol isSubClass FunctionClass(t.tpe.typeArguments.size - 1), (owner, t)) - // [Eugene++ to Paul] needs review!! - // val symbols = m.typeArguments map (m => manifestToSymbol(m)) - // val formals = symbols.init map (_.typeConstructor) val formals = compilerTypeFromTag(t).typeArguments + assert(fnSymbol isSubClass FunctionClass(formals.size - 1), (owner, t)) val params = owner newSyntheticValueParams formals MethodType(params, formals.last) } diff --git a/src/compiler/scala/tools/nsc/typechecker/Modes.scala b/src/compiler/scala/tools/nsc/typechecker/Modes.scala index 3eff5ef024..e9ea99faab 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Modes.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Modes.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index dc9f07cad9..efb96b173c 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ @@ -983,15 +983,10 @@ trait Namers extends MethodSynthesis { } addDefaultGetters(meth, vparamss, tparams, overriddenSymbol) - // macro defs need to be typechecked in advance - // because @macroImpl annotation only gets assigned during typechecking - // otherwise we might find ourselves in the situation when we specified -Xmacro-fallback-classpath - // but macros still don't expand - // that might happen because macro def doesn't have its link a macro impl yet - if (ddef.symbol.isTermMacro) { - val pt = resultPt.substSym(tparamSyms, tparams map (_.symbol)) - typer.computeMacroDefType(ddef, pt) - } + // fast track macros, i.e. macros defined inside the compiler, are hardcoded + // hence we make use of that and let them have whatever right-hand side they need + // (either "macro ???" as they used to or just "???" to maximally simplify their compilation) + if (fastTrack contains ddef.symbol) ddef.symbol setFlag MACRO thisMethodType({ val rt = ( diff --git a/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala index a0c1342026..7ba198a9f2 100644 --- a/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala +++ b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala b/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala index cf5c7265ad..4776c3b45f 100644 --- a/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala +++ b/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala @@ -1,6 +1,6 @@ /* NSC -- new Scala compiler * - * Copyright 2012 LAMP/EPFL + * Copyright 2011-2012 LAMP/EPFL * @author Adriaan Moors */ @@ -113,7 +113,6 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL import definitions._ import analyzer._ //Typer - val SYNTH_CASE = Flags.CASE | SYNTHETIC case class DefaultOverrideMatchAttachment(default: Tree) @@ -241,7 +240,8 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL // append the default to the list of cases and suppress the unreachable case error that may arise (once we detect that...) val matchFailGenOverride = match_.attachments.get[DefaultOverrideMatchAttachment].map{case DefaultOverrideMatchAttachment(default) => ((scrut: Tree) => default)} - val selectorSym = freshSym(selector.pos, pureType(selectorTp)) setFlag SYNTH_CASE + val selectorSym = freshSym(selector.pos, pureType(selectorTp)) setFlag treeInfo.SYNTH_CASE_FLAGS + // pt = Any* occurs when compiling test/files/pos/annotDepMethType.scala with -Xexperimental val combined = combineCases(selector, selectorSym, cases map translateCase(selectorSym, pt), pt, matchOwner, matchFailGenOverride) @@ -1228,7 +1228,7 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL if (settings.XnoPatmatAnalysis.value) (true, false) else scrut match { case Typed(_, tpt) => - (treeInfo.isUncheckedAnnotation(tpt.tpe), + (tpt.tpe hasAnnotation UncheckedClass, // matches with two or fewer cases need not apply for switchiness (if-then-else will do) treeInfo.isSwitchAnnotation(tpt.tpe) && casesNoSubstOnly.lengthCompare(2) > 0) case _ => @@ -1317,6 +1317,9 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL def freshSym(pos: Position, tp: Type = NoType, prefix: String = "x") = NoSymbol.newTermSymbol(freshName(prefix), pos) setInfo tp + def newSynthCaseLabel(name: String) = + NoSymbol.newLabel(freshName(name), NoPosition) setFlag treeInfo.SYNTH_CASE_FLAGS + // codegen relevant to the structure of the translation (how extractors are combined) trait AbsCodegen { def matcher(scrut: Tree, scrutSym: Symbol, restpe: Type)(cases: List[Casegen => Tree], matchFailGen: Option[Tree => Tree]): Tree @@ -1487,7 +1490,7 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL case object FalseCond extends Cond {override def toString = "F"} case class AndCond(a: Cond, b: Cond) extends Cond {override def toString = a +"/\\"+ b} - case class OrCond(a: Cond, b: Cond) extends Cond {override def toString = "("+a+") \\/ ("+ b +")"} + case class OrCond(a: Cond, b: Cond) extends Cond {override def toString = "("+a+") \\/ ("+ b +")"} object EqualityCond { private val uniques = new collection.mutable.HashMap[(Tree, Tree), EqualityCond] @@ -3109,7 +3112,7 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL } } - private val defaultLabel: Symbol = NoSymbol.newLabel(freshName("default"), NoPosition) setFlag SYNTH_CASE + private val defaultLabel: Symbol = newSynthCaseLabel("default") /** Collapse guarded cases that switch on the same constant (the last case may be unguarded). * @@ -3477,11 +3480,11 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL * if keepGoing is false, the result Some(x) of the naive translation is encoded as matchRes == x */ def matcher(scrut: Tree, scrutSym: Symbol, restpe: Type)(cases: List[Casegen => Tree], matchFailGen: Option[Tree => Tree]): Tree = { - val matchEnd = NoSymbol.newLabel(freshName("matchEnd"), NoPosition) setFlag SYNTH_CASE + val matchEnd = newSynthCaseLabel("matchEnd") val matchRes = NoSymbol.newValueParameter(newTermName("x"), NoPosition, SYNTHETIC) setInfo restpe.withoutAnnotations // matchEnd setInfo MethodType(List(matchRes), restpe) - def newCaseSym = NoSymbol.newLabel(freshName("case"), NoPosition) setInfo MethodType(Nil, restpe) setFlag SYNTH_CASE + def newCaseSym = newSynthCaseLabel("case") setInfo MethodType(Nil, restpe) var _currCase = newCaseSym val caseDefs = cases map { (mkCase: Casegen => Tree) => diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index 3518316fbb..41387b7507 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ @@ -122,7 +122,7 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R val defaultGetters = clazz.info.findMembers(0L, DEFAULTPARAM) val defaultMethodNames = defaultGetters map (sym => nme.defaultGetterToMethod(sym.name)) - defaultMethodNames.distinct foreach { name => + defaultMethodNames.toList.distinct foreach { name => val methods = clazz.info.findMember(name, 0L, METHOD, false).alternatives val haveDefaults = methods filter (sym => sym.hasParamWhich(_.hasDefault) && !nme.isProtectedAccessorName(sym.name)) @@ -628,7 +628,7 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R matchingArity match { // So far so good: only one candidate method - case concrete :: Nil => + case Scope(concrete) => val mismatches = abstractParams zip concrete.tpe.paramTypes filterNot { case (x, y) => x =:= y } mismatches match { // Only one mismatched parameter: say something useful. @@ -1541,7 +1541,8 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R transform(qual) case Apply(fn, args) => - checkSensible(tree.pos, fn, args) + // sensicality should be subsumed by the unreachability/exhaustivity/irrefutability analyses in the pattern matcher + if (!inPattern) checkSensible(tree.pos, fn, args) currentApplication = tree tree } @@ -1718,7 +1719,7 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R val pat1 = transform(pat) inPattern = false treeCopy.CaseDef(tree, pat1, transform(guard), transform(body)) - case LabelDef(_, _, _) if gen.hasSynthCaseSymbol(result) => + case LabelDef(_, _, _) if treeInfo.hasSynthCaseSymbol(result) => val old = inPattern inPattern = true val res = deriveLabelDef(result)(transform) diff --git a/src/compiler/scala/tools/nsc/typechecker/StdAttachments.scala b/src/compiler/scala/tools/nsc/typechecker/StdAttachments.scala index 190b18711c..64c5b41638 100644 --- a/src/compiler/scala/tools/nsc/typechecker/StdAttachments.scala +++ b/src/compiler/scala/tools/nsc/typechecker/StdAttachments.scala @@ -4,7 +4,7 @@ package typechecker trait StdAttachments { self: Analyzer => - type UnaffiliatedMacroContext = scala.reflect.makro.runtime.Context + type UnaffiliatedMacroContext = scala.reflect.macros.runtime.Context type MacroContext = UnaffiliatedMacroContext { val universe: self.global.type } case class MacroRuntimeAttachment(delayed: Boolean, typerContext: Context, macroContext: Option[MacroContext]) }
\ No newline at end of file diff --git a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala index b544407286..92c50a05c2 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala index 5465a3b47f..c7c9d2f4aa 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/typechecker/Tags.scala b/src/compiler/scala/tools/nsc/typechecker/Tags.scala index 052484e8e1..f82e009be8 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Tags.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Tags.scala @@ -61,7 +61,7 @@ trait Tags { */ def resolveTypeTag(pos: Position, pre: Type, tp: Type, concrete: Boolean, allowMaterialization: Boolean = true): Tree = { val tagSym = if (concrete) TypeTagClass else AbsTypeTagClass - val tagTp = if (pre == NoType) TypeRef(BaseUniverseClass.asTypeConstructor, tagSym, List(tp)) else singleType(pre, pre member tagSym.name) + val tagTp = if (pre == NoType) TypeRef(BaseUniverseClass.toTypeConstructor, tagSym, List(tp)) else singleType(pre, pre member tagSym.name) val taggedTp = appliedType(tagTp, List(tp)) resolveTag(pos, taggedTp, allowMaterialization) } diff --git a/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala b/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala index fe82af5b23..07d457b17b 100644 --- a/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala b/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala index 38c2c5f719..4a0977eb90 100644 --- a/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala +++ b/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ @@ -401,7 +401,11 @@ trait TypeDiagnostics { object checkDead { private var expr: Symbol = NoSymbol - private def exprOK = expr != Object_synchronized + + private def exprOK = + (expr != Object_synchronized) && + !(expr.isLabel && treeInfo.isSynthCaseSymbol(expr)) // it's okay to jump to matchEnd (or another case) with an argument of type nothing + private def treeOK(tree: Tree) = tree.tpe != null && tree.tpe.typeSymbol == NothingClass def updateExpr(fn: Tree) = { diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index e57cae00e0..063f615e17 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ @@ -92,8 +92,8 @@ trait Typers extends Modes with Adaptations with Tags { // when true: // - we may virtualize matches (if -Xexperimental and there's a suitable __match in scope) // - we synthesize PartialFunction implementations for `x => x match {...}` and `match {...}` when the expected type is PartialFunction - // this is disabled by: -Xoldpatmat, scaladoc or interactive compilation - @inline private def newPatternMatching = opt.virtPatmat && !forScaladoc && !forInteractive // && (phase.id < currentRun.uncurryPhase.id) + // this is disabled by: -Xoldpatmat or interactive compilation (we run it for scaladoc due to SI-5933) + @inline private def newPatternMatching = opt.virtPatmat && !forInteractive //&& !forScaladoc && (phase.id < currentRun.uncurryPhase.id) abstract class Typer(context0: Context) extends TyperDiagnostics with Adaptation with Tag with TyperContextErrors { import context0.unit @@ -769,7 +769,7 @@ trait Typers extends Modes with Adaptations with Tags { val featureName = (nestedOwners map (_.name + ".")).mkString + featureTrait.name def action(): Boolean = { def hasImport = inferImplicit(EmptyTree: Tree, featureTrait.tpe, true, false, context) != SearchFailure - def hasOption = settings.language.value contains featureName + def hasOption = settings.language.value exists (s => s == featureName || s == "_") val OK = hasImport || hasOption if (!OK) { val Some(AnnotationInfo(_, List(Literal(Constant(featureDesc: String)), Literal(Constant(required: Boolean))), _)) = @@ -2286,7 +2286,7 @@ trait Typers extends Modes with Adaptations with Tags { // but not in real life (i.e., now that's we've reset the method's type skolems' // infos back to their pre-GADT-constraint state) if (isFullyDefined(pt) && !(body1.tpe <:< pt)) - body1 = typedPos(body1.pos)(gen.mkCast(body1, pt)) + body1 = typedPos(body1.pos)(gen.mkCast(body1, pt.normalize)) } @@ -3220,7 +3220,7 @@ trait Typers extends Modes with Adaptations with Tags { // we don't create a new Context for a Match, so find the CaseDef, then go out one level and navigate back to the match that has this case // val thisCase = context.nextEnclosing(_.tree.isInstanceOf[CaseDef]) // val unchecked = thisCase.outer.tree.collect{case Match(selector, cases) if cases contains thisCase => selector} match { - // case List(Typed(_, tpt)) if treeInfo.isUncheckedAnnotation(tpt.tpe) => true + // case List(Typed(_, tpt)) if tpt.tpe hasAnnotation UncheckedClass => true // case t => println("outer tree: "+ (t, thisCase, thisCase.outer.tree)); false // } // println("wrapClassTagUnapply"+ (!isPastTyper && infer.containsUnchecked(pt), pt, uncheckedPattern)) @@ -4522,7 +4522,9 @@ trait Typers extends Modes with Adaptations with Tags { }) setType qual.tpe setPos qual.pos, name) case _ if accessibleError.isDefined => - val qual1 = adaptToMemberWithArgs(tree, qual, name, mode, false, false) + // don't adapt constructor, SI-6074 + val qual1 = if (name == nme.CONSTRUCTOR) qual + else adaptToMemberWithArgs(tree, qual, name, mode, false, false) if (!qual1.isErrorTyped && (qual1 ne qual)) typed(Select(qual1, name) setPos tree.pos, mode, pt) else @@ -5089,7 +5091,7 @@ trait Typers extends Modes with Adaptations with Tags { // convert new Array^N[T](len) for N > 1 to evidence[ClassTag[Array[...Array[T]...]]].newArray(len), where Array HK gets applied (N-1) times // [Eugene] no more MaxArrayDims. ClassTags are flexible enough to allow creation of arrays of arbitrary dimensionality (w.r.t JVM restrictions) val Some((level, componentType)) = erasure.GenericArray.unapply(tpt.tpe) - val tagType = List.iterate(componentType, level)(tpe => appliedType(ArrayClass.asType, List(tpe))).last + val tagType = List.iterate(componentType, level)(tpe => appliedType(ArrayClass.toTypeConstructor, List(tpe))).last val newArrayApp = atPos(tree.pos) { val tag = resolveClassTag(tree.pos, tagType) if (tag.isEmpty) MissingClassTagError(tree, tagType) diff --git a/src/compiler/scala/tools/nsc/typechecker/Unapplies.scala b/src/compiler/scala/tools/nsc/typechecker/Unapplies.scala index d508e10813..4871ef199c 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Unapplies.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Unapplies.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/typechecker/Variances.scala b/src/compiler/scala/tools/nsc/typechecker/Variances.scala index 1ba0de0192..b9f2b9abd8 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Variances.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Variances.scala @@ -1,5 +1,5 @@ /* NSC -- new scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/util/CharArrayReader.scala b/src/compiler/scala/tools/nsc/util/CharArrayReader.scala index 153334b5e1..d0927ae6f6 100644 --- a/src/compiler/scala/tools/nsc/util/CharArrayReader.scala +++ b/src/compiler/scala/tools/nsc/util/CharArrayReader.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/util/ClassPath.scala b/src/compiler/scala/tools/nsc/util/ClassPath.scala index 9755fb6c60..1c7a723f7f 100644 --- a/src/compiler/scala/tools/nsc/util/ClassPath.scala +++ b/src/compiler/scala/tools/nsc/util/ClassPath.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2006-2011 LAMP/EPFL + * Copyright 2006-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/util/CommandLineParser.scala b/src/compiler/scala/tools/nsc/util/CommandLineParser.scala index 78bfd5e908..de4b3d5d62 100644 --- a/src/compiler/scala/tools/nsc/util/CommandLineParser.scala +++ b/src/compiler/scala/tools/nsc/util/CommandLineParser.scala @@ -1,5 +1,5 @@ /* NEST (New Scala Test) - * Copyright 2007-2011 LAMP/EPFL + * Copyright 2007-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/util/DocStrings.scala b/src/compiler/scala/tools/nsc/util/DocStrings.scala index c88414c423..b096e1bc03 100755 --- a/src/compiler/scala/tools/nsc/util/DocStrings.scala +++ b/src/compiler/scala/tools/nsc/util/DocStrings.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2006-2011 LAMP/EPFL + * Copyright 2006-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/util/FreshNameCreator.scala b/src/compiler/scala/tools/nsc/util/FreshNameCreator.scala index 16bf748414..554a96d627 100644 --- a/src/compiler/scala/tools/nsc/util/FreshNameCreator.scala +++ b/src/compiler/scala/tools/nsc/util/FreshNameCreator.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/util/JavaCharArrayReader.scala b/src/compiler/scala/tools/nsc/util/JavaCharArrayReader.scala index 0dd1f23570..33a3e7f70f 100644 --- a/src/compiler/scala/tools/nsc/util/JavaCharArrayReader.scala +++ b/src/compiler/scala/tools/nsc/util/JavaCharArrayReader.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/util/MsilClassPath.scala b/src/compiler/scala/tools/nsc/util/MsilClassPath.scala index 6215506141..fb55c7aa1a 100644 --- a/src/compiler/scala/tools/nsc/util/MsilClassPath.scala +++ b/src/compiler/scala/tools/nsc/util/MsilClassPath.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2006-2011 LAMP/EPFL + * Copyright 2006-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/util/ScalaClassLoader.scala b/src/compiler/scala/tools/nsc/util/ScalaClassLoader.scala index 5b30d9aacd..25caae9ecb 100644 --- a/src/compiler/scala/tools/nsc/util/ScalaClassLoader.scala +++ b/src/compiler/scala/tools/nsc/util/ScalaClassLoader.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/nsc/util/ShowPickled.scala b/src/compiler/scala/tools/nsc/util/ShowPickled.scala index 53ed96d0d3..d1f3183f68 100644 --- a/src/compiler/scala/tools/nsc/util/ShowPickled.scala +++ b/src/compiler/scala/tools/nsc/util/ShowPickled.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/util/StatisticsInfo.scala b/src/compiler/scala/tools/nsc/util/StatisticsInfo.scala index f6a1ae1414..8cdb96c586 100644 --- a/src/compiler/scala/tools/nsc/util/StatisticsInfo.scala +++ b/src/compiler/scala/tools/nsc/util/StatisticsInfo.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/util/TreeSet.scala b/src/compiler/scala/tools/nsc/util/TreeSet.scala index c816d1eed4..ab1142211f 100644 --- a/src/compiler/scala/tools/nsc/util/TreeSet.scala +++ b/src/compiler/scala/tools/nsc/util/TreeSet.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/compiler/scala/tools/nsc/util/package.scala b/src/compiler/scala/tools/nsc/util/package.scala index 2229b8d997..876fb18578 100644 --- a/src/compiler/scala/tools/nsc/util/package.scala +++ b/src/compiler/scala/tools/nsc/util/package.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/reflect/FastTrack.scala b/src/compiler/scala/tools/reflect/FastTrack.scala index 237ef813c7..f84877cccb 100644 --- a/src/compiler/scala/tools/reflect/FastTrack.scala +++ b/src/compiler/scala/tools/reflect/FastTrack.scala @@ -28,7 +28,7 @@ trait FastTrack { def run(args: List[Any]): Any = { val c = args(0).asInstanceOf[MacroContext] val result = expander((c, c.expandee)) - c.Expr[Nothing](result)(c.TypeTag.Nothing) + c.Expr[Nothing](result)(c.AbsTypeTag.Nothing) } } @@ -38,7 +38,7 @@ trait FastTrack { MacroInternal_materializeClassTag bindTo { case (c, Apply(TypeApply(_, List(tt)), List(u))) => c.materializeClassTag(u, tt.tpe) } MacroInternal_materializeAbsTypeTag bindTo { case (c, Apply(TypeApply(_, List(tt)), List(u))) => c.materializeTypeTag(u, EmptyTree, tt.tpe, concrete = false) } MacroInternal_materializeTypeTag bindTo { case (c, Apply(TypeApply(_, List(tt)), List(u))) => c.materializeTypeTag(u, EmptyTree, tt.tpe, concrete = true) } - ApiUniverseReify bindTo { case (c, Apply(TypeApply(_, List(tt)), List(expr))) => c.materializeExpr(c.prefix.tree, EmptyTree, expr) } + BaseUniverseReify bindTo { case (c, Apply(TypeApply(_, List(tt)), List(expr))) => c.materializeExpr(c.prefix.tree, EmptyTree, expr) } ReflectRuntimeCurrentMirror bindTo { case (c, _) => scala.reflect.runtime.Macros.currentMirror(c).tree } StringContext_f bindTo { case (c, app@Apply(Select(Apply(_, parts), _), args)) => c.macro_StringInterpolation_f(parts, args, app.pos) } registry diff --git a/src/compiler/scala/tools/reflect/MacroImplementations.scala b/src/compiler/scala/tools/reflect/MacroImplementations.scala index e1b959cefa..40ceefcc70 100644 --- a/src/compiler/scala/tools/reflect/MacroImplementations.scala +++ b/src/compiler/scala/tools/reflect/MacroImplementations.scala @@ -1,7 +1,7 @@ package scala.tools.reflect -import scala.reflect.makro.{ReificationError, UnexpectedReificationError} -import scala.reflect.makro.runtime.Context +import scala.reflect.macros.{ReificationError, UnexpectedReificationError} +import scala.reflect.macros.runtime.Context import scala.collection.mutable.ListBuffer import scala.collection.mutable.Stack @@ -25,9 +25,9 @@ abstract class MacroImplementations { c.abort(args(parts.length-1).pos, "too many arguments for interpolated string") } - val stringParts = parts map { + val stringParts = parts map { case Literal(Constant(s: String)) => s; - case _ => throw new IllegalArgumentException("argument parts must be a list of string literals") + case _ => throw new IllegalArgumentException("argument parts must be a list of string literals") } val pi = stringParts.iterator diff --git a/src/compiler/scala/tools/reflect/StdTags.scala b/src/compiler/scala/tools/reflect/StdTags.scala index 25a42a82cd..0704189ddc 100644 --- a/src/compiler/scala/tools/reflect/StdTags.scala +++ b/src/compiler/scala/tools/reflect/StdTags.scala @@ -20,7 +20,7 @@ trait StdTags { def apply[U <: BaseUniverse with Singleton](m: MirrorOf[U]): U # Type = { val u = m.universe val pre = u.ThisType(m.staticPackage("scala.collection.immutable").moduleClass.asInstanceOf[u.Symbol]) - u.TypeRef(pre, u.definitions.ListClass, List(u.definitions.StringClass.asTypeConstructor)) + u.TypeRef(pre, u.definitions.ListClass, List(u.definitions.StringClass.toTypeConstructor)) } }) @@ -29,7 +29,7 @@ trait StdTags { m, new TypeCreator { def apply[U <: BaseUniverse with Singleton](m: MirrorOf[U]): U # Type = - m.staticClass(classTag[T].runtimeClass.getName).asTypeConstructor.asInstanceOf[U # Type] + m.staticClass(classTag[T].runtimeClass.getName).toTypeConstructor.asInstanceOf[U # Type] }) lazy val tagOfInt = u.TypeTag.Int lazy val tagOfString = tagOfStaticClass[String] @@ -52,7 +52,7 @@ object StdRuntimeTags extends StdTags { } abstract class StdContextTags extends StdTags { - val tc: scala.reflect.makro.Context + val tc: scala.reflect.macros.Context val u: tc.universe.type = tc.universe val m = tc.mirror } diff --git a/src/compiler/scala/tools/reflect/ToolBoxFactory.scala b/src/compiler/scala/tools/reflect/ToolBoxFactory.scala index 6c48762200..eeec973299 100644 --- a/src/compiler/scala/tools/reflect/ToolBoxFactory.scala +++ b/src/compiler/scala/tools/reflect/ToolBoxFactory.scala @@ -85,7 +85,7 @@ abstract class ToolBoxFactory[U <: JavaUniverse](val u: U) { factorySelf => if (tree.hasSymbol && tree.symbol.isFreeTerm) { tree match { case Ident(_) => - val freeTermRef = Ident(freeTermNames(tree.symbol.asFreeTermSymbol)) + val freeTermRef = Ident(freeTermNames(tree.symbol.asFreeTerm)) if (wrapFreeTermRefs) Apply(freeTermRef, List()) else freeTermRef case _ => throw new Error("internal error: %s (%s, %s) is not supported".format(tree, tree.productPrefix, tree.getClass)) @@ -256,7 +256,8 @@ abstract class ToolBoxFactory[U <: JavaUniverse](val u: U) { factorySelf => // } val (singleton, jmeth) = compileExpr(expr) val result = jmeth.invoke(singleton, thunks map (_.asInstanceOf[AnyRef]): _*) - result + if (jmeth.getReturnType == java.lang.Void.TYPE) () + else result } def parseExpr(code: String): Tree = { @@ -350,7 +351,7 @@ abstract class ToolBoxFactory[U <: JavaUniverse](val u: U) { factorySelf => } def inferImplicitView(tree: u.Tree, from: u.Type, to: u.Type, silent: Boolean = true, withMacrosDisabled: Boolean = false, pos: u.Position = u.NoPosition): u.Tree = { - val viewTpe = u.appliedType(u.definitions.FunctionClass(1).asTypeConstructor, List(from, to)) + val viewTpe = u.appliedType(u.definitions.FunctionClass(1).toTypeConstructor, List(from, to)) inferImplicit(tree, viewTpe, isView = true, silent = silent, withMacrosDisabled = withMacrosDisabled, pos = pos) } diff --git a/src/compiler/scala/tools/reflect/WrappedProperties.scala b/src/compiler/scala/tools/reflect/WrappedProperties.scala index 45c1b57d71..6610b9476e 100644 --- a/src/compiler/scala/tools/reflect/WrappedProperties.scala +++ b/src/compiler/scala/tools/reflect/WrappedProperties.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2006-2011 LAMP/EPFL + * Copyright 2006-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/reflect/package.scala b/src/compiler/scala/tools/reflect/package.scala index a3778a3b69..3008930823 100644 --- a/src/compiler/scala/tools/reflect/package.scala +++ b/src/compiler/scala/tools/reflect/package.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/util/Javap.scala b/src/compiler/scala/tools/util/Javap.scala index f4f218350a..ce149a5aa0 100644 --- a/src/compiler/scala/tools/util/Javap.scala +++ b/src/compiler/scala/tools/util/Javap.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/compiler/scala/tools/util/PathResolver.scala b/src/compiler/scala/tools/util/PathResolver.scala index 5f4e6d58c3..739878c282 100644 --- a/src/compiler/scala/tools/util/PathResolver.scala +++ b/src/compiler/scala/tools/util/PathResolver.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2006-2011 LAMP/EPFL + * Copyright 2006-2012 LAMP/EPFL * @author Paul Phillips */ @@ -194,7 +194,7 @@ class PathResolver(settings: Settings, context: JavaContext) { def scalaBootClassPath = cmdLineOrElse("bootclasspath", Defaults.scalaBootClassPath) def scalaExtDirs = cmdLineOrElse("extdirs", Defaults.scalaExtDirs) /** Scaladoc doesn't need any bootstrapping, otherwise will create errors such as: - * [scaladoc] ../scala-trunk/src/reflect/scala/reflect/makro/Reifiers.scala:89: error: object api is not a member of package reflect + * [scaladoc] ../scala-trunk/src/reflect/scala/reflect/macros/Reifiers.scala:89: error: object api is not a member of package reflect * [scaladoc] case class ReificationError(val pos: reflect.api.PositionApi, val msg: String) extends Throwable(msg) * [scaladoc] ^ * because the bootstrapping will look at the sourcepath and create package "reflect" in "<root>" diff --git a/src/continuations/plugin/scala/tools/selectivecps/SelectiveANFTransform.scala b/src/continuations/plugin/scala/tools/selectivecps/SelectiveANFTransform.scala index 211560e343..51760d2807 100644 --- a/src/continuations/plugin/scala/tools/selectivecps/SelectiveANFTransform.scala +++ b/src/continuations/plugin/scala/tools/selectivecps/SelectiveANFTransform.scala @@ -99,11 +99,11 @@ abstract class SelectiveANFTransform extends PluginComponent with Transform with treeCopy.Block(body, List(transform(selDef)), transformPureMatch(mat, selector, cases)) // virtpatmat - case b@Block(matchStats@((selDef: ValDef) :: cases), matchEnd) if ext.isDefined && pureBody && (matchStats forall gen.hasSynthCaseSymbol) => + case b@Block(matchStats@((selDef: ValDef) :: cases), matchEnd) if ext.isDefined && pureBody && (matchStats forall treeInfo.hasSynthCaseSymbol) => transformPureVirtMatch(b, selDef, cases, matchEnd) // virtpatmat that stores the scrut separately -- TODO: can we eliminate this case?? - case Block(List(selDef0: ValDef), mat@Block(matchStats@((selDef: ValDef) :: cases), matchEnd)) if ext.isDefined && pureBody && (matchStats forall gen.hasSynthCaseSymbol)=> + case Block(List(selDef0: ValDef), mat@Block(matchStats@((selDef: ValDef) :: cases), matchEnd)) if ext.isDefined && pureBody && (matchStats forall treeInfo.hasSynthCaseSymbol)=> treeCopy.Block(body, List(transform(selDef0)), transformPureVirtMatch(mat, selDef, cases, matchEnd)) case _ => @@ -253,7 +253,7 @@ abstract class SelectiveANFTransform extends PluginComponent with Transform with // calling each labeldef is wrong, since some labels may be jumped over // we can get away with this for now since the only other labels we emit are for tailcalls/while loops, // which do not have consecutive labeldefs (and thus fall-through is irrelevant) - if (gen.hasSynthCaseSymbol(ldef)) (List(stm1), localTyper.typed{Literal(Constant(()))}, cpsA) + if (treeInfo.hasSynthCaseSymbol(ldef)) (List(stm1), localTyper.typed{Literal(Constant(()))}, cpsA) else { assert(params.isEmpty, "problem in ANF transforming label with non-empty params "+ ldef) (List(stm1), localTyper.typed{Apply(Ident(sym), List())}, cpsA) @@ -469,9 +469,9 @@ abstract class SelectiveANFTransform extends PluginComponent with Transform with val (anfStats, anfExpr) = rec(stms, cpsA, List()) // println("\nanf-block:\n"+ ((stms :+ expr) mkString ("{", "\n", "}")) +"\nBECAME\n"+ ((anfStats :+ anfExpr) mkString ("{", "\n", "}"))) - // println("synth case? "+ (anfStats map (t => (t, t.isDef, gen.hasSynthCaseSymbol(t))))) + // println("synth case? "+ (anfStats map (t => (t, t.isDef, treeInfo.hasSynthCaseSymbol(t))))) // SUPER UGLY HACK: handle virtpatmat-style matches, whose labels have already been turned into DefDefs - if (anfStats.nonEmpty && (anfStats forall (t => !t.isDef || gen.hasSynthCaseSymbol(t)))) { + if (anfStats.nonEmpty && (anfStats forall (t => !t.isDef || treeInfo.hasSynthCaseSymbol(t)))) { val (prologue, rest) = (anfStats :+ anfExpr) span (s => !s.isInstanceOf[DefDef]) // find first case // println("rest: "+ rest) // val (defs, calls) = rest partition (_.isInstanceOf[DefDef]) diff --git a/src/detach/plugin/scala/tools/detach/Detach.scala b/src/detach/plugin/scala/tools/detach/Detach.scala index 41a3795a49..376a56beed 100644 --- a/src/detach/plugin/scala/tools/detach/Detach.scala +++ b/src/detach/plugin/scala/tools/detach/Detach.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Stephane Micheloud */ diff --git a/src/detach/plugin/scala/tools/detach/DetachPlugin.scala b/src/detach/plugin/scala/tools/detach/DetachPlugin.scala index e4e9e6bdfe..d24a96f0ba 100644 --- a/src/detach/plugin/scala/tools/detach/DetachPlugin.scala +++ b/src/detach/plugin/scala/tools/detach/DetachPlugin.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Stephane Micheloud */ diff --git a/src/eclipse/README.md b/src/eclipse/README.md index 7ef775218b..39a3f457a0 100644 --- a/src/eclipse/README.md +++ b/src/eclipse/README.md @@ -29,7 +29,7 @@ inside `src/library` with the following contents: version.number=2.10.0-20120603-141530-b34313db72 maven.version.number=2.10.0-SNAPSHOT osgi.version.number=2.10.0.v20120603-141530-b34313db72 - copyright.string=Copyright 2002-2011, LAMP/EPFL + copyright.string=Copyright 2002-2012 LAMP/EPFL 4. Project files are tracked by Git, so adding them to `.gitignore` won't prevent them from being shown as dirty in `git status`. You can still ignore them by telling Git to diff --git a/src/fjbg/ch/epfl/lamp/fjbg/FJBGContext.java b/src/fjbg/ch/epfl/lamp/fjbg/FJBGContext.java index 4c5bc27237..6265142a46 100644 --- a/src/fjbg/ch/epfl/lamp/fjbg/FJBGContext.java +++ b/src/fjbg/ch/epfl/lamp/fjbg/FJBGContext.java @@ -1,5 +1,5 @@ /* FJBG -- Fast Java Bytecode Generator - * Copyright 2002-2011 LAMP/EPFL + * Copyright 2002-2012 LAMP/EPFL * @author Michel Schinz */ diff --git a/src/fjbg/ch/epfl/lamp/fjbg/JAccessFlags.java b/src/fjbg/ch/epfl/lamp/fjbg/JAccessFlags.java index 0a48fc1628..1a4406cf5b 100644 --- a/src/fjbg/ch/epfl/lamp/fjbg/JAccessFlags.java +++ b/src/fjbg/ch/epfl/lamp/fjbg/JAccessFlags.java @@ -1,5 +1,5 @@ /* FJBG -- Fast Java Bytecode Generator - * Copyright 2002-2011 LAMP/EPFL + * Copyright 2002-2012 LAMP/EPFL * @author Michel Schinz */ diff --git a/src/fjbg/ch/epfl/lamp/fjbg/JArrayType.java b/src/fjbg/ch/epfl/lamp/fjbg/JArrayType.java index 85f9408f46..27b7d443a8 100644 --- a/src/fjbg/ch/epfl/lamp/fjbg/JArrayType.java +++ b/src/fjbg/ch/epfl/lamp/fjbg/JArrayType.java @@ -1,5 +1,5 @@ /* FJBG -- Fast Java Bytecode Generator - * Copyright 2002-2011 LAMP/EPFL + * Copyright 2002-2012 LAMP/EPFL * @author Michel Schinz */ diff --git a/src/fjbg/ch/epfl/lamp/fjbg/JAttribute.java b/src/fjbg/ch/epfl/lamp/fjbg/JAttribute.java index 3b9e5f3a7c..8294cdf783 100644 --- a/src/fjbg/ch/epfl/lamp/fjbg/JAttribute.java +++ b/src/fjbg/ch/epfl/lamp/fjbg/JAttribute.java @@ -1,5 +1,5 @@ /* FJBG -- Fast Java Bytecode Generator - * Copyright 2002-2011 LAMP/EPFL + * Copyright 2002-2012 LAMP/EPFL * @author Michel Schinz */ diff --git a/src/fjbg/ch/epfl/lamp/fjbg/JAttributeFactory.java b/src/fjbg/ch/epfl/lamp/fjbg/JAttributeFactory.java index b66bbd8bc0..c2736ad76c 100644 --- a/src/fjbg/ch/epfl/lamp/fjbg/JAttributeFactory.java +++ b/src/fjbg/ch/epfl/lamp/fjbg/JAttributeFactory.java @@ -1,5 +1,5 @@ /* FJBG -- Fast Java Bytecode Generator - * Copyright 2002-2011 LAMP/EPFL + * Copyright 2002-2012 LAMP/EPFL * @author Michel Schinz */ diff --git a/src/fjbg/ch/epfl/lamp/fjbg/JClass.java b/src/fjbg/ch/epfl/lamp/fjbg/JClass.java index 1d0bc0e19b..a588e43440 100644 --- a/src/fjbg/ch/epfl/lamp/fjbg/JClass.java +++ b/src/fjbg/ch/epfl/lamp/fjbg/JClass.java @@ -1,5 +1,5 @@ /* FJBG -- Fast Java Bytecode Generator - * Copyright 2002-2011 LAMP/EPFL + * Copyright 2002-2012 LAMP/EPFL * @author Michel Schinz */ diff --git a/src/fjbg/ch/epfl/lamp/fjbg/JCode.java b/src/fjbg/ch/epfl/lamp/fjbg/JCode.java index d80f9f5f94..05021c46b3 100644 --- a/src/fjbg/ch/epfl/lamp/fjbg/JCode.java +++ b/src/fjbg/ch/epfl/lamp/fjbg/JCode.java @@ -1,5 +1,5 @@ /* FJBG -- Fast Java Bytecode Generator - * Copyright 2002-2011 LAMP/EPFL + * Copyright 2002-2012 LAMP/EPFL * @author Michel Schinz */ diff --git a/src/fjbg/ch/epfl/lamp/fjbg/JCodeAttribute.java b/src/fjbg/ch/epfl/lamp/fjbg/JCodeAttribute.java index 153f156c55..76dda2fe76 100644 --- a/src/fjbg/ch/epfl/lamp/fjbg/JCodeAttribute.java +++ b/src/fjbg/ch/epfl/lamp/fjbg/JCodeAttribute.java @@ -1,5 +1,5 @@ /* FJBG -- Fast Java Bytecode Generator - * Copyright 2002-2011 LAMP/EPFL + * Copyright 2002-2012 LAMP/EPFL * @author Michel Schinz */ diff --git a/src/fjbg/ch/epfl/lamp/fjbg/JCodeIterator.java b/src/fjbg/ch/epfl/lamp/fjbg/JCodeIterator.java index 989c313c3e..452fa8a76e 100644 --- a/src/fjbg/ch/epfl/lamp/fjbg/JCodeIterator.java +++ b/src/fjbg/ch/epfl/lamp/fjbg/JCodeIterator.java @@ -1,5 +1,5 @@ /* FJBG -- Fast Java Bytecode Generator - * Copyright 2002-2011 LAMP/EPFL + * Copyright 2002-2012 LAMP/EPFL * @author Michel Schinz */ diff --git a/src/fjbg/ch/epfl/lamp/fjbg/JConstantPool.java b/src/fjbg/ch/epfl/lamp/fjbg/JConstantPool.java index ca2985c9e8..7fbe70786e 100644 --- a/src/fjbg/ch/epfl/lamp/fjbg/JConstantPool.java +++ b/src/fjbg/ch/epfl/lamp/fjbg/JConstantPool.java @@ -1,5 +1,5 @@ /* FJBG -- Fast Java Bytecode Generator - * Copyright 2002-2011 LAMP/EPFL + * Copyright 2002-2012 LAMP/EPFL * @author Michel Schinz */ diff --git a/src/fjbg/ch/epfl/lamp/fjbg/JConstantValueAttribute.java b/src/fjbg/ch/epfl/lamp/fjbg/JConstantValueAttribute.java index 6efd3d7d34..88265c1417 100644 --- a/src/fjbg/ch/epfl/lamp/fjbg/JConstantValueAttribute.java +++ b/src/fjbg/ch/epfl/lamp/fjbg/JConstantValueAttribute.java @@ -1,5 +1,5 @@ /* FJBG -- Fast Java Bytecode Generator - * Copyright 2002-2011 LAMP/EPFL + * Copyright 2002-2012 LAMP/EPFL * @author Michel Schinz */ diff --git a/src/fjbg/ch/epfl/lamp/fjbg/JEnclosingMethodAttribute.java b/src/fjbg/ch/epfl/lamp/fjbg/JEnclosingMethodAttribute.java index 5536a3bbcd..b8f34bd595 100644 --- a/src/fjbg/ch/epfl/lamp/fjbg/JEnclosingMethodAttribute.java +++ b/src/fjbg/ch/epfl/lamp/fjbg/JEnclosingMethodAttribute.java @@ -1,5 +1,5 @@ /* FJBG -- Fast Java Bytecode Generator - * Copyright 2002-2011 LAMP/EPFL + * Copyright 2002-2012 LAMP/EPFL * @author Michel Schinz */ diff --git a/src/fjbg/ch/epfl/lamp/fjbg/JExceptionsAttribute.java b/src/fjbg/ch/epfl/lamp/fjbg/JExceptionsAttribute.java index aee34de219..a629947505 100644 --- a/src/fjbg/ch/epfl/lamp/fjbg/JExceptionsAttribute.java +++ b/src/fjbg/ch/epfl/lamp/fjbg/JExceptionsAttribute.java @@ -1,5 +1,5 @@ /* FJBG -- Fast Java Bytecode Generator - * Copyright 2002-2011 LAMP/EPFL + * Copyright 2002-2012 LAMP/EPFL * @author Michel Schinz */ diff --git a/src/fjbg/ch/epfl/lamp/fjbg/JExtendedCode.java b/src/fjbg/ch/epfl/lamp/fjbg/JExtendedCode.java index d4c5417260..ca859e1042 100644 --- a/src/fjbg/ch/epfl/lamp/fjbg/JExtendedCode.java +++ b/src/fjbg/ch/epfl/lamp/fjbg/JExtendedCode.java @@ -1,5 +1,5 @@ /* FJBG -- Fast Java Bytecode Generator - * Copyright 2002-2011 LAMP/EPFL + * Copyright 2002-2012 LAMP/EPFL * @author Michel Schinz */ diff --git a/src/fjbg/ch/epfl/lamp/fjbg/JField.java b/src/fjbg/ch/epfl/lamp/fjbg/JField.java index 1456157bc7..314ed70805 100644 --- a/src/fjbg/ch/epfl/lamp/fjbg/JField.java +++ b/src/fjbg/ch/epfl/lamp/fjbg/JField.java @@ -1,5 +1,5 @@ /* FJBG -- Fast Java Bytecode Generator - * Copyright 2002-2011 LAMP/EPFL + * Copyright 2002-2012 LAMP/EPFL * @author Michel Schinz */ diff --git a/src/fjbg/ch/epfl/lamp/fjbg/JFieldOrMethod.java b/src/fjbg/ch/epfl/lamp/fjbg/JFieldOrMethod.java index 3d2bf87264..dfffc83ed0 100644 --- a/src/fjbg/ch/epfl/lamp/fjbg/JFieldOrMethod.java +++ b/src/fjbg/ch/epfl/lamp/fjbg/JFieldOrMethod.java @@ -1,5 +1,5 @@ /* FJBG -- Fast Java Bytecode Generator - * Copyright 2002-2011 LAMP/EPFL + * Copyright 2002-2012 LAMP/EPFL * @author Michel Schinz */ diff --git a/src/fjbg/ch/epfl/lamp/fjbg/JInnerClassesAttribute.java b/src/fjbg/ch/epfl/lamp/fjbg/JInnerClassesAttribute.java index 200bf1713b..07dd805166 100644 --- a/src/fjbg/ch/epfl/lamp/fjbg/JInnerClassesAttribute.java +++ b/src/fjbg/ch/epfl/lamp/fjbg/JInnerClassesAttribute.java @@ -1,5 +1,5 @@ /* FJBG -- Fast Java Bytecode Generator - * Copyright 2002-2011 LAMP/EPFL + * Copyright 2002-2012 LAMP/EPFL * @author Michel Schinz */ diff --git a/src/fjbg/ch/epfl/lamp/fjbg/JLabel.java b/src/fjbg/ch/epfl/lamp/fjbg/JLabel.java index 77148c89aa..5b7c0f9ba7 100644 --- a/src/fjbg/ch/epfl/lamp/fjbg/JLabel.java +++ b/src/fjbg/ch/epfl/lamp/fjbg/JLabel.java @@ -1,5 +1,5 @@ /* FJBG -- Fast Java Bytecode Generator - * Copyright 2002-2011 LAMP/EPFL + * Copyright 2002-2012 LAMP/EPFL * @author Michel Schinz */ diff --git a/src/fjbg/ch/epfl/lamp/fjbg/JLineNumberTableAttribute.java b/src/fjbg/ch/epfl/lamp/fjbg/JLineNumberTableAttribute.java index af7145939e..05b645dedb 100644 --- a/src/fjbg/ch/epfl/lamp/fjbg/JLineNumberTableAttribute.java +++ b/src/fjbg/ch/epfl/lamp/fjbg/JLineNumberTableAttribute.java @@ -1,5 +1,5 @@ /* FJBG -- Fast Java Bytecode Generator - * Copyright 2002-2011 LAMP/EPFL + * Copyright 2002-2012 LAMP/EPFL * @author Michel Schinz */ diff --git a/src/fjbg/ch/epfl/lamp/fjbg/JLocalVariable.java b/src/fjbg/ch/epfl/lamp/fjbg/JLocalVariable.java index ab2c8f2c72..d019b6882b 100644 --- a/src/fjbg/ch/epfl/lamp/fjbg/JLocalVariable.java +++ b/src/fjbg/ch/epfl/lamp/fjbg/JLocalVariable.java @@ -1,5 +1,5 @@ /* FJBG -- Fast Java Bytecode Generator - * Copyright 2002-2011 LAMP/EPFL + * Copyright 2002-2012 LAMP/EPFL * @author Michel Schinz */ diff --git a/src/fjbg/ch/epfl/lamp/fjbg/JLocalVariableTableAttribute.java b/src/fjbg/ch/epfl/lamp/fjbg/JLocalVariableTableAttribute.java index a091898c00..27662f5f68 100644 --- a/src/fjbg/ch/epfl/lamp/fjbg/JLocalVariableTableAttribute.java +++ b/src/fjbg/ch/epfl/lamp/fjbg/JLocalVariableTableAttribute.java @@ -1,5 +1,5 @@ /* FJBG -- Fast Java Bytecode Generator - * Copyright 2002-2011 LAMP/EPFL + * Copyright 2002-2012 LAMP/EPFL * @author Michel Schinz */ diff --git a/src/fjbg/ch/epfl/lamp/fjbg/JMember.java b/src/fjbg/ch/epfl/lamp/fjbg/JMember.java index 70d6189b4b..5aaf8bbe90 100644 --- a/src/fjbg/ch/epfl/lamp/fjbg/JMember.java +++ b/src/fjbg/ch/epfl/lamp/fjbg/JMember.java @@ -1,5 +1,5 @@ /* FJBG -- Fast Java Bytecode Generator - * Copyright 2002-2011 LAMP/EPFL + * Copyright 2002-2012 LAMP/EPFL * @author Michel Schinz */ diff --git a/src/fjbg/ch/epfl/lamp/fjbg/JMethod.java b/src/fjbg/ch/epfl/lamp/fjbg/JMethod.java index ad35c76da3..472b9a733a 100644 --- a/src/fjbg/ch/epfl/lamp/fjbg/JMethod.java +++ b/src/fjbg/ch/epfl/lamp/fjbg/JMethod.java @@ -1,5 +1,5 @@ /* FJBG -- Fast Java Bytecode Generator - * Copyright 2002-2011 LAMP/EPFL + * Copyright 2002-2012 LAMP/EPFL * @author Michel Schinz */ diff --git a/src/fjbg/ch/epfl/lamp/fjbg/JMethodType.java b/src/fjbg/ch/epfl/lamp/fjbg/JMethodType.java index a0197de972..ca9cbb6ba4 100644 --- a/src/fjbg/ch/epfl/lamp/fjbg/JMethodType.java +++ b/src/fjbg/ch/epfl/lamp/fjbg/JMethodType.java @@ -1,5 +1,5 @@ /* FJBG -- Fast Java Bytecode Generator - * Copyright 2002-2011 LAMP/EPFL + * Copyright 2002-2012 LAMP/EPFL * @author Michel Schinz */ diff --git a/src/fjbg/ch/epfl/lamp/fjbg/JObjectType.java b/src/fjbg/ch/epfl/lamp/fjbg/JObjectType.java index 50ccae79c0..8711588819 100644 --- a/src/fjbg/ch/epfl/lamp/fjbg/JObjectType.java +++ b/src/fjbg/ch/epfl/lamp/fjbg/JObjectType.java @@ -1,5 +1,5 @@ /* FJBG -- Fast Java Bytecode Generator - * Copyright 2002-2011 LAMP/EPFL + * Copyright 2002-2012 LAMP/EPFL * @author Michel Schinz */ diff --git a/src/fjbg/ch/epfl/lamp/fjbg/JOpcode.java b/src/fjbg/ch/epfl/lamp/fjbg/JOpcode.java index 4c971a1838..8266fd5e6c 100644 --- a/src/fjbg/ch/epfl/lamp/fjbg/JOpcode.java +++ b/src/fjbg/ch/epfl/lamp/fjbg/JOpcode.java @@ -1,5 +1,5 @@ /* FJBG -- Fast Java Bytecode Generator - * Copyright 2002-2011 LAMP/EPFL + * Copyright 2002-2012 LAMP/EPFL * @author Michel Schinz */ diff --git a/src/fjbg/ch/epfl/lamp/fjbg/JOtherAttribute.java b/src/fjbg/ch/epfl/lamp/fjbg/JOtherAttribute.java index dcee9c2c13..4eb3b48785 100644 --- a/src/fjbg/ch/epfl/lamp/fjbg/JOtherAttribute.java +++ b/src/fjbg/ch/epfl/lamp/fjbg/JOtherAttribute.java @@ -1,5 +1,5 @@ /* FJBG -- Fast Java Bytecode Generator - * Copyright 2002-2011 LAMP/EPFL + * Copyright 2002-2012 LAMP/EPFL * @author Michel Schinz */ diff --git a/src/fjbg/ch/epfl/lamp/fjbg/JReferenceType.java b/src/fjbg/ch/epfl/lamp/fjbg/JReferenceType.java index 646b0f878d..9cbfe8bddd 100644 --- a/src/fjbg/ch/epfl/lamp/fjbg/JReferenceType.java +++ b/src/fjbg/ch/epfl/lamp/fjbg/JReferenceType.java @@ -1,5 +1,5 @@ /* FJBG -- Fast Java Bytecode Generator - * Copyright 2002-2011 LAMP/EPFL + * Copyright 2002-2012 LAMP/EPFL * @author Michel Schinz */ diff --git a/src/fjbg/ch/epfl/lamp/fjbg/JSourceFileAttribute.java b/src/fjbg/ch/epfl/lamp/fjbg/JSourceFileAttribute.java index 46090b77e9..037e727837 100644 --- a/src/fjbg/ch/epfl/lamp/fjbg/JSourceFileAttribute.java +++ b/src/fjbg/ch/epfl/lamp/fjbg/JSourceFileAttribute.java @@ -1,5 +1,5 @@ /* FJBG -- Fast Java Bytecode Generator - * Copyright 2002-2011 LAMP/EPFL + * Copyright 2002-2012 LAMP/EPFL * @author Michel Schinz */ diff --git a/src/fjbg/ch/epfl/lamp/fjbg/JStackMapTableAttribute.java b/src/fjbg/ch/epfl/lamp/fjbg/JStackMapTableAttribute.java index 52881a2502..2034faa3ea 100644 --- a/src/fjbg/ch/epfl/lamp/fjbg/JStackMapTableAttribute.java +++ b/src/fjbg/ch/epfl/lamp/fjbg/JStackMapTableAttribute.java @@ -1,5 +1,5 @@ /* FJBG -- Fast Java Bytecode Generator - * Copyright 2002-2011 LAMP/EPFL + * Copyright 2002-2012 LAMP/EPFL * @author Michel Schinz */ diff --git a/src/fjbg/ch/epfl/lamp/fjbg/JType.java b/src/fjbg/ch/epfl/lamp/fjbg/JType.java index 2519fc0fe1..25c6b99a52 100644 --- a/src/fjbg/ch/epfl/lamp/fjbg/JType.java +++ b/src/fjbg/ch/epfl/lamp/fjbg/JType.java @@ -1,5 +1,5 @@ /* FJBG -- Fast Java Bytecode Generator - * Copyright 2002-2011 LAMP/EPFL + * Copyright 2002-2012 LAMP/EPFL * @author Michel Schinz */ diff --git a/src/fjbg/ch/epfl/lamp/fjbg/Main.java b/src/fjbg/ch/epfl/lamp/fjbg/Main.java index d8fcdacd95..cab87c3a3a 100644 --- a/src/fjbg/ch/epfl/lamp/fjbg/Main.java +++ b/src/fjbg/ch/epfl/lamp/fjbg/Main.java @@ -1,5 +1,5 @@ /* FJBG -- Fast Java Bytecode Generator - * Copyright 2002-2011 LAMP/EPFL + * Copyright 2002-2012 LAMP/EPFL * @author Michel Schinz */ diff --git a/src/fjbg/ch/epfl/lamp/util/ByteArray.java b/src/fjbg/ch/epfl/lamp/util/ByteArray.java index 0605ae7c20..59a3ac9a12 100644 --- a/src/fjbg/ch/epfl/lamp/util/ByteArray.java +++ b/src/fjbg/ch/epfl/lamp/util/ByteArray.java @@ -1,5 +1,5 @@ /* FJBG -- Fast Java Bytecode Generator - * Copyright 2002-2011 LAMP/EPFL + * Copyright 2002-2012 LAMP/EPFL * @author Michel Schinz */ diff --git a/src/library/scala/Array.scala b/src/library/scala/Array.scala index 6784b630c7..7511b5309d 100644 --- a/src/library/scala/Array.scala +++ b/src/library/scala/Array.scala @@ -439,10 +439,10 @@ object Array extends FallbackArrayBuilding { * example code. * Line 2 is translated into a call to `apply(Int)`, while line 3 is translated into a call to * `update(Int, T)`. - * + * * Two implicit conversions exist in [[scala.Predef]] that are frequently applied to arrays: a conversion * to [[scala.collection.mutable.ArrayOps]] (shown on line 4 of the example above) and a conversion - * to [[scala.collection.mutable.WrappedArray]] (a subtype of [[scala.collections.Seq]]). + * to [[scala.collection.mutable.WrappedArray]] (a subtype of [[scala.collection.Seq]]). * Both types make available many of the standard operations found in the Scala collections API. * The conversion to `ArrayOps` is temporary, as all operations defined on `ArrayOps` return an `Array`, * while the conversion to `WrappedArray` is permanent as all operations return a `WrappedArray`. diff --git a/src/library/scala/Function0.scala b/src/library/scala/Function0.scala index 3690a0e65b..5f87b38057 100644 --- a/src/library/scala/Function0.scala +++ b/src/library/scala/Function0.scala @@ -6,7 +6,7 @@ ** |/ ** \* */ // GENERATED CODE: DO NOT EDIT. -// genprod generated these sources at: Mon Apr 30 07:46:11 PDT 2012 +// genprod generated these sources at: Tue Aug 07 11:54:44 CEST 2012 package scala @@ -33,7 +33,7 @@ package scala * latter can specify inputs which it will not handle. */ -trait Function0[@specialized +R] extends AnyRef { self => +trait Function0[@specialized(Specializable.Primitives) +R] extends AnyRef { self => /** Apply the body of this function to the arguments. * @return the result of function application. */ diff --git a/src/library/scala/Function1.scala b/src/library/scala/Function1.scala index f9b37fc6bd..22393c65dd 100644 --- a/src/library/scala/Function1.scala +++ b/src/library/scala/Function1.scala @@ -32,7 +32,7 @@ package scala */ @annotation.implicitNotFound(msg = "No implicit view available from ${T1} => ${R}.") -trait Function1[@specialized(scala.Int, scala.Long, scala.Float, scala.Double, scala.AnyRef) -T1, @specialized(scala.Unit, scala.Boolean, scala.Int, scala.Float, scala.Long, scala.Double, scala.AnyRef) +R] extends AnyRef { self => +trait Function1[@specialized(scala.Int, scala.Long, scala.Float, scala.Double/*, scala.AnyRef*/) -T1, @specialized(scala.Unit, scala.Boolean, scala.Int, scala.Float, scala.Long, scala.Double/*, scala.AnyRef*/) +R] extends AnyRef { self => /** Apply the body of this function to the argument. * @return the result of function application. */ diff --git a/src/library/scala/Predef.scala b/src/library/scala/Predef.scala index 44025d5358..f3d36473dd 100644 --- a/src/library/scala/Predef.scala +++ b/src/library/scala/Predef.scala @@ -115,8 +115,11 @@ object Predef extends LowPriorityImplicits { @deprecated("This notion doesn't have a corresponding concept in 2.10, because scala.reflect.runtime.universe.TypeTag can capture arbitrary types. Use type tags instead of manifests, and there will be no need in opt manifests.", "2.10.0") val NoManifest = scala.reflect.NoManifest + @deprecated("Use scala.reflect.classTag[T] and scala.reflect.runtime.universe.typeTag[T] instead", "2.10.0") def manifest[T](implicit m: Manifest[T]) = m + @deprecated("Use scala.reflect.classTag[T] instead", "2.10.0") def classManifest[T](implicit m: ClassManifest[T]) = m + @deprecated("This notion doesn't have a corresponding concept in 2.10, because scala.reflect.runtime.universe.TypeTag can capture arbitrary types. Use type tags instead of manifests, and there will be no need in opt manifests.", "2.10.0") def optManifest[T](implicit m: OptManifest[T]) = m // Minor variations on identity functions diff --git a/src/library/scala/StringContext.scala b/src/library/scala/StringContext.scala index 7d37fa4aa1..723d95a499 100644 --- a/src/library/scala/StringContext.scala +++ b/src/library/scala/StringContext.scala @@ -8,8 +8,6 @@ package scala -import language.experimental.macros - /** A class to support string interpolation. * This class supports string interpolation as outlined in Scala SIP-11. * It needs to be fully documented once the SIP is accepted. @@ -99,7 +97,7 @@ case class StringContext(parts: String*) { * format specifier `%%`. */ // The implementation is magically hardwired into `scala.tools.reflect.MacroImplementations.macro_StringInterpolation_f` - def f(args: Any*): String = macro ??? + def f(args: Any*): String = ??? // macro } object StringContext { diff --git a/src/library/scala/Tuple2.scala b/src/library/scala/Tuple2.scala index 5e77127080..35d5a441c8 100644 --- a/src/library/scala/Tuple2.scala +++ b/src/library/scala/Tuple2.scala @@ -16,7 +16,7 @@ package scala * @param _1 Element 1 of this Tuple2 * @param _2 Element 2 of this Tuple2 */ -case class Tuple2[@specialized(Int, Long, Double, Char, Boolean, AnyRef) +T1, @specialized(Int, Long, Double, Char, Boolean, AnyRef) +T2](_1: T1, _2: T2) +case class Tuple2[@specialized(Int, Long, Double, Char, Boolean/*, AnyRef*/) +T1, @specialized(Int, Long, Double, Char, Boolean/*, AnyRef*/) +T2](_1: T1, _2: T2) extends Product2[T1, T2] { override def toString() = "(" + _1 + "," + _2 + ")" diff --git a/src/library/scala/collection/SeqLike.scala b/src/library/scala/collection/SeqLike.scala index c87726ef2c..d7418de9c3 100644 --- a/src/library/scala/collection/SeqLike.scala +++ b/src/library/scala/collection/SeqLike.scala @@ -852,7 +852,7 @@ object SeqLike { /** Finds a particular index at which one sequence occurs in another sequence. * Like `indexOf`, but finds the latest occurrence rather than earliest. * - * @see [[scala.collection.SeqLike], method `indexOf` + * @see [[scala.collection.SeqLike]], method `indexOf` */ def lastIndexOf[B]( source: Seq[B], sourceOffset: Int, sourceCount: Int, diff --git a/src/library/scala/reflect/base/Base.scala b/src/library/scala/reflect/base/Base.scala index 53854f160d..714fd365ef 100644 --- a/src/library/scala/reflect/base/Base.scala +++ b/src/library/scala/reflect/base/Base.scala @@ -1,7 +1,6 @@ package scala.reflect package base -import language.experimental.macros import java.io.PrintWriter import scala.annotation.switch import scala.ref.WeakReference @@ -62,7 +61,9 @@ class Base extends Universe { self => class TypeSymbol(val owner: Symbol, override val name: TypeName, flags: FlagSet) extends Symbol(name, flags) with TypeSymbolBase { - override val asTypeConstructor = TypeRef(ThisType(owner), this, Nil) + override def toTypeConstructor = TypeRef(ThisType(owner), this, Nil) + override def toType = TypeRef(ThisType(owner), this, Nil) + override def toTypeIn(site: Type) = TypeRef(ThisType(owner), this, Nil) } implicit val TypeSymbolTag = ClassTag[TypeSymbol](classOf[TypeSymbol]) @@ -170,12 +171,17 @@ class Base extends Universe { self => object BoundedWildcardType extends BoundedWildcardTypeExtractor implicit val BoundedWildcardTypeTag = ClassTag[BoundedWildcardType](classOf[BoundedWildcardType]) - type Scope = Iterable[Symbol] + class Scope(elems: Iterable[Symbol]) extends ScopeBase with MemberScopeBase { + def iterator = elems.iterator + def sorted = elems.toList + } + type MemberScope = Scope implicit val ScopeTag = ClassTag[Scope](classOf[Scope]) + implicit val MemberScopeTag = ClassTag[MemberScope](classOf[MemberScope]) - def newScope = newScopeWith() - def newNestedScope(outer: Iterable[Symbol]) = newScope - def newScopeWith(elems: Symbol*): Scope = elems + def newScope: Scope = newScopeWith() + def newNestedScope(outer: Scope): Scope = newScope + def newScopeWith(elems: Symbol*): Scope = new Scope(elems) abstract class Name(str: String) extends NameBase { override def toString = str @@ -229,7 +235,6 @@ class Base extends Universe { self => override val privateWithin: Name, override val annotations: List[Tree]) extends ModifiersBase { def hasFlag(flags: FlagSet) = (this.flags & flags) != 0 - def hasAllFlags(flags: FlagSet) = (flags & ~this.flags) == 0 } implicit val ModifiersTag = ClassTag[Modifiers](classOf[Modifiers]) @@ -291,16 +296,16 @@ class Base extends Universe { self => object build extends BuildBase { def selectType(owner: Symbol, name: String): TypeSymbol = { val clazz = new ClassSymbol(owner, newTypeName(name), NoFlags) - cached(clazz.fullName)(clazz).asTypeSymbol + cached(clazz.fullName)(clazz).asType } def selectTerm(owner: Symbol, name: String): TermSymbol = { val valu = new MethodSymbol(owner, newTermName(name), NoFlags) - cached(valu.fullName)(valu).asTermSymbol + cached(valu.fullName)(valu).asTerm } def selectOverloadedMethod(owner: Symbol, name: String, index: Int): MethodSymbol = - selectTerm(owner, name).asMethodSymbol + selectTerm(owner, name).asMethod def newNestedSymbol(owner: Symbol, name: Name, pos: Position, flags: Long, isClass: Boolean): Symbol = if (name.isTypeName) @@ -380,7 +385,7 @@ class Base extends Universe { self => object definitions extends DefinitionsBase { lazy val ScalaPackage = staticModule("scala") - lazy val ScalaPackageClass = ScalaPackage.moduleClass.asClassSymbol + lazy val ScalaPackageClass = ScalaPackage.moduleClass.asClass lazy val AnyClass = staticClass("scala.Any") lazy val AnyValClass = staticClass("scala.Any") @@ -461,6 +466,8 @@ class Base extends Universe { self => def treeToString(tree: Tree) = s"<tree ${tree.getClass}>" + def treeType(tree: Tree) = NoType + trait TermTree extends Tree trait TypTree extends Tree diff --git a/src/library/scala/reflect/base/Constants.scala b/src/library/scala/reflect/base/Constants.scala index 8f98e85ad0..ba12b02e92 100644 --- a/src/library/scala/reflect/base/Constants.scala +++ b/src/library/scala/reflect/base/Constants.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/reflect/scala/reflect/api/Exprs.scala b/src/library/scala/reflect/base/Exprs.scala index 8b2a3b4ea8..47af4f3a9d 100644 --- a/src/reflect/scala/reflect/api/Exprs.scala +++ b/src/library/scala/reflect/base/Exprs.scala @@ -1,12 +1,10 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ package scala.reflect -package api - -import scala.reflect.base.TreeCreator +package base trait Exprs { self: Universe => @@ -16,8 +14,8 @@ trait Exprs { self: Universe => def in[U <: Universe with Singleton](otherMirror: MirrorOf[U]): U # Expr[T] def tree: Tree - def staticTpe: Type - def actualTpe: Type + def staticType: Type + def actualType: Type def splice: T val value: T @@ -26,7 +24,7 @@ trait Exprs { self: Universe => override def canEqual(x: Any) = x.isInstanceOf[Expr[_]] override def equals(x: Any) = x.isInstanceOf[Expr[_]] && this.mirror == x.asInstanceOf[Expr[_]].mirror && this.tree == x.asInstanceOf[Expr[_]].tree override def hashCode = mirror.hashCode * 31 + tree.hashCode - override def toString = "Expr["+staticTpe+"]("+tree+")" + override def toString = "Expr["+staticType+"]("+tree+")" } object Expr { @@ -45,8 +43,8 @@ trait Exprs { self: Universe => // [Eugene++] this is important // !!! remove when we have improved type inference for singletons // search for .type] to find other instances - lazy val staticTpe: Type = implicitly[AbsTypeTag[T]].tpe - def actualTpe: Type = tree.tpe + lazy val staticType: Type = implicitly[AbsTypeTag[T]].tpe + def actualType: Type = treeType(tree) def splice: T = throw new UnsupportedOperationException(""" |the function you're calling has not been spliced by the compiler. @@ -58,5 +56,24 @@ trait Exprs { self: Universe => |if you want to splice the underlying expression, use `<your expr>.splice`. |if you want to get a value of the underlying expression, add scala-compiler.jar to the classpath, |import `scala.tools.reflect.Eval` and call `<your expr>.eval` instead.""".trim.stripMargin) + + private def writeReplace(): AnyRef = new SerializedExpr(treec, implicitly[AbsTypeTag[T]].in(scala.reflect.basis.rootMirror)) + } +} + +private[scala] class SerializedExpr(var treec: TreeCreator, var tag: scala.reflect.basis.AbsTypeTag[_]) extends Serializable { + private def writeObject(out: java.io.ObjectOutputStream): Unit = { + out.writeObject(treec) + out.writeObject(tag) + } + + private def readObject(in: java.io.ObjectInputStream): Unit = { + treec = in.readObject().asInstanceOf[TreeCreator] + tag = in.readObject().asInstanceOf[scala.reflect.basis.AbsTypeTag[_]] + } + + private def readResolve(): AnyRef = { + import scala.reflect.basis._ + Expr(rootMirror, treec)(tag) } }
\ No newline at end of file diff --git a/src/library/scala/reflect/base/FlagSets.scala b/src/library/scala/reflect/base/FlagSets.scala index 57946d0f27..43de9970c0 100644 --- a/src/library/scala/reflect/base/FlagSets.scala +++ b/src/library/scala/reflect/base/FlagSets.scala @@ -13,5 +13,11 @@ trait FlagSets { self: Universe => /** The empty set of flags */ val NoFlags: FlagSet + + /** The base API all flag bearers support */ + trait HasFlagsBase { + def flags: FlagSet + def hasFlag(flags: FlagSet): Boolean + } } diff --git a/src/library/scala/reflect/base/Scopes.scala b/src/library/scala/reflect/base/Scopes.scala index a5db01c0ce..a388fdc392 100644 --- a/src/library/scala/reflect/base/Scopes.scala +++ b/src/library/scala/reflect/base/Scopes.scala @@ -3,13 +3,33 @@ package base trait Scopes { self: Universe => - type Scope >: Null <: Iterable[Symbol] + type Scope >: Null <: ScopeBase + + /** The base API that all scopes support */ + trait ScopeBase extends Iterable[Symbol] /** A tag that preserves the identity of the `Scope` abstract type from erasure. * Can be used for pattern matching, instance tests, serialization and likes. */ implicit val ScopeTag: ClassTag[Scope] + type MemberScope >: Null <: Scope with MemberScopeBase + + /** The base API that all member scopes support */ + trait MemberScopeBase extends ScopeBase { + /** Sorts the symbols included in this scope so that: + * 1) Symbols appear the linearization order of their owners. + * 2) Symbols with the same owner appear in reverse order of their declarations. + * 3) Synthetic members (e.g. getters/setters for vals/vars) might appear in arbitrary order. + */ + def sorted: List[Symbol] + } + + /** A tag that preserves the identity of the `MemberScope` abstract type from erasure. + * Can be used for pattern matching, instance tests, serialization and likes. + */ + implicit val MemberScopeTag: ClassTag[MemberScope] + /** Create a new scope */ def newScope: Scope diff --git a/src/library/scala/reflect/base/StandardDefinitions.scala b/src/library/scala/reflect/base/StandardDefinitions.scala index 2f270a5911..fe32fdb4c2 100644 --- a/src/library/scala/reflect/base/StandardDefinitions.scala +++ b/src/library/scala/reflect/base/StandardDefinitions.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/library/scala/reflect/base/StandardNames.scala b/src/library/scala/reflect/base/StandardNames.scala index 50399a4a1e..3e569cd523 100644 --- a/src/library/scala/reflect/base/StandardNames.scala +++ b/src/library/scala/reflect/base/StandardNames.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler -* Copyright 2005-2011 LAMP/EPFL +* Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/library/scala/reflect/base/Symbols.scala b/src/library/scala/reflect/base/Symbols.scala index ced1f33395..fe857c540f 100644 --- a/src/library/scala/reflect/base/Symbols.scala +++ b/src/library/scala/reflect/base/Symbols.scala @@ -80,10 +80,6 @@ trait Symbols { self: Universe => /** The base API that all symbols support */ trait SymbolBase { this: Symbol => - /** An id number which is unique for all symbols in this universe */ - // [Eugene++ to Martin] do we leave this here? - def id: Int - /** The owner of this symbol. This is the symbol * that directly contains the current symbol's definition. * The `NoSymbol` symbol does not have an owner, and calling this method @@ -112,18 +108,6 @@ trait Symbols { self: Universe => */ def fullName: String - /** If this symbol is a class, this symbol; otherwise the next enclosing - * class, or `NoSymbol` if none exists. - */ - def enclosingClass: Symbol = - if (isClass || this == NoSymbol) this else owner.enclosingClass - - /** If this symbol is a method, this symbol; otherwise the next enclosing - * method, or `NoSymbol` if none exists. - */ - def enclosingMethod: Symbol = - if (isMethod || this == NoSymbol) this else owner.enclosingMethod - /** Does this symbol represent the definition of a type? * Note that every symbol is either a term or a type. * So for every symbol `sym`, either `sym.isTerm` is true @@ -132,9 +116,9 @@ trait Symbols { self: Universe => def isType: Boolean = false /** This symbol cast to a TypeSymbol. - * Returns ClassCastException if `isType` is false. + * @throws ScalaReflectionException if `isType` is false. */ - def asTypeSymbol: TypeSymbol = throw new ClassCastException(toString) + def asType: TypeSymbol = throw new ScalaReflectionException(s"$this is not a type") /** Does this symbol represent the definition of a term? * Note that every symbol is either a term or a term. @@ -144,9 +128,9 @@ trait Symbols { self: Universe => def isTerm: Boolean = false /** This symbol cast to a TermSymbol. - * Returns ClassCastException if `isTerm` is false. + * @throws ScalaReflectionException if `isTerm` is false. */ - def asTermSymbol: TermSymbol = throw new ClassCastException(toString) + def asTerm: TermSymbol = throw new ScalaReflectionException(s"$this is not a term") /** Does this symbol represent the definition of a method? * If yes, `isTerm` is also guaranteed to be true. @@ -154,9 +138,19 @@ trait Symbols { self: Universe => def isMethod: Boolean = false /** This symbol cast to a MethodSymbol. - * Returns ClassCastException if `isMethod` is false. + * @throws ScalaReflectionException if `isMethod` is false. */ - def asMethodSymbol: MethodSymbol = throw new ClassCastException(toString) + def asMethod: MethodSymbol = { + def overloadedMsg = + "encapsulates multiple overloaded alternatives and cannot be treated as a method. "+ + "Consider invoking `<offending symbol>.asTerm.alternatives` and manually picking the required method" + def vanillaMsg = "is not a method" + val msg = if (isOverloadedMethod) overloadedMsg else vanillaMsg + throw new ScalaReflectionException(s"$this $msg") + } + + /** Used to provide a better error message for `asMethod` */ + protected def isOverloadedMethod = false /** Does this symbol represent the definition of a module (i.e. it * results from an object definition?). @@ -165,9 +159,9 @@ trait Symbols { self: Universe => def isModule: Boolean = false /** This symbol cast to a ModuleSymbol defined by an object definition. - * Returns ClassCastException if `isModule` is false. + * @throws ScalaReflectionException if `isModule` is false. */ - def asModuleSymbol: ModuleSymbol = throw new ClassCastException(toString) + def asModule: ModuleSymbol = throw new ScalaReflectionException(s"$this is not a module") /** Does this symbol represent the definition of a class or trait? * If yes, `isType` is also guaranteed to be true. @@ -181,9 +175,9 @@ trait Symbols { self: Universe => def isModuleClass: Boolean = false /** This symbol cast to a ClassSymbol representing a class or trait. - * Returns ClassCastException if `isClass` is false. + * @throws ScalaReflectionException if `isClass` is false. */ - def asClassSymbol: ClassSymbol = throw new ClassCastException(toString) + def asClass: ClassSymbol = throw new ScalaReflectionException(s"$this is not a class") /** Does this symbol represent a free term captured by reification? * If yes, `isTerm` is also guaranteed to be true. @@ -191,9 +185,9 @@ trait Symbols { self: Universe => def isFreeTerm: Boolean = false /** This symbol cast to a free term symbol. - * Returns ClassCastException if `isFreeTerm` is false. + * @throws ScalaReflectionException if `isFreeTerm` is false. */ - def asFreeTermSymbol: FreeTermSymbol = throw new ClassCastException(toString) + def asFreeTerm: FreeTermSymbol = throw new ScalaReflectionException(s"$this is not a free term") /** Does this symbol represent a free type captured by reification? * If yes, `isType` is also guaranteed to be true. @@ -201,9 +195,9 @@ trait Symbols { self: Universe => def isFreeType: Boolean = false /** This symbol cast to a free type symbol. - * Returns ClassCastException if `isFreeType` is false. + * @throws ScalaReflectionException if `isFreeType` is false. */ - def asFreeTypeSymbol: FreeTypeSymbol = throw new ClassCastException(toString) + def asFreeType: FreeTypeSymbol = throw new ScalaReflectionException(s"$this is not a free type") def newTermSymbol(name: TermName, pos: Position = NoPosition, flags: FlagSet = NoFlags): TermSymbol def newModuleAndClassSymbol(name: Name, pos: Position = NoPosition, flags: FlagSet = NoFlags): (ModuleSymbol, ClassSymbol) @@ -219,16 +213,34 @@ trait Symbols { self: Universe => final type NameType = TypeName /** The type constructor corresponding to this type symbol. - * This is different from `asType` in that type parameters - * are part of results of `asType`, but not of `asTypeConstructor`. + * This is different from `toType` in that type parameters + * are part of results of `toType`, but not of `toTypeConstructor`. * * Example: Given a class declaration `class C[T] { ... } `, that generates a symbol - * `C`. Then `C.asType` is the type `C[T]`, but `C.asTypeConstructor` is `C`. + * `C`. Then `C.toType` is the type `C[T]`, but `C.toTypeConstructor` is `C`. + */ + def toTypeConstructor: Type + + /** A type reference that refers to this type symbol seen + * as a member of given type `site`. */ - def asTypeConstructor: Type + def toTypeIn(site: Type): Type + + /** A type reference that refers to this type symbol + * Note if symbol is a member of a class, one almost always is interested + * in `asTypeIn` with a site type instead. + * + * Example: Given a class declaration `class C[T] { ... } `, that generates a symbol + * `C`. Then `C.toType` is the type `C[T]`. + * + * By contrast, `C.typeSignature` would be a type signature of form + * `PolyType(ClassInfoType(...))` that describes type parameters, value + * parameters, parent types, and members of `C`. + */ + def toType: Type override def isType = true - override def asTypeSymbol = this + override def asType = this } /** The base API that all term symbols support */ @@ -238,13 +250,13 @@ trait Symbols { self: Universe => final type NameType = TermName final override def isTerm = true - final override def asTermSymbol = this + final override def asTerm = this } /** The base API that all method symbols support */ trait MethodSymbolBase extends TermSymbolBase { this: MethodSymbol => final override def isMethod = true - final override def asMethodSymbol = this + final override def asMethod = this } /** The base API that all module symbols support */ @@ -257,24 +269,24 @@ trait Symbols { self: Universe => // [Eugene++] when this becomes `moduleClass: ClassSymbol`, it will be the happiest day in my life final override def isModule = true - final override def asModuleSymbol = this + final override def asModule = this } /** The base API that all class symbols support */ trait ClassSymbolBase extends TypeSymbolBase { this: ClassSymbol => final override def isClass = true - final override def asClassSymbol = this + final override def asClass = this } /** The base API that all free type symbols support */ trait FreeTypeSymbolBase extends TypeSymbolBase { this: FreeTypeSymbol => final override def isFreeType = true - final override def asFreeTypeSymbol = this + final override def asFreeType = this } /** The base API that all free term symbols support */ trait FreeTermSymbolBase extends TermSymbolBase { this: FreeTermSymbol => final override def isFreeTerm = true - final override def asFreeTermSymbol = this + final override def asFreeTerm = this } } diff --git a/src/library/scala/reflect/base/Trees.scala b/src/library/scala/reflect/base/Trees.scala index 2814450ae3..7fa3c90e7d 100644 --- a/src/library/scala/reflect/base/Trees.scala +++ b/src/library/scala/reflect/base/Trees.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ package scala.reflect @@ -34,6 +34,9 @@ trait Trees { self: Universe => /** Obtains string representation of a tree */ protected def treeToString(tree: Tree): String + /** Obtains the type of the tree (we intentionally don't expose `tree.tpe` in base) */ + protected def treeType(tree: Tree): Type + /** Tree is the basis for scala's abstract syntax. The nodes are * implemented as case classes, and the parameters which initialize * a given tree are immutable: however Trees have several mutable @@ -1356,10 +1359,7 @@ trait Trees { self: Universe => implicit val ModifiersTag: ClassTag[Modifiers] /** ... */ - abstract class ModifiersBase { - def flags: FlagSet - def hasFlag(flags: FlagSet): Boolean - def hasAllFlags(flags: FlagSet): Boolean + abstract class ModifiersBase extends HasFlagsBase { def privateWithin: Name // default: EmptyTypeName def annotations: List[Tree] // default: List() def mapAnnotations(f: List[Tree] => List[Tree]): Modifiers = diff --git a/src/library/scala/reflect/base/TypeTags.scala b/src/library/scala/reflect/base/TypeTags.scala index 05b1a079d7..b673122d00 100644 --- a/src/library/scala/reflect/base/TypeTags.scala +++ b/src/library/scala/reflect/base/TypeTags.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ @@ -169,6 +169,7 @@ trait TypeTags { self: Universe => val otherMirror1 = otherMirror.asInstanceOf[MirrorOf[otherMirror.universe.type]] otherMirror.universe.AbsTypeTag[T](otherMirror1, tpec) } + private def writeReplace(): AnyRef = new SerializedTypeTag(tpec, concrete = false) } /** @@ -233,13 +234,18 @@ trait TypeTags { self: Universe => val otherMirror1 = otherMirror.asInstanceOf[MirrorOf[otherMirror.universe.type]] otherMirror.universe.TypeTag[T](otherMirror1, tpec) } + private def writeReplace(): AnyRef = new SerializedTypeTag(tpec, concrete = true) } - private class PredefTypeTag[T](_tpe: Type, copyIn: Universe => Universe # TypeTag[T]) extends TypeTagImpl[T](rootMirror, null) { + private class PredefTypeCreator[T](copyIn: Universe => Universe # TypeTag[T]) extends TypeCreator { + def apply[U <: Universe with Singleton](m: MirrorOf[U]): U # Type = { + copyIn(m.universe).asInstanceOf[U # TypeTag[T]].tpe + } + } + + private class PredefTypeTag[T](_tpe: Type, copyIn: Universe => Universe # TypeTag[T]) extends TypeTagImpl[T](rootMirror, new PredefTypeCreator(copyIn)) { override lazy val tpe: Type = _tpe - override def in[U <: Universe with Singleton](otherMirror: MirrorOf[U]): U # TypeTag[T] = - copyIn(otherMirror.universe).asInstanceOf[U # TypeTag[T]] - private def readResolve() = copyIn(self) + private def writeReplace(): AnyRef = new SerializedTypeTag(tpec, concrete = true) } // incantations @@ -248,3 +254,21 @@ trait TypeTags { self: Universe => // big thanks to Viktor Klang for this brilliant idea! def typeOf[T](implicit ttag: TypeTag[T]): Type = ttag.tpe } + +private[scala] class SerializedTypeTag(var tpec: TypeCreator, var concrete: Boolean) extends Serializable { + private def writeObject(out: java.io.ObjectOutputStream): Unit = { + out.writeObject(tpec) + out.writeBoolean(concrete) + } + + private def readObject(in: java.io.ObjectInputStream): Unit = { + tpec = in.readObject().asInstanceOf[TypeCreator] + concrete = in.readBoolean() + } + + private def readResolve(): AnyRef = { + import scala.reflect.basis._ + if (concrete) TypeTag(rootMirror, tpec) + else AbsTypeTag(rootMirror, tpec) + } +}
\ No newline at end of file diff --git a/src/library/scala/reflect/base/Universe.scala b/src/library/scala/reflect/base/Universe.scala index 93ddcb9f55..f098876c18 100644 --- a/src/library/scala/reflect/base/Universe.scala +++ b/src/library/scala/reflect/base/Universe.scala @@ -10,9 +10,57 @@ abstract class Universe extends Symbols with Constants with AnnotationInfos with Positions + with Exprs with TypeTags with TagInterop with StandardDefinitions with StandardNames with BuildUtils - with Mirrors
\ No newline at end of file + with Mirrors +{ + /** Given an expression, generate a tree that when compiled and executed produces the original tree. + * The produced tree will be bound to the Universe it was called from. + * + * For instance, given the abstract syntax tree representation of the <[ x + 1 ]> expression: + * + * {{{ + * Apply(Select(Ident("x"), "+"), List(Literal(Constant(1)))) + * }}} + * + * The reifier transforms it to the following expression: + * + * {{{ + * <[ + * val $u: u.type = u // where u is a reference to the Universe that calls the reify + * $u.Expr[Int]($u.Apply($u.Select($u.Ident($u.newFreeVar("x", <Int>, x), "+"), List($u.Literal($u.Constant(1)))))) + * ]> + * }}} + * + * Reification performs expression splicing (when processing Expr.splice) + * and type splicing (for every type T that has a TypeTag[T] implicit in scope): + * + * {{{ + * val two = mirror.reify(2) // Literal(Constant(2)) + * val four = mirror.reify(two.splice + two.splice) // Apply(Select(two.tree, newTermName("$plus")), List(two.tree)) + * + * def macroImpl[T](c: Context) = { + * ... + * // T here is just a type parameter, so the tree produced by reify won't be of much use in a macro expansion + * // however, if T were annotated with c.AbsTypeTag (which would declare an implicit parameter for macroImpl) + * // then reification would substitute T with the TypeTree that was used in a TypeApply of this particular macro invocation + * val factory = c.reify{ new Queryable[T] } + * ... + * } + * }}} + * + * The transformation looks mostly straightforward, but it has its tricky parts: + * * Reifier retains symbols and types defined outside the reified tree, however + * locally defined entities get erased and replaced with their original trees + * * Free variables are detected and wrapped in symbols of the type FreeVar + * * Mutable variables that are accessed from a local function are wrapped in refs + * * Since reified trees can be compiled outside of the scope they've been created in, + * special measures are taken to ensure that all members accessed in the reifee remain visible + */ + // implementation is magically hardwired to `scala.reflect.reify.Taggers` + def reify[T](expr: T): Expr[T] = ??? // macro +}
\ No newline at end of file diff --git a/src/library/scala/reflect/makro/internal/macroImpl.scala b/src/library/scala/reflect/macros/internal/macroImpl.scala index 0dfa8d1654..a7b2bf482c 100644 --- a/src/library/scala/reflect/makro/internal/macroImpl.scala +++ b/src/library/scala/reflect/macros/internal/macroImpl.scala @@ -1,4 +1,4 @@ -package scala.reflect.makro +package scala.reflect.macros package internal /** Links macro definitions with their implementation. diff --git a/src/library/scala/reflect/makro/internal/package.scala b/src/library/scala/reflect/macros/internal/package.scala index 78cb0ffb10..912db53ed4 100644 --- a/src/library/scala/reflect/makro/internal/package.scala +++ b/src/library/scala/reflect/macros/internal/package.scala @@ -1,8 +1,7 @@ -package scala.reflect -package makro +package scala.reflect.macros -import language.experimental.macros import scala.reflect.base.{Universe => BaseUniverse} +import scala.reflect.ClassTag // anchors for materialization macros emitted during tag materialization in Implicits.scala // implementation is magically hardwired into `scala.reflect.reify.Taggers` @@ -10,7 +9,7 @@ import scala.reflect.base.{Universe => BaseUniverse} // todo. once we have implicit macros for tag generation, we can remove these anchors // [Eugene++] how do I hide this from scaladoc? package object internal { - private[scala] def materializeClassTag[T](u: BaseUniverse): ClassTag[T] = macro ??? - private[scala] def materializeAbsTypeTag[T](u: BaseUniverse): u.AbsTypeTag[T] = macro ??? - private[scala] def materializeTypeTag[T](u: BaseUniverse): u.TypeTag[T] = macro ??? + private[scala] def materializeClassTag[T](u: BaseUniverse): ClassTag[T] = ??? // macro + private[scala] def materializeAbsTypeTag[T](u: BaseUniverse): u.AbsTypeTag[T] = ??? // macro + private[scala] def materializeTypeTag[T](u: BaseUniverse): u.TypeTag[T] = ??? // macro } diff --git a/src/library/scala/runtime/AbstractFunction0.scala b/src/library/scala/runtime/AbstractFunction0.scala index c4ce0ebcdc..1b351c62ae 100644 --- a/src/library/scala/runtime/AbstractFunction0.scala +++ b/src/library/scala/runtime/AbstractFunction0.scala @@ -9,6 +9,6 @@ package scala.runtime -abstract class AbstractFunction0[@specialized +R] extends Function0[R] { +abstract class AbstractFunction0[@specialized(Specializable.Primitives) +R] extends Function0[R] { } diff --git a/src/library/scala/runtime/AbstractFunction1.scala b/src/library/scala/runtime/AbstractFunction1.scala index b2f336fe52..a68a82e6a2 100644 --- a/src/library/scala/runtime/AbstractFunction1.scala +++ b/src/library/scala/runtime/AbstractFunction1.scala @@ -9,6 +9,6 @@ package scala.runtime -abstract class AbstractFunction1[@specialized(scala.Int, scala.Long, scala.Float, scala.Double, scala.AnyRef) -T1, @specialized(scala.Unit, scala.Boolean, scala.Int, scala.Float, scala.Long, scala.Double, scala.AnyRef) +R] extends Function1[T1, R] { +abstract class AbstractFunction1[@specialized(scala.Int, scala.Long, scala.Float, scala.Double/*, scala.AnyRef*/) -T1, @specialized(scala.Unit, scala.Boolean, scala.Int, scala.Float, scala.Long, scala.Double/*, scala.AnyRef*/) +R] extends Function1[T1, R] { } diff --git a/src/library/scala/runtime/WorksheetSupport.scala b/src/library/scala/runtime/WorksheetSupport.scala index db6d6359a3..6f2a4d382d 100644 --- a/src/library/scala/runtime/WorksheetSupport.scala +++ b/src/library/scala/runtime/WorksheetSupport.scala @@ -14,9 +14,11 @@ object WorksheetSupport { * By default it is 30ms. */ private class FlushedOutputStream(out: OutputStream) extends OutputStream { + protected def flushInterval = 30000000L // interval between flushes, by default 30ms + protected def width = 80 // output width, by default 80 characters + protected def tabInc = 8 // tab increment, by default 8 characters private var lastFlush: Long = 0L - protected val flushInterval = 30000000L // 30ms - private var lastCh: Int = '\n' + private var col = -1 override def write(b: Array[Byte], off: Int, len: Int) = { for (idx <- off until (off + len min b.length)) writeOne(b(idx)) flush() @@ -33,14 +35,18 @@ object WorksheetSupport { } } def writeOne(c: Int) { - if (lastCh == '\n') { - lastCh = 0 + if (col < 0) { + col = 0 write((currentOffset+" ").getBytes) } out.write(c) - lastCh = c + col = + if (c == '\n') -1 + else if (c == '\t') (col / tabInc) * tabInc + tabInc + else col + 1 + if (col >= width) writeOne('\n') } - def ensureNewLine() = if (lastCh != '\n') writeOne('\n') + def ensureNewLine() = if (col > 0) writeOne('\n') } private val flushedOut = new FlushedOutputStream(System.out) @@ -69,7 +75,7 @@ object WorksheetSupport { try op catch { case ex: StopException => ; - case ex => ex.printStackTrace() + case ex: Throwable => ex.printStackTrace() } } diff --git a/src/library/scala/specialized.scala b/src/library/scala/specialized.scala index b876869afb..761c7cb25e 100644 --- a/src/library/scala/specialized.scala +++ b/src/library/scala/specialized.scala @@ -28,5 +28,5 @@ import Specializable._ class specialized(group: SpecializedGroup) extends annotation.StaticAnnotation { def this(types: Specializable*) = this(new Group(types.toList)) - def this() = this(Everything) + def this() = this(Primitives) } diff --git a/src/library/scala/unchecked.scala b/src/library/scala/unchecked.scala index 10d34312cf..5b05792d97 100644 --- a/src/library/scala/unchecked.scala +++ b/src/library/scala/unchecked.scala @@ -6,32 +6,30 @@ ** |/ ** \* */ - - package scala -/** An annotation that gets applied to a selector in a match expression. - * If it is present, exhaustiveness warnings for that expression will be - * suppressed. - * For example, compiling the code: +/** An annotation to designate that the annotated entity + * should not be considered for additional compiler checks. + * Specific applications include annotating the subject of + * a match expression to suppress exhaustiveness warnings, and + * annotating a type argument in a match case to suppress + * unchecked warnings. + * + * Such suppression should be used with caution, without which + * one may encounter [[scala.MatchError]] or [[java.lang.ClassCastException]] + * at runtime. In most cases one can and should address the + * warning instead of suppressing it. + * * {{{ - * object test extends App { - * def f(x: Option[Int]) = x match { - * case Some(y) => y - * } - * f(None) + * object Test extends App { + * // This would normally warn "match is not exhaustive" + * // because `None` is not covered. + * def f(x: Option[String]) = (x: @unchecked) match { case Some(y) => y } + * // This would normally warn "type pattern is unchecked" + * // but here will blindly cast the head element to String. + * def g(xs: Any) = xs match { case x: List[String @unchecked] => x.head } * } - * }}} - * will display the following warning: - * {{{ - * test.scala:2: warning: does not cover case {object None} - * def f(x: Option[int]) = x match { - * ^ - * one warning found - * }}} - * The above message may be suppressed by substituting the expression `x` - * with `(x: @unchecked)`. Then the modified code will compile silently, - * but, in any case, a [[scala.MatchError]] will be raised at runtime. + * }}} * * @since 2.4 */ diff --git a/src/library/scala/util/automata/WordBerrySethi.scala b/src/library/scala/util/automata/WordBerrySethi.scala index 1d4d1f971f..235a74dd7a 100644 --- a/src/library/scala/util/automata/WordBerrySethi.scala +++ b/src/library/scala/util/automata/WordBerrySethi.scala @@ -11,7 +11,7 @@ package scala.util.automata import scala.collection.{ immutable, mutable } import scala.util.regexp.WordExp -/** This class turns a regular expression into a [[scala.util.automata.NondetWorkAutom]] +/** This class turns a regular expression into a [[scala.util.automata.NondetWordAutom]] * celebrated position automata construction (also called ''Berry-Sethi'' or ''Glushkov''). * * @author Burak Emir diff --git a/src/library/scala/xml/parsing/XhtmlParser.scala b/src/library/scala/xml/parsing/XhtmlParser.scala index de9a3f2243..e7e3cc38c9 100644 --- a/src/library/scala/xml/parsing/XhtmlParser.scala +++ b/src/library/scala/xml/parsing/XhtmlParser.scala @@ -12,7 +12,7 @@ package parsing import scala.io.Source /** An XML Parser that preserves `CDATA` blocks and knows about - * [[scala.xml.parsing.HtmlEntities]]. + * [[scala.xml.parsing.XhtmlEntities]]. * * @author (c) David Pollak, 2007 WorldWide Conferencing, LLC. */ diff --git a/src/manual/scala/man1/Command.scala b/src/manual/scala/man1/Command.scala index 16c4307140..d8f2b22dea 100644 --- a/src/manual/scala/man1/Command.scala +++ b/src/manual/scala/man1/Command.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Stephane Micheloud */ diff --git a/src/manual/scala/man1/fsc.scala b/src/manual/scala/man1/fsc.scala index 2aafe7d82c..ed5da09828 100644 --- a/src/manual/scala/man1/fsc.scala +++ b/src/manual/scala/man1/fsc.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Stephane Micheloud */ diff --git a/src/manual/scala/man1/scala.scala b/src/manual/scala/man1/scala.scala index 8daab84d3e..c2a0a2ad01 100644 --- a/src/manual/scala/man1/scala.scala +++ b/src/manual/scala/man1/scala.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Stephane Micheloud */ diff --git a/src/manual/scala/man1/scalac.scala b/src/manual/scala/man1/scalac.scala index 49324ffa83..9e4df51819 100644 --- a/src/manual/scala/man1/scalac.scala +++ b/src/manual/scala/man1/scalac.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Stephane Micheloud */ diff --git a/src/manual/scala/man1/scaladoc.scala b/src/manual/scala/man1/scaladoc.scala index 193c77fc51..ac2a16ccb3 100644 --- a/src/manual/scala/man1/scaladoc.scala +++ b/src/manual/scala/man1/scaladoc.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Stephane Micheloud */ diff --git a/src/manual/scala/man1/scalap.scala b/src/manual/scala/man1/scalap.scala index 88fc91957f..15fd47fb56 100644 --- a/src/manual/scala/man1/scalap.scala +++ b/src/manual/scala/man1/scalap.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Stephane Micheloud */ diff --git a/src/manual/scala/tools/docutil/EmitHtml.scala b/src/manual/scala/tools/docutil/EmitHtml.scala index 43d097a137..076626aa1c 100644 --- a/src/manual/scala/tools/docutil/EmitHtml.scala +++ b/src/manual/scala/tools/docutil/EmitHtml.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Stephane Micheloud * Adapted from Lex Spoon's sbaz manual */ diff --git a/src/manual/scala/tools/docutil/EmitManPage.scala b/src/manual/scala/tools/docutil/EmitManPage.scala index 39d68dbc18..6b54b316ea 100644 --- a/src/manual/scala/tools/docutil/EmitManPage.scala +++ b/src/manual/scala/tools/docutil/EmitManPage.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Stephane Micheloud * Adapted from Lex Spoon's sbaz manual */ diff --git a/src/manual/scala/tools/docutil/ManMaker.scala b/src/manual/scala/tools/docutil/ManMaker.scala index fa35e658dd..b0781127bb 100644 --- a/src/manual/scala/tools/docutil/ManMaker.scala +++ b/src/manual/scala/tools/docutil/ManMaker.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Stephane Micheloud * Adapted from Lex Spoon's sbaz manual */ diff --git a/src/manual/scala/tools/docutil/ManPage.scala b/src/manual/scala/tools/docutil/ManPage.scala index ff7ac1bb4c..6ecf422cc4 100644 --- a/src/manual/scala/tools/docutil/ManPage.scala +++ b/src/manual/scala/tools/docutil/ManPage.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Stephane Micheloud * Adapted from Lex Spoon's sbaz manual */ diff --git a/src/manual/scala/tools/docutil/resources/index.html b/src/manual/scala/tools/docutil/resources/index.html index d1f3bd81f4..aaef94d400 100644 --- a/src/manual/scala/tools/docutil/resources/index.html +++ b/src/manual/scala/tools/docutil/resources/index.html @@ -8,7 +8,7 @@ <meta http-equiv="Content-Style-Type" content="text/css"/> <meta http-equiv="Content-Language" content="en"/> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/> - <meta name="Copyright" content="(C) 2002-2011 LAMP/EPFL"/> + <meta name="Copyright" content="(C) 2002-2012 LAMP/EPFL"/> <meta name="Language" content="en"/> <meta name="Description" content="The Scala Programming Language"/> <meta name="Author" content="Stephane Micheloud"/> diff --git a/src/partest/scala/tools/partest/CompilerTest.scala b/src/partest/scala/tools/partest/CompilerTest.scala index fec9893099..a1450ee876 100644 --- a/src/partest/scala/tools/partest/CompilerTest.scala +++ b/src/partest/scala/tools/partest/CompilerTest.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/partest/scala/tools/partest/DirectTest.scala b/src/partest/scala/tools/partest/DirectTest.scala index 323705b695..ff047daf9e 100644 --- a/src/partest/scala/tools/partest/DirectTest.scala +++ b/src/partest/scala/tools/partest/DirectTest.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/partest/scala/tools/partest/IcodeTest.scala b/src/partest/scala/tools/partest/IcodeTest.scala index 28891f9bbf..ebb194b14f 100644 --- a/src/partest/scala/tools/partest/IcodeTest.scala +++ b/src/partest/scala/tools/partest/IcodeTest.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/partest/scala/tools/partest/ReplTest.scala b/src/partest/scala/tools/partest/ReplTest.scala index c7f17ad2a3..840739089b 100644 --- a/src/partest/scala/tools/partest/ReplTest.scala +++ b/src/partest/scala/tools/partest/ReplTest.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/partest/scala/tools/partest/ScaladocModelTest.scala b/src/partest/scala/tools/partest/ScaladocModelTest.scala index 7117d7c715..b8a41aabe4 100644 --- a/src/partest/scala/tools/partest/ScaladocModelTest.scala +++ b/src/partest/scala/tools/partest/ScaladocModelTest.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Vlad Ureche */ diff --git a/src/partest/scala/tools/partest/SecurityTest.scala b/src/partest/scala/tools/partest/SecurityTest.scala index 54aad5a625..462db025b5 100644 --- a/src/partest/scala/tools/partest/SecurityTest.scala +++ b/src/partest/scala/tools/partest/SecurityTest.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/partest/scala/tools/partest/SigTest.scala b/src/partest/scala/tools/partest/SigTest.scala index 1d8728294b..d9666f331e 100644 --- a/src/partest/scala/tools/partest/SigTest.scala +++ b/src/partest/scala/tools/partest/SigTest.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/partest/scala/tools/partest/nest/CompileManager.scala b/src/partest/scala/tools/partest/nest/CompileManager.scala index 6e6c767117..604e53e64c 100644 --- a/src/partest/scala/tools/partest/nest/CompileManager.scala +++ b/src/partest/scala/tools/partest/nest/CompileManager.scala @@ -1,5 +1,5 @@ /* NEST (New Scala Test) - * Copyright 2007-2011 LAMP/EPFL + * Copyright 2007-2012 LAMP/EPFL * @author Philipp Haller */ diff --git a/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala b/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala index 68e9753575..32f14872ec 100644 --- a/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala +++ b/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala @@ -1,5 +1,5 @@ /* NEST (New Scala Test) - * Copyright 2007-2011 LAMP/EPFL + * Copyright 2007-2012 LAMP/EPFL * @author Philipp Haller */ diff --git a/src/partest/scala/tools/partest/nest/ConsoleRunner.scala b/src/partest/scala/tools/partest/nest/ConsoleRunner.scala index 20e6f47802..ccc756c158 100644 --- a/src/partest/scala/tools/partest/nest/ConsoleRunner.scala +++ b/src/partest/scala/tools/partest/nest/ConsoleRunner.scala @@ -1,5 +1,5 @@ /* NEST (New Scala Test) - * Copyright 2007-2011 LAMP/EPFL + * Copyright 2007-2012 LAMP/EPFL * @author Philipp Haller */ diff --git a/src/partest/scala/tools/partest/nest/DirectRunner.scala b/src/partest/scala/tools/partest/nest/DirectRunner.scala index c254472342..a07705322d 100644 --- a/src/partest/scala/tools/partest/nest/DirectRunner.scala +++ b/src/partest/scala/tools/partest/nest/DirectRunner.scala @@ -1,5 +1,5 @@ /* NEST (New Scala Test) - * Copyright 2007-2011 LAMP/EPFL + * Copyright 2007-2012 LAMP/EPFL * @author Philipp Haller */ diff --git a/src/partest/scala/tools/partest/nest/FileManager.scala b/src/partest/scala/tools/partest/nest/FileManager.scala index 40bfa36b04..064b82da85 100644 --- a/src/partest/scala/tools/partest/nest/FileManager.scala +++ b/src/partest/scala/tools/partest/nest/FileManager.scala @@ -1,5 +1,5 @@ /* NEST (New Scala Test) - * Copyright 2007-2011 LAMP/EPFL + * Copyright 2007-2012 LAMP/EPFL * @author Philipp Haller */ diff --git a/src/partest/scala/tools/partest/nest/NestRunner.scala b/src/partest/scala/tools/partest/nest/NestRunner.scala index 27c1ef64f0..10fe2e8fb3 100644 --- a/src/partest/scala/tools/partest/nest/NestRunner.scala +++ b/src/partest/scala/tools/partest/nest/NestRunner.scala @@ -1,5 +1,5 @@ /* NEST (New Scala Test) - * Copyright 2007-2011 LAMP/EPFL + * Copyright 2007-2012 LAMP/EPFL * @author Philipp Haller */ diff --git a/src/partest/scala/tools/partest/nest/NestUI.scala b/src/partest/scala/tools/partest/nest/NestUI.scala index 54e99a7ddf..29845e2fbf 100644 --- a/src/partest/scala/tools/partest/nest/NestUI.scala +++ b/src/partest/scala/tools/partest/nest/NestUI.scala @@ -1,5 +1,5 @@ /* NEST (New Scala Test) - * Copyright 2007-2011 LAMP/EPFL + * Copyright 2007-2012 LAMP/EPFL * @author Philipp Haller */ diff --git a/src/partest/scala/tools/partest/nest/PathSettings.scala b/src/partest/scala/tools/partest/nest/PathSettings.scala index b409a29165..93a34bb66f 100644 --- a/src/partest/scala/tools/partest/nest/PathSettings.scala +++ b/src/partest/scala/tools/partest/nest/PathSettings.scala @@ -1,5 +1,5 @@ /* NEST (New Scala Test) - * Copyright 2007-2011 LAMP/EPFL + * Copyright 2007-2012 LAMP/EPFL */ package scala.tools.partest diff --git a/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala b/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala index fa75d96b34..838bf56d73 100644 --- a/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala +++ b/src/partest/scala/tools/partest/nest/ReflectiveRunner.scala @@ -1,5 +1,5 @@ /* NEST (New Scala Test) - * Copyright 2007-2011 LAMP/EPFL + * Copyright 2007-2012 LAMP/EPFL * @author Philipp Haller */ diff --git a/src/partest/scala/tools/partest/nest/RunnerManager.scala b/src/partest/scala/tools/partest/nest/RunnerManager.scala index 5a7684dc61..20d61d0831 100644 --- a/src/partest/scala/tools/partest/nest/RunnerManager.scala +++ b/src/partest/scala/tools/partest/nest/RunnerManager.scala @@ -1,5 +1,5 @@ /* NEST (New Scala Test) - * Copyright 2007-2011 LAMP/EPFL + * Copyright 2007-2012 LAMP/EPFL * @author Philipp Haller */ diff --git a/src/partest/scala/tools/partest/nest/RunnerUtils.scala b/src/partest/scala/tools/partest/nest/RunnerUtils.scala index 93fff0e146..ce2d6b5008 100644 --- a/src/partest/scala/tools/partest/nest/RunnerUtils.scala +++ b/src/partest/scala/tools/partest/nest/RunnerUtils.scala @@ -1,5 +1,5 @@ /* NEST (New Scala Test) - * Copyright 2007-2011 LAMP/EPFL + * Copyright 2007-2012 LAMP/EPFL * @author Philipp Haller */ diff --git a/src/partest/scala/tools/partest/nest/TestFile.scala b/src/partest/scala/tools/partest/nest/TestFile.scala index 52af16274e..c203c000d1 100644 --- a/src/partest/scala/tools/partest/nest/TestFile.scala +++ b/src/partest/scala/tools/partest/nest/TestFile.scala @@ -1,5 +1,5 @@ /* NEST (New Scala Test) - * Copyright 2007-2011 LAMP/EPFL + * Copyright 2007-2012 LAMP/EPFL * @author Philipp Haller */ diff --git a/src/partest/scala/tools/partest/package.scala b/src/partest/scala/tools/partest/package.scala index 9f45b380eb..08934ef143 100644 --- a/src/partest/scala/tools/partest/package.scala +++ b/src/partest/scala/tools/partest/package.scala @@ -1,5 +1,5 @@ /* NEST (New Scala Test) - * Copyright 2007-2011 LAMP/EPFL + * Copyright 2007-2012 LAMP/EPFL */ package scala.tools diff --git a/src/reflect/scala/reflect/api/Constants.scala b/src/reflect/scala/reflect/api/Constants.scala index 7862ab0d25..6657245003 100644 --- a/src/reflect/scala/reflect/api/Constants.scala +++ b/src/reflect/scala/reflect/api/Constants.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/reflect/scala/reflect/api/FlagSets.scala b/src/reflect/scala/reflect/api/FlagSets.scala index 969176d641..6d105c9d20 100644 --- a/src/reflect/scala/reflect/api/FlagSets.scala +++ b/src/reflect/scala/reflect/api/FlagSets.scala @@ -9,8 +9,7 @@ trait FlagSets { self: Universe => trait FlagOps extends Any { def | (right: FlagSet): FlagSet - def & (right: FlagSet): FlagSet - def containsAll (right: FlagSet): Boolean + def hasFlag(flags: FlagSet): Boolean } implicit def addFlagOps(left: FlagSet): FlagOps @@ -19,8 +18,6 @@ trait FlagSets { self: Universe => type FlagValues >: Null <: FlagValuesApi - // [Eugene++] any other flags we would like to expose? - trait FlagValuesApi { /** Flag indicating that symbol or tree represents a trait */ @@ -100,13 +97,5 @@ trait FlagSets { self: Universe => /** Flag indicating that parameter has a default value */ val DEFAULTPARAM: FlagSet - - /** Flag indicating that trait has neither method implementations nor fields. - * This means the trait can be represented as a Java interface. */ - val INTERFACE: FlagSet - - def union(flags: FlagSet*): FlagSet - def intersection(flag: FlagSet*): FlagSet - def containsAll(superset: FlagSet, subset: FlagSet): Boolean } } diff --git a/src/reflect/scala/reflect/api/Mirrors.scala b/src/reflect/scala/reflect/api/Mirrors.scala index 27176a2a2d..f2f96645e3 100644 --- a/src/reflect/scala/reflect/api/Mirrors.scala +++ b/src/reflect/scala/reflect/api/Mirrors.scala @@ -33,8 +33,16 @@ trait Mirrors { self: Universe => /** Reflects against a field symbol and returns a mirror * that can be used to get and, if appropriate, set the value of the field. * + * FieldMirrors are the only way to get at private[this] vals and vars and + * might be useful to inspect the data of underlying Java fields. + * For all other uses, it's better to go through the fields accessor. + * + * In particular, there should be no need to ever access a field mirror + * when reflecting on just the public members of a class or trait. + * Note also that only accessor MethodMirrors, but not FieldMirrors will accurately reflect overriding behavior. + * * To get a field symbol by the name of the field you would like to reflect, - * use `<this mirror>.symbol.typeSignature.member(newTermName(<name of the field>)).asTermSymbol`. + * use `<this mirror>.symbol.typeSignature.member(newTermName(<name of the field>)).asTerm.accessed`. * For further information about member lookup refer to `Symbol.typeSignature`. * * The input symbol can be either private or non-private (Scala reflection transparently deals with visibility). @@ -54,7 +62,7 @@ trait Mirrors { self: Universe => * that can be used to invoke the method provided. * * To get a method symbol by the name of the method you would like to reflect, - * use `<this mirror>.symbol.typeSignature.member(newTermName(<name of the method>)).asMethodSymbol`. + * use `<this mirror>.symbol.typeSignature.member(newTermName(<name of the method>)).asMethod`. * For further information about member lookup refer to `Symbol.typeSignature`. * * The input symbol can be either private or non-private (Scala reflection transparently deals with visibility). @@ -66,7 +74,7 @@ trait Mirrors { self: Universe => * that can be used to create instances of the class, inspect its companion object or perform further reflections. * * To get a class symbol by the name of the class you would like to reflect, - * use `<this mirror>.symbol.typeSignature.member(newTypeName(<name of the class>)).asClassSymbol`. + * use `<this mirror>.symbol.typeSignature.member(newTypeName(<name of the class>)).asClass`. * For further information about member lookup refer to `Symbol.typeSignature`. * * The input symbol can be either private or non-private (Scala reflection transparently deals with visibility). @@ -78,7 +86,7 @@ trait Mirrors { self: Universe => * that can be used to get the instance of the object or inspect its companion class. * * To get a module symbol by the name of the object you would like to reflect, - * use `<this mirror>.symbol.typeSignature.member(newTermName(<name of the object>)).asModuleSymbol`. + * use `<this mirror>.symbol.typeSignature.member(newTermName(<name of the object>)).asModule`. * For further information about member lookup refer to `Symbol.typeSignature`. * * The input symbol can be either private or non-private (Scala reflection transparently deals with visibility). @@ -91,7 +99,7 @@ trait Mirrors { self: Universe => trait FieldMirror { /** The object containing the field */ - def receiver: AnyRef + def receiver: Any /** The field symbol representing the field. * @@ -107,6 +115,10 @@ trait Mirrors { self: Universe => * Scala reflection uses reflection capabilities of the underlying platform, * so `FieldMirror.get` might throw platform-specific exceptions associated * with getting a field or invoking a getter method of the field. + * + * If `symbol` represents a field of a base class with respect to the class of the receiver, + * and this base field is overriden in the class of the receiver, then this method will retrieve + * the value of the base field. To achieve overriding behavior, use reflectMethod on an accessor. */ def get: Any @@ -117,6 +129,10 @@ trait Mirrors { self: Universe => * Scala reflection uses reflection capabilities of the underlying platform, * so `FieldMirror.get` might throw platform-specific exceptions associated * with setting a field or invoking a setter method of the field. + * + * If `symbol` represents a field of a base class with respect to the class of the receiver, + * and this base field is overriden in the class of the receiver, then this method will set + * the value of the base field. To achieve overriding behavior, use reflectMethod on an accessor. */ def set(value: Any): Unit } @@ -125,7 +141,7 @@ trait Mirrors { self: Universe => trait MethodMirror { /** The receiver object of the method */ - def receiver: AnyRef + def receiver: Any /** The method symbol representing the method */ def symbol: MethodSymbol @@ -201,7 +217,7 @@ trait Mirrors { self: Universe => * that can be used to invoke it and construct instances of this mirror's symbols. * * To get a constructor symbol you would like to reflect, - * use `<this mirror>.symbol.typeSignature.member(nme.CONSTRUCTOR).asMethodSymbol`. + * use `<this mirror>.symbol.typeSignature.member(nme.CONSTRUCTOR).asMethod`. * For further information about member lookup refer to `Symbol.typeSignature`. * * The input symbol can be either private or non-private (Scala reflection transparently deals with visibility). @@ -226,7 +242,9 @@ trait Mirrors { self: Universe => * Such a mirror can be used to further reflect against the members of the object * to get/set fields, invoke methods and inspect inner classes and objects. */ - def reflect(obj: Any): InstanceMirror + // we need a ClassTag here to preserve boxity of primitives + // the class tag lets us tell apart `mirror.reflect(2)` and `mirror.reflect(new Integer(2))` + def reflect[T: ClassTag](obj: T): InstanceMirror /** Reflects against a static class symbol and returns a mirror * that can be used to create instances of the class, inspect its companion object or perform further reflections. diff --git a/src/reflect/scala/reflect/api/StandardDefinitions.scala b/src/reflect/scala/reflect/api/StandardDefinitions.scala index c2a89f92dd..c6f02f1a33 100644 --- a/src/reflect/scala/reflect/api/StandardDefinitions.scala +++ b/src/reflect/scala/reflect/api/StandardDefinitions.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ package scala.reflect diff --git a/src/reflect/scala/reflect/api/StandardNames.scala b/src/reflect/scala/reflect/api/StandardNames.scala index 24d803a24a..65d87ad7f0 100644 --- a/src/reflect/scala/reflect/api/StandardNames.scala +++ b/src/reflect/scala/reflect/api/StandardNames.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler -* Copyright 2005-2011 LAMP/EPFL +* Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ package scala.reflect diff --git a/src/reflect/scala/reflect/api/Symbols.scala b/src/reflect/scala/reflect/api/Symbols.scala index c94c796279..448382973a 100644 --- a/src/reflect/scala/reflect/api/Symbols.scala +++ b/src/reflect/scala/reflect/api/Symbols.scala @@ -12,15 +12,8 @@ trait Symbols extends base.Symbols { self: Universe => override type FreeTermSymbol >: Null <: TermSymbol with FreeTermSymbolApi override type FreeTypeSymbol >: Null <: TypeSymbol with FreeTypeSymbolApi - trait HasFlagsApi { - def flags: FlagSet - def hasFlag(fs: FlagSet): Boolean - def hasAllFlags(fs: FlagSet): Boolean - def flagString: String - } - /** The API of symbols */ - trait SymbolApi extends SymbolBase with HasFlagsApi { this: Symbol => + trait SymbolApi extends SymbolBase with HasFlagsBase { this: Symbol => /** The position of this symbol */ @@ -50,22 +43,52 @@ trait Symbols extends base.Symbols { self: Universe => */ def hasAnnotation(sym: Symbol): Boolean - /** ... + /** For a class: the module or case class factory with the same name in the same package. + * For a module: the class with the same name in the same package. + * For all others: NoSymbol */ - def orElse(alt: => Symbol): Symbol + def companionSymbol: Symbol - /** ... + /** The type signature of this symbol seen as a member of given type `site`. */ - def filter(cond: Symbol => Boolean): Symbol + def typeSignatureIn(site: Type): Type - /** If this is a NoSymbol, returns NoSymbol, otherwise - * returns the result of applying `f` to this symbol. + /** The type signature of this symbol. + * Note if the symbol is a member of a class, one almost always is interested + * in `typeSignatureIn` with a site type instead. */ - def map(f: Symbol => Symbol): Symbol + def typeSignature: Type - /** ... + /******************* tests *******************/ + + /** Does this symbol represent a synthetic (i.e. a compiler-generated) entity? + * Examples of synthetic entities are accessors for vals and vars + * or mixin constructors in trait implementation classes. */ - def suchThat(cond: Symbol => Boolean): Symbol + def isSynthetic: Boolean + + /** Does this symbol represent a local declaration or definition? + * + * If yes, either `isPrivate` or `isProtected` are guaranteed to be true. + * Local symbols can only be accessed from the same object instance. + * + * If yes, `privateWithin` might tell more about this symbol's visibility scope. + */ + def isLocal: Boolean + + /** Does this symbol represent a private declaration or definition? + * If yes, `privateWithin` might tell more about this symbol's visibility scope. + */ + def isPrivate: Boolean + + /** Does this symbol represent a protected declaration or definition? + * If yes, `privateWithin` might tell more about this symbol's visibility scope. + */ + def isProtected: Boolean + + /** Does this symbol represent a public declaration or definition? + */ + def isPublic: Boolean /** * Set when symbol has a modifier of the form private[X], NoSymbol otherwise. @@ -94,24 +117,89 @@ trait Symbols extends base.Symbols { self: Universe => */ def privateWithin: Symbol - /** For a class: the module or case class factory with the same name in the same package. - * For a module: the class with the same name in the same package. - * For all others: NoSymbol + /** Does this symbol represent the definition of a package? + * If yes, `isTerm` is also guaranteed to be true. */ - def companionSymbol: Symbol + def isPackage: Boolean + + /** Does this symbol represent a package class? + * If yes, `isClass` is also guaranteed to be true. + */ + def isPackageClass: Boolean + + /** Does this symbol or its underlying type represent a typechecking error? + */ + def isErroneous : Boolean + + /** Can this symbol be loaded by a reflective mirror? + * + * Scalac relies on `ScalaSignature' annotation to retain symbols across compilation runs. + * Such annotations (also called "pickles") are applied on top-level classes and include information + * about all symbols reachable from the annotee. However, local symbols (e.g. classes or definitions local to a block) + * are typically unreachable and information about them gets lost. + * + * This method is useful for macro writers who wish to save certain ASTs to be used at runtime. + * With `isLocatable' it's possible to check whether a tree can be retained as is, or it needs special treatment. + */ + def isLocatable: Boolean + + /** Is this symbol static (i.e. with no outer instance)? + * Q: When exactly is a sym marked as STATIC? + * A: If it's a member of a toplevel object, or of an object contained in a toplevel object, or any number of levels deep. + * http://groups.google.com/group/scala-internals/browse_thread/thread/d385bcd60b08faf6 + */ + def isStatic: Boolean + + /** Is this symbol final? + */ + def isFinal: Boolean + + /** Is this symbol overriding something? + */ + def isOverride: Boolean + + /** Is this symbol labelled as "abstract override"? + */ + def isAbstractOverride: Boolean + + /** Is this symbol a macro? + */ + def isMacro: Boolean + + /** Is this symbol a parameter (either a method parameter or a type parameter)? + */ + def isParameter: Boolean + + /** Is this symbol a specialized type parameter or a generated specialized member? + */ + def isSpecialized: Boolean - /** If this symbol is a package class, this symbol; otherwise the next enclosing - * package class, or `NoSymbol` if none exists. + /******************* helpers *******************/ + + /** ... */ - def enclosingPackageClass: Symbol + def orElse(alt: => Symbol): Symbol + + /** ... + */ + def filter(cond: Symbol => Boolean): Symbol - /** If this symbol is a top-level class, this symbol; otherwise the next enclosing - * top-level class, or `NoSymbol` if none exists. + /** If this is a NoSymbol, returns NoSymbol, otherwise + * returns the result of applying `f` to this symbol. + */ + def map(f: Symbol => Symbol): Symbol + + /** ... */ - def enclosingTopLevelClass: Symbol + def suchThat(cond: Symbol => Boolean): Symbol + /** The string discriminator of this symbol; useful for debugging */ + def kind: String + } + + /** The API of term symbols */ + trait TermSymbolApi extends SymbolApi with TermSymbolBase { this: TermSymbol => /** Does this symbol represent a value, i.e. not a module and not a method? - * If yes, `isTerm` is also guaranteed to be true. * [Eugene++] I need a review of the implementation */ def isValue: Boolean @@ -120,7 +208,6 @@ trait Symbols extends base.Symbols { self: Universe => def isStable: Boolean /** Does this symbol represent a mutable value? - * If yes, `isTerm` and `isValue` are also guaranteed to be true. */ def isVariable: Boolean @@ -129,113 +216,68 @@ trait Symbols extends base.Symbols { self: Universe => def isAccessor: Boolean /** Does this symbol represent a getter of a field? - * If yes, `isTerm` and `isMethod` are also guaranteed to be true. + * If yes, `isMethod` is also guaranteed to be true. */ def isGetter: Boolean /** Does this symbol represent a setter of a field? - * If yes, `isTerm` and `isMethod` are also guaranteed to be true. + * If yes, `isMethod` is also guaranteed to be true. */ def isSetter: Boolean - /** Does this symbol represent the definition of a package? - * If yes, `isTerm` is also guaranteed to be true. - */ - def isPackage: Boolean - - /** Does this symbol represent a package class? - * If yes, `isClass` is also guaranteed to be true. - */ - def isPackageClass: Boolean - - /** Is this symbol an overloaded method? + /** Does this symbol represent an overloaded method? + * If yes, `isMethod` is false, and the list of the enclosed alternatives can be found out via `alternatives`. */ def isOverloaded : Boolean - /** Does this symbol represent the definition of a primitive class? - * Namely, is it one of [[scala.Double]], [[scala.Float]], [[scala.Long]], [[scala.Int]], [[scala.Char]], - * [[scala.Short]], [[scala.Byte]], [[scala.Unit]] or [[scala.Boolean]]? + /** Does this symbol represent an implicit value, definition or parameter? */ - def isPrimitiveValueClass: Boolean + def isImplicit: Boolean - /** Does this symbol represent the definition of a numeric value class? - * Namely, is it one of [[scala.Double]], [[scala.Float]], [[scala.Long]], [[scala.Int]], [[scala.Char]], - * [[scala.Short]], [[scala.Byte]], [[scala.Unit]] or [[scala.Boolean]]? - */ - def isNumericValueClass: Boolean - - /** Does this symbol represent the definition of a custom value class? - * Namely, is AnyVal among its parent classes? - * TODO: Why not just have in reflect.internal? - * [Eugene++] because it's useful for macros + /** Does this symbol represent a lazy value? */ - def isDerivedValueClass: Boolean + def isLazy: Boolean - /** Does this symbol represent the definition of a type alias? - * If yes, `isType` is also guaranteed to be true. - */ - def isAliasType : Boolean + /** The overloaded alternatives of this symbol */ + def alternatives: List[Symbol] - /** Does this symbol represent the definition of an abstract type? - * If yes, `isType` is also guaranteed to be true. - */ - def isAbstractType : Boolean + /** Used to provide a better error message for `asMethod` */ + override protected def isOverloadedMethod = alternatives exists (_.isMethod) - /** Does this symbol represent an existentially bound type? - * If yes, `isType` is also guaranteed to be true. + /** Backing field for an accessor method, NoSymbol for all other term symbols. */ - def isExistential : Boolean + def accessed: Symbol - /** Does this symbol represent a free type captured by reification? + /** Getter method for a backing field of a val or a val, NoSymbol for all other term symbols. */ - def isFreeType : Boolean + def getter: Symbol - /** Does this symbol or its underlying type represent a typechecking error? + /** Setter method for a backing field of a val or a val, NoSymbol for all other term symbols. */ - def isErroneous : Boolean + def setter: Symbol - /** Can this symbol be loaded by a reflective mirror? - * - * Scalac relies on `ScalaSignature' annotation to retain symbols across compilation runs. - * Such annotations (also called "pickles") are applied on top-level classes and include information - * about all symbols reachable from the annotee. However, local symbols (e.g. classes or definitions local to a block) - * are typically unreachable and information about them gets lost. - * - * This method is useful for macro writers who wish to save certain ASTs to be used at runtime. - * With `isLocatable' it's possible to check whether a tree can be retained as is, or it needs special treatment. + /** Does this symbol represent a field of a class + * that was generated from a parameter of that class? */ - def isLocatable: Boolean + def isParamAccessor: Boolean - /** Is this symbol static (i.e. with no outer instance)? - * Q: When exactly is a sym marked as STATIC? - * A: If it's a member of a toplevel object, or of an object contained in a toplevel object, or any number of levels deep. - * http://groups.google.com/group/scala-internals/browse_thread/thread/d385bcd60b08faf6 + /** Does this symbol represent a field of a case class + * that corresponds to a parameter in the first parameter list of the + * primary constructor of that class? */ - def isStatic: Boolean + def isCaseAccessor: Boolean - /** The type signature of this symbol seen as a member of given type `site`. + /** Does this symbol represent a parameter with a default value? */ - def typeSignatureIn(site: Type): Type + def isParamWithDefault: Boolean - /** The type signature of this symbol. - * Note if the symbol is a member of a class, one almost always is interested - * in `typeSignatureIn` with a site type instead. + /** Does this symbol represent a by-name parameter? */ - def typeSignature: Type - - /** The string discriminator of this symbol; useful for debugging */ - def kind: String - } - - /** The API of term symbols */ - trait TermSymbolApi extends SymbolApi with HasFlagsApi with TermSymbolBase { this: TermSymbol => - /** The overloaded alternatives of this symbol */ - def alternatives: List[Symbol] - + def isByNameParam: Boolean } /** The API of type symbols */ - trait TypeSymbolApi extends SymbolApi with HasFlagsApi with TypeSymbolBase { this: TypeSymbol => + trait TypeSymbolApi extends SymbolApi with TypeSymbolBase { this: TypeSymbol => /** Is the type parameter represented by this symbol contravariant? */ def isContravariant : Boolean @@ -246,37 +288,92 @@ trait Symbols extends base.Symbols { self: Universe => /** Does this symbol represent the definition of a skolem? * Skolems are used during typechecking to represent type parameters viewed from inside their scopes. - * If yes, `isType` is also guaranteed to be true. */ def isSkolem : Boolean - /** A type reference that refers to this type symbol seen - * as a member of given type `site`. - */ - def asTypeIn(site: Type): Type - - /** A type reference that refers to this type symbol - * Note if symbol is a member of a class, one almost always is interested - * in `asTypeIn` with a site type instead. - * - * Example: Given a class declaration `class C[T] { ... } `, that generates a symbol - * `C`. Then `C.asType` is the type `C[T]`. - * - * By contrast, `C.typeSignature` would be a type signature of form - * `PolyType(ClassInfoType(...))` that describes type parameters, value - * parameters, parent types, and members of `C`. - */ - def asType: Type // !!! Same as typeSignature. + /** Does this symbol represent the definition of a type alias? + */ + def isAliasType : Boolean + + /** Does this symbol represent the definition of an abstract type? + */ + def isAbstractType : Boolean + + /** Does this symbol represent an existentially bound type? + */ + def isExistential : Boolean + + /** For a polymorphic type, its type parameters, the empty list for all other types */ + def typeParams: List[Symbol] } /** The API of method symbols */ - type MethodSymbolApi = MethodSymbolBase + trait MethodSymbolApi extends TermSymbolApi with MethodSymbolBase { this: MethodSymbol => + /** Does this method represent a constructor? + * + * If `owner` is a class, then this is a vanilla JVM constructor. + * If `owner` is a trait, then this is a mixin constructor. + */ + def isConstructor: Boolean + + /** For a polymorphic method, its type parameters, the empty list for all other methods */ + def typeParams: List[Symbol] + + /** All parameter lists of the method. + * + * Can be used to distinguish nullary methods and methods with empty parameter lists. + * For a nullary method, returns the empty list (i.e. `List()`). + * For a method with an empty parameter list, returns a list that contains the empty list (i.e. `List(List())`). + */ + def params: List[List[Symbol]] + + /** Does this method support variable length argument lists? + */ + def isVarargs: Boolean + + /** The return type of the method */ + def returnType: Type + } /** The API of module symbols */ - type ModuleSymbolApi = ModuleSymbolBase + trait ModuleSymbolApi extends TermSymbolApi with ModuleSymbolBase { this: ModuleSymbol => + } /** The API of class symbols */ trait ClassSymbolApi extends TypeSymbolApi with ClassSymbolBase { this: ClassSymbol => + /** Does this symbol represent the definition of a primitive class? + * Namely, is it one of [[scala.Double]], [[scala.Float]], [[scala.Long]], [[scala.Int]], [[scala.Char]], + * [[scala.Short]], [[scala.Byte]], [[scala.Unit]] or [[scala.Boolean]]? + */ + def isPrimitive: Boolean + + /** Does this symbol represent the definition of a numeric value class? + * Namely, is it one of [[scala.Double]], [[scala.Float]], [[scala.Long]], [[scala.Int]], [[scala.Char]], + * [[scala.Short]], [[scala.Byte]], [[scala.Unit]] or [[scala.Boolean]]? + */ + def isNumeric: Boolean + + /** Does this symbol represent the definition of a custom value class? + * Namely, is AnyVal among its parent classes? + */ + def isDerivedValueClass: Boolean + + /** Does this symbol represent a trait? + */ + def isTrait: Boolean + + /** Does this symbol represent an abstract class? + */ + def isAbstractClass: Boolean + + /** Does this symbol represent a case class? + */ + def isCaseClass: Boolean + + /** Does this symbol represent a sealed class? + */ + def isSealed: Boolean + /** If this symbol is a class or trait, its self type, otherwise the type * of the symbol itself. */ @@ -284,6 +381,9 @@ trait Symbols extends base.Symbols { self: Universe => /** The type `C.this`, where `C` is the current class */ def thisPrefix: Type + + /** For a polymorphic class/trait, its type parameters, the empty list for all other classes/trait */ + def typeParams: List[Symbol] } /** The API of free term symbols */ diff --git a/src/reflect/scala/reflect/api/TagInterop.scala b/src/reflect/scala/reflect/api/TagInterop.scala index f1938083b5..4d2254cb9f 100644 --- a/src/reflect/scala/reflect/api/TagInterop.scala +++ b/src/reflect/scala/reflect/api/TagInterop.scala @@ -27,8 +27,8 @@ trait TagInterop { self: JavaUniverse => val jm = mirror.asInstanceOf[ju.Mirror] val sym = jm.classSymbol(manifest.erasure) val tpe = - if (manifest.typeArguments.isEmpty) sym.asType - else ju.appliedType(sym.asTypeConstructor, manifest.typeArguments map (targ => ju.manifestToTypeTag(jm, targ)) map (_.in(jm).tpe)) + if (manifest.typeArguments.isEmpty) sym.toType + else ju.appliedType(sym.toTypeConstructor, manifest.typeArguments map (targ => ju.manifestToTypeTag(jm, targ)) map (_.in(jm).tpe)) tpe.asInstanceOf[U # Type] case u => u.manifestToTypeTag(mirror.asInstanceOf[u.Mirror], manifest).in(mirror).tpe diff --git a/src/reflect/scala/reflect/api/Trees.scala b/src/reflect/scala/reflect/api/Trees.scala index 2d130daa4e..5522693b29 100644 --- a/src/reflect/scala/reflect/api/Trees.scala +++ b/src/reflect/scala/reflect/api/Trees.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ package scala.reflect @@ -109,6 +109,8 @@ trait Trees extends base.Trees { self: Universe => def duplicate: this.type } + override protected def treeType(tree: Tree) = tree.tpe + override type TermTree >: Null <: Tree with TermTreeApi /** The API that all term trees support */ @@ -640,8 +642,16 @@ trait Trees extends base.Trees { self: Universe => abstract class Transformer { val treeCopy: TreeCopier = newLazyTreeCopier protected[scala] var currentOwner: Symbol = rootMirror.RootClass - protected def currentMethod = currentOwner.enclosingMethod - protected def currentClass = currentOwner.enclosingClass + protected def currentMethod = { + def enclosingMethod(sym: Symbol): Symbol = + if (sym.isMethod || sym == NoSymbol) sym else enclosingMethod(sym.owner) + enclosingMethod(currentOwner) + } + protected def currentClass = { + def enclosingClass(sym: Symbol): Symbol = + if (sym.isClass || sym == NoSymbol) sym else enclosingClass(sym.owner) + enclosingClass(currentOwner) + } // protected def currentPackage = currentOwner.enclosingTopLevelClass.owner def transform(tree: Tree): Tree = itransform(this, tree) @@ -683,7 +693,7 @@ trait Trees extends base.Trees { self: Universe => type Modifiers >: Null <: ModifiersApi - abstract class ModifiersApi extends ModifiersBase with HasFlagsApi + abstract class ModifiersApi extends ModifiersBase } diff --git a/src/reflect/scala/reflect/api/Types.scala b/src/reflect/scala/reflect/api/Types.scala index 01de5fa9a7..199cf9b9e5 100644 --- a/src/reflect/scala/reflect/api/Types.scala +++ b/src/reflect/scala/reflect/api/Types.scala @@ -24,73 +24,35 @@ trait Types extends base.Types { self: Universe => */ def declaration(name: Name): Symbol - /** The collection of declarations in this type - * [Eugene++] why not List? + /** A `Scope` containing directly declared members of this type. + * Unlike `members` this method doesn't returns inherited members. + * + * Members in the returned scope might appear in arbitrary order. + * Use `declarations.sorted` to get an ordered list of members. */ - def declarations: Iterable[Symbol] + def declarations: MemberScope /** The member with given name, either directly declared or inherited, * an OverloadedSymbol if several exist, NoSymbol if none exist. */ def member(name: Name): Symbol - /** The non-private member with given name, either directly declared or inherited, - * an OverloadedSymbol if several exist, NoSymbol if none exist. - */ - def nonPrivateMember(name: Name): Symbol - - /** An iterable containing all members of this type (directly declared or inherited) - * Members appear in the linearization order of their owners. - * Members with the same owner appear in reverse order of their declarations. - * [Eugene++] the order needs to be reversed back, at least in the public API - */ - def members: Iterable[Symbol] - - /** An iterable containing all non-private members of this type (directly declared or inherited) - * Members appear in the linearization order of their owners. - * Members with the same owner appear in reverse order of their declarations. - */ - def nonPrivateMembers: Iterable[Symbol] - - /** Substitute symbols in `to` for corresponding occurrences of references to - * symbols `from` in this type. - */ - def substituteSymbols(from: List[Symbol], to: List[Symbol]): Type - - /** Substitute types in `to` for corresponding occurrences of references to - * symbols `from` in this type. - */ - def substituteTypes(from: List[Symbol], to: List[Type]): Type - - /** If this is a parameterized types, the type arguments. - * Otherwise the empty list + /** A `Scope` containing all members of this type (directly declared or inherited). + * Unlike `declarations` this method also returns inherited members. + * + * Members in the returned scope might appear in arbitrary order. + * Use `declarations.sorted` to get an ordered list of members. */ - def typeArguments: List[Type] - - /** For a (potentially wrapped) poly type, its type parameters, - * the empty list for all other types */ - def typeParams: List[Symbol] - - /** For a (nullary) method or poly type, its direct result type, - * the type itself for all other types. */ - def resultType: Type + def members: MemberScope /** Is this type a type constructor that is missing its type arguments? */ - def isHigherKinded: Boolean // !!! This should be called "isTypeConstructor", no? + def takesTypeArgs: Boolean /** Returns the corresponding type constructor (e.g. List for List[T] or List[String]) */ def typeConstructor: Type - /** Does this type refer to spliceable types or is a spliceable type? - */ - def isConcrete: Boolean - - /** Is this type an abstract type that needs to be resolved? - */ - def isSpliceable: Boolean - /** * Expands type aliases and converts higher-kinded TypeRefs to PolyTypes. * Functions on types are also implemented as PolyTypes. @@ -99,7 +61,7 @@ trait Types extends base.Types { self: Universe => * TypeRef(pre, <List>, List()) is replaced by * PolyType(X, TypeRef(pre, <List>, List(X))) */ - def normalize: Type // !!! Alternative name? "normalize" is used to mean too many things. + def normalize: Type /** Does this type conform to given type argument `that`? */ def <:< (that: Type): Boolean @@ -111,7 +73,7 @@ trait Types extends base.Types { self: Universe => * in reverse linearization order, starting with the class itself and ending * in class Any. */ - def baseClasses: List[Symbol] // !!! Alternative name, perhaps linearization? + def baseClasses: List[Symbol] /** The least type instance of given class which is a supertype * of this type. Example: @@ -141,36 +103,7 @@ trait Types extends base.Types { self: Universe => /** The erased type corresponding to this type after * all transformations from Scala to Java have been performed. */ - def erasure: Type // !!! "erasedType", compare with "widen" (so "erase") or "underlying" (so "erased") - // why not name it "erasure"? - - /** Apply `f` to each part of this type, returning - * a new type. children get mapped before their parents */ - def map(f: Type => Type): Type - - /** Apply `f` to each part of this type, for side effects only */ - def foreach(f: Type => Unit) - - /** Returns optionally first type (in a preorder traversal) which satisfies predicate `p`, - * or None if none exists. - */ - def find(p: Type => Boolean): Option[Type] - - /** Is there part of this type which satisfies predicate `p`? */ - def exists(p: Type => Boolean): Boolean - - /** Does this type contain a reference to given symbol? */ - def contains(sym: Symbol): Boolean - - /** If this is a compound type, the list of its parent types; - * otherwise the empty list - */ - def parents: List[Type] - - /** If this is a singleton type, returns the type underlying it; - * otherwise returns this type itself. - */ - def underlying: Type + def erasure: Type /** If this is a singleton type, widen it to its nearest underlying non-singleton * base type by applying one or more `underlying` dereferences. @@ -193,6 +126,36 @@ trait Types extends base.Types { self: Universe => */ def narrow: Type + /******************* helpers *******************/ + + /** Substitute symbols in `to` for corresponding occurrences of references to + * symbols `from` in this type. + */ + def substituteSymbols(from: List[Symbol], to: List[Symbol]): Type + + /** Substitute types in `to` for corresponding occurrences of references to + * symbols `from` in this type. + */ + def substituteTypes(from: List[Symbol], to: List[Type]): Type + + /** Apply `f` to each part of this type, returning + * a new type. children get mapped before their parents */ + def map(f: Type => Type): Type + + /** Apply `f` to each part of this type, for side effects only */ + def foreach(f: Type => Unit) + + /** Returns optionally first type (in a preorder traversal) which satisfies predicate `p`, + * or None if none exists. + */ + def find(p: Type => Boolean): Option[Type] + + /** Is there part of this type which satisfies predicate `p`? */ + def exists(p: Type => Boolean): Boolean + + /** Does this type contain a reference to given symbol? */ + def contains(sym: Symbol): Boolean + /** The string discriminator of this type; useful for debugging */ def kind: String } diff --git a/src/reflect/scala/reflect/api/Universe.scala b/src/reflect/scala/reflect/api/Universe.scala index 85d8adc44f..3dce0f218e 100644 --- a/src/reflect/scala/reflect/api/Universe.scala +++ b/src/reflect/scala/reflect/api/Universe.scala @@ -1,8 +1,6 @@ package scala.reflect package api -import language.experimental.macros - abstract class Universe extends base.Universe with Symbols with Types @@ -16,53 +14,4 @@ abstract class Universe extends base.Universe with StandardDefinitions with StandardNames with Importers - with Exprs with AnnotationInfos -{ - - /** Given an expression, generate a tree that when compiled and executed produces the original tree. - * The produced tree will be bound to the Universe it was called from. - * - * For instance, given the abstract syntax tree representation of the <[ x + 1 ]> expression: - * - * {{{ - * Apply(Select(Ident("x"), "+"), List(Literal(Constant(1)))) - * }}} - * - * The reifier transforms it to the following expression: - * - * {{{ - * <[ - * val $u: u.type = u // where u is a reference to the Universe that calls the reify - * $u.Expr[Int]($u.Apply($u.Select($u.Ident($u.newFreeVar("x", <Int>, x), "+"), List($u.Literal($u.Constant(1)))))) - * ]> - * }}} - * - * Reification performs expression splicing (when processing Expr.splice) - * and type splicing (for every type T that has a TypeTag[T] implicit in scope): - * - * {{{ - * val two = mirror.reify(2) // Literal(Constant(2)) - * val four = mirror.reify(two.splice + two.splice) // Apply(Select(two.tree, newTermName("$plus")), List(two.tree)) - * - * def macroImpl[T](c: Context) = { - * ... - * // T here is just a type parameter, so the tree produced by reify won't be of much use in a macro expansion - * // however, if T were annotated with c.TypeTag (which would declare an implicit parameter for macroImpl) - * // then reification would subtitute T with the TypeTree that was used in a TypeApply of this particular macro invocation - * val factory = c.reify{ new Queryable[T] } - * ... - * } - * }}} - * - * The transformation looks mostly straightforward, but it has its tricky parts: - * * Reifier retains symbols and types defined outside the reified tree, however - * locally defined entities get erased and replaced with their original trees - * * Free variables are detected and wrapped in symbols of the type FreeVar - * * Mutable variables that are accessed from a local function are wrapped in refs - * * Since reified trees can be compiled outside of the scope they've been created in, - * special measures are taken to ensure that all members accessed in the reifee remain visible - */ - // implementation is magically hardwired to `scala.reflect.reify.Taggers` - def reify[T](expr: T): Expr[T] = macro ??? -}
\ No newline at end of file diff --git a/src/reflect/scala/reflect/internal/AnnotationCheckers.scala b/src/reflect/scala/reflect/internal/AnnotationCheckers.scala index 449b0ca0bc..9f102c5712 100644 --- a/src/reflect/scala/reflect/internal/AnnotationCheckers.scala +++ b/src/reflect/scala/reflect/internal/AnnotationCheckers.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2007-2011 LAMP/EPFL + * Copyright 2007-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/reflect/scala/reflect/internal/AnnotationInfos.scala b/src/reflect/scala/reflect/internal/AnnotationInfos.scala index 2bcc95b9a8..229570dafd 100644 --- a/src/reflect/scala/reflect/internal/AnnotationInfos.scala +++ b/src/reflect/scala/reflect/internal/AnnotationInfos.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2007-2011 LAMP/EPFL + * Copyright 2007-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/reflect/scala/reflect/internal/BaseTypeSeqs.scala b/src/reflect/scala/reflect/internal/BaseTypeSeqs.scala index 19f70ba785..fbee906b7b 100644 --- a/src/reflect/scala/reflect/internal/BaseTypeSeqs.scala +++ b/src/reflect/scala/reflect/internal/BaseTypeSeqs.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ package scala.reflect diff --git a/src/reflect/scala/reflect/internal/BuildUtils.scala b/src/reflect/scala/reflect/internal/BuildUtils.scala index ad59605760..74b9442076 100644 --- a/src/reflect/scala/reflect/internal/BuildUtils.scala +++ b/src/reflect/scala/reflect/internal/BuildUtils.scala @@ -8,11 +8,11 @@ trait BuildUtils extends base.BuildUtils { self: SymbolTable => class BuildImpl extends BuildBase { def selectType(owner: Symbol, name: String): TypeSymbol = - select(owner, newTypeName(name)).asTypeSymbol + select(owner, newTypeName(name)).asType def selectTerm(owner: Symbol, name: String): TermSymbol = { - val result = select(owner, newTermName(name)).asTermSymbol - if (result.isOverloaded) result.suchThat(!_.isMethod).asTermSymbol + val result = select(owner, newTermName(name)).asTerm + if (result.isOverloaded) result.suchThat(!_.isMethod).asTerm else result } @@ -26,7 +26,7 @@ trait BuildUtils extends base.BuildUtils { self: SymbolTable => def selectOverloadedMethod(owner: Symbol, name: String, index: Int): MethodSymbol = { val result = owner.info.decl(newTermName(name)).alternatives(index) - if (result ne NoSymbol) result.asMethodSymbol + if (result ne NoSymbol) result.asMethod else MissingRequirementError.notFound("overloaded method %s #%d in %s".format(name, index, owner.fullName)) } diff --git a/src/reflect/scala/reflect/internal/Chars.scala b/src/reflect/scala/reflect/internal/Chars.scala index 50ec71094a..6ece733b06 100644 --- a/src/reflect/scala/reflect/internal/Chars.scala +++ b/src/reflect/scala/reflect/internal/Chars.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2006-2011 LAMP/EPFL + * Copyright 2006-2012 LAMP/EPFL * @author Martin Odersky */ package scala.reflect diff --git a/src/reflect/scala/reflect/internal/ClassfileConstants.scala b/src/reflect/scala/reflect/internal/ClassfileConstants.scala index 3346e9cccb..124f1f881d 100644 --- a/src/reflect/scala/reflect/internal/ClassfileConstants.scala +++ b/src/reflect/scala/reflect/internal/ClassfileConstants.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/reflect/scala/reflect/internal/Constants.scala b/src/reflect/scala/reflect/internal/Constants.scala index d6a168ee11..e5a543da46 100644 --- a/src/reflect/scala/reflect/internal/Constants.scala +++ b/src/reflect/scala/reflect/internal/Constants.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/reflect/scala/reflect/internal/Definitions.scala b/src/reflect/scala/reflect/internal/Definitions.scala index 90aa0b732c..c6815d10c3 100644 --- a/src/reflect/scala/reflect/internal/Definitions.scala +++ b/src/reflect/scala/reflect/internal/Definitions.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ @@ -20,21 +20,21 @@ trait Definitions extends api.StandardDefinitions { object definitions extends DefinitionsClass // [Eugene] find a way to make these non-lazy - lazy val ByteTpe = definitions.ByteClass.asType - lazy val ShortTpe = definitions.ShortClass.asType - lazy val CharTpe = definitions.CharClass.asType - lazy val IntTpe = definitions.IntClass.asType - lazy val LongTpe = definitions.LongClass.asType - lazy val FloatTpe = definitions.FloatClass.asType - lazy val DoubleTpe = definitions.DoubleClass.asType - lazy val BooleanTpe = definitions.BooleanClass.asType - lazy val UnitTpe = definitions.UnitClass.asType - lazy val AnyTpe = definitions.AnyClass.asType - lazy val ObjectTpe = definitions.ObjectClass.asType - lazy val AnyValTpe = definitions.AnyValClass.asType - lazy val AnyRefTpe = definitions.AnyRefClass.asType - lazy val NothingTpe = definitions.NothingClass.asType - lazy val NullTpe = definitions.NullClass.asType + lazy val ByteTpe = definitions.ByteClass.toTypeConstructor + lazy val ShortTpe = definitions.ShortClass.toTypeConstructor + lazy val CharTpe = definitions.CharClass.toTypeConstructor + lazy val IntTpe = definitions.IntClass.toTypeConstructor + lazy val LongTpe = definitions.LongClass.toTypeConstructor + lazy val FloatTpe = definitions.FloatClass.toTypeConstructor + lazy val DoubleTpe = definitions.DoubleClass.toTypeConstructor + lazy val BooleanTpe = definitions.BooleanClass.toTypeConstructor + lazy val UnitTpe = definitions.UnitClass.toTypeConstructor + lazy val AnyTpe = definitions.AnyClass.toTypeConstructor + lazy val ObjectTpe = definitions.ObjectClass.toTypeConstructor + lazy val AnyValTpe = definitions.AnyValClass.toTypeConstructor + lazy val AnyRefTpe = definitions.AnyRefClass.toTypeConstructor + lazy val NothingTpe = definitions.NothingClass.toTypeConstructor + lazy val NullTpe = definitions.NullClass.toTypeConstructor /** Since both the value parameter types and the result type may * require access to the type parameter symbols, we model polymorphic @@ -183,11 +183,11 @@ trait Definitions extends api.StandardDefinitions { // It becomes tricky to create dedicated objects for other symbols because // of initialization order issues. lazy val JavaLangPackage = getRequiredPackage(sn.JavaLang) - lazy val JavaLangPackageClass = JavaLangPackage.moduleClass.asClassSymbol + lazy val JavaLangPackageClass = JavaLangPackage.moduleClass.asClass lazy val ScalaPackage = getRequiredPackage(nme.scala_) - lazy val ScalaPackageClass = ScalaPackage.moduleClass.asClassSymbol + lazy val ScalaPackageClass = ScalaPackage.moduleClass.asClass lazy val RuntimePackage = getRequiredPackage("scala.runtime") - lazy val RuntimePackageClass = RuntimePackage.moduleClass.asClassSymbol + lazy val RuntimePackageClass = RuntimePackage.moduleClass.asClass lazy val JavaLangEnumClass = requiredClass[java.lang.Enum[_]] @@ -471,11 +471,11 @@ trait Definitions extends api.StandardDefinitions { lazy val OptManifestClass = requiredClass[scala.reflect.OptManifest[_]] lazy val NoManifest = requiredModule[scala.reflect.NoManifest.type] - lazy val ExprsClass = getClassIfDefined("scala.reflect.api.Exprs") // defined in scala-reflect.jar, so we need to be careful - lazy val ExprClass = if (ExprsClass != NoSymbol) getMemberClass(ExprsClass, tpnme.Expr) else NoSymbol - def ExprSplice = if (ExprsClass != NoSymbol) getMemberMethod(ExprClass, nme.splice) else NoSymbol - def ExprValue = if (ExprsClass != NoSymbol) getMemberMethod(ExprClass, nme.value) else NoSymbol - lazy val ExprModule = if (ExprsClass != NoSymbol) getMemberModule(ExprsClass, nme.Expr) else NoSymbol + lazy val ExprsClass = requiredClass[scala.reflect.base.Exprs] + lazy val ExprClass = getMemberClass(ExprsClass, tpnme.Expr) + def ExprSplice = getMemberMethod(ExprClass, nme.splice) + def ExprValue = getMemberMethod(ExprClass, nme.value) + lazy val ExprModule = getMemberModule(ExprsClass, nme.Expr) lazy val ClassTagModule = requiredModule[scala.reflect.ClassTag[_]] lazy val ClassTagClass = requiredClass[scala.reflect.ClassTag[_]] @@ -486,8 +486,7 @@ trait Definitions extends api.StandardDefinitions { lazy val TypeTagModule = getMemberModule(TypeTagsClass, nme.TypeTag) lazy val BaseUniverseClass = requiredClass[scala.reflect.base.Universe] - lazy val ApiUniverseClass = getClassIfDefined("scala.reflect.api.Universe") // defined in scala-reflect.jar, so we need to be careful - def ApiUniverseReify = if (ApiUniverseClass != NoSymbol) getMemberMethod(ApiUniverseClass, nme.reify) else NoSymbol + def BaseUniverseReify = getMemberMethod(BaseUniverseClass, nme.reify) lazy val JavaUniverseClass = getClassIfDefined("scala.reflect.api.JavaUniverse") // defined in scala-reflect.jar, so we need to be careful lazy val MirrorOfClass = requiredClass[scala.reflect.base.MirrorOf[_]] @@ -495,13 +494,13 @@ trait Definitions extends api.StandardDefinitions { lazy val TypeCreatorClass = requiredClass[scala.reflect.base.TypeCreator] lazy val TreeCreatorClass = requiredClass[scala.reflect.base.TreeCreator] - lazy val MacroContextClass = getClassIfDefined("scala.reflect.makro.Context") // defined in scala-reflect.jar, so we need to be careful + lazy val MacroContextClass = getClassIfDefined("scala.reflect.macros.Context") // defined in scala-reflect.jar, so we need to be careful def MacroContextPrefix = if (MacroContextClass != NoSymbol) getMemberMethod(MacroContextClass, nme.prefix) else NoSymbol def MacroContextPrefixType = if (MacroContextClass != NoSymbol) getMemberType(MacroContextClass, tpnme.PrefixType) else NoSymbol def MacroContextUniverse = if (MacroContextClass != NoSymbol) getMemberMethod(MacroContextClass, nme.universe) else NoSymbol def MacroContextMirror = if (MacroContextClass != NoSymbol) getMemberMethod(MacroContextClass, nme.mirror) else NoSymbol - lazy val MacroImplAnnotation = requiredClass[scala.reflect.makro.internal.macroImpl] - lazy val MacroInternalPackage = getPackageObject("scala.reflect.makro.internal") + lazy val MacroImplAnnotation = requiredClass[scala.reflect.macros.internal.macroImpl] + lazy val MacroInternalPackage = getPackageObject("scala.reflect.macros.internal") def MacroInternal_materializeClassTag = getMemberMethod(MacroInternalPackage, nme.materializeClassTag) def MacroInternal_materializeAbsTypeTag = getMemberMethod(MacroInternalPackage, nme.materializeAbsTypeTag) def MacroInternal_materializeTypeTag = getMemberMethod(MacroInternalPackage, nme.materializeTypeTag) @@ -1045,7 +1044,7 @@ trait Definitions extends api.StandardDefinitions { // System.err.println("isMethod = " + result.isMethod) // System.err.println("isTerm = " + result.isTerm) // System.err.println("isValue = " + result.isValue) - // result.asMethodSymbol + // result.asMethod // // prints this: // @@ -1074,8 +1073,8 @@ trait Definitions extends api.StandardDefinitions { // [scalacfork] // [scalacfork] uncaught exception during compilation: java.lang.ClassCastException // [scalacfork] error: java.lang.ClassCastException: value apply - // [scalacfork] at scala.reflect.base.Symbols$SymbolBase$class.asMethodSymbol(Symbols.scala:118) - // [scalacfork] at scala.reflect.internal.Symbols$SymbolContextApiImpl.asMethodSymbol(Symbols.scala:63) + // [scalacfork] at scala.reflect.base.Symbols$SymbolBase$class.asMethod(Symbols.scala:118) + // [scalacfork] at scala.reflect.internal.Symbols$SymbolContextApiImpl.asMethod(Symbols.scala:63) // [scalacfork] at scala.reflect.internal.Definitions$DefinitionsClass.Symbol_apply(Definitions.scala:381) // [Eugene++] should be a ClassCastException instead? diff --git a/src/reflect/scala/reflect/internal/ExistentialsAndSkolems.scala b/src/reflect/scala/reflect/internal/ExistentialsAndSkolems.scala index f1fe4fc118..833ab81b9f 100644 --- a/src/reflect/scala/reflect/internal/ExistentialsAndSkolems.scala +++ b/src/reflect/scala/reflect/internal/ExistentialsAndSkolems.scala @@ -1,5 +1,5 @@ /* NSC -- new scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/reflect/scala/reflect/internal/FatalError.scala b/src/reflect/scala/reflect/internal/FatalError.scala index c843308480..428803994b 100644 --- a/src/reflect/scala/reflect/internal/FatalError.scala +++ b/src/reflect/scala/reflect/internal/FatalError.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ package scala.reflect.internal diff --git a/src/reflect/scala/reflect/internal/FlagSets.scala b/src/reflect/scala/reflect/internal/FlagSets.scala index 0354d2513c..6e77741355 100644 --- a/src/reflect/scala/reflect/internal/FlagSets.scala +++ b/src/reflect/scala/reflect/internal/FlagSets.scala @@ -13,8 +13,7 @@ trait FlagSets extends api.FlagSets { self: SymbolTable => private class FlagOpsImpl(left: Long) extends FlagOps { def | (right: Long): Long = left | right - def & (right: Long): Long = left & right - def containsAll (right: Long): Boolean = (right & ~left) == 0 + def hasFlag(right: Long): Boolean = (left & right) != 0 } val NoFlags: FlagSet = 0L @@ -47,20 +46,5 @@ trait FlagSets extends api.FlagSets { self: SymbolTable => val CONTRAVARIANT : FlagSet = Flags.CONTRAVARIANT val DEFAULTPARAM : FlagSet = Flags.DEFAULTPARAM val INTERFACE : FlagSet = Flags.INTERFACE - - def union(flags: FlagSet*): FlagSet = { - var acc = 0L - for (flag <- flags) acc |= flag - acc - } - - def intersection(flags: FlagSet*): FlagSet = { - var acc = -1L - for (flag <- flags) acc &= flag - acc - } - - def containsAll(superset: FlagSet, subset: FlagSet): Boolean = - (subset & ~superset) == 0 } } diff --git a/src/reflect/scala/reflect/internal/Flags.scala b/src/reflect/scala/reflect/internal/Flags.scala index 55fa00dd4d..f3f3bf5ce8 100644 --- a/src/reflect/scala/reflect/internal/Flags.scala +++ b/src/reflect/scala/reflect/internal/Flags.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/reflect/scala/reflect/internal/InfoTransformers.scala b/src/reflect/scala/reflect/internal/InfoTransformers.scala index e53f714c0c..e25ebc0076 100644 --- a/src/reflect/scala/reflect/internal/InfoTransformers.scala +++ b/src/reflect/scala/reflect/internal/InfoTransformers.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/reflect/scala/reflect/internal/Kinds.scala b/src/reflect/scala/reflect/internal/Kinds.scala index b736a9192f..eb94f0e11c 100644 --- a/src/reflect/scala/reflect/internal/Kinds.scala +++ b/src/reflect/scala/reflect/internal/Kinds.scala @@ -1,5 +1,5 @@ /* NSC -- new scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/reflect/scala/reflect/internal/Mirrors.scala b/src/reflect/scala/reflect/internal/Mirrors.scala index f7561ae274..2e2e63a4b4 100644 --- a/src/reflect/scala/reflect/internal/Mirrors.scala +++ b/src/reflect/scala/reflect/internal/Mirrors.scala @@ -1,6 +1,6 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/reflect/scala/reflect/internal/MissingRequirementError.scala b/src/reflect/scala/reflect/internal/MissingRequirementError.scala index fbbbcc1928..5ede51d5f3 100644 --- a/src/reflect/scala/reflect/internal/MissingRequirementError.scala +++ b/src/reflect/scala/reflect/internal/MissingRequirementError.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/reflect/scala/reflect/internal/Names.scala b/src/reflect/scala/reflect/internal/Names.scala index 72e6707f57..835a46f05d 100644 --- a/src/reflect/scala/reflect/internal/Names.scala +++ b/src/reflect/scala/reflect/internal/Names.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/reflect/scala/reflect/internal/Phase.scala b/src/reflect/scala/reflect/internal/Phase.scala index 68dc5ce783..ac30d49b8c 100644 --- a/src/reflect/scala/reflect/internal/Phase.scala +++ b/src/reflect/scala/reflect/internal/Phase.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/reflect/scala/reflect/internal/Printers.scala b/src/reflect/scala/reflect/internal/Printers.scala index 18f9928124..e3e2063b05 100644 --- a/src/reflect/scala/reflect/internal/Printers.scala +++ b/src/reflect/scala/reflect/internal/Printers.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ @@ -670,7 +670,7 @@ trait Printers extends api.Printers { self: SymbolTable => if (flags == NoFlags) nme.NoFlags.toString else { val s_flags = new collection.mutable.ListBuffer[String] - for (i <- 0 to 63 if (flags containsAll (1L << i))) + for (i <- 0 to 63 if (flags hasFlag (1L << i))) s_flags += flagToString(1L << i).replace("<", "").replace(">", "").toUpperCase s_flags mkString " | " } diff --git a/src/reflect/scala/reflect/internal/Scopes.scala b/src/reflect/scala/reflect/internal/Scopes.scala index 89e3c52de6..ed75b5d855 100644 --- a/src/reflect/scala/reflect/internal/Scopes.scala +++ b/src/reflect/scala/reflect/internal/Scopes.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ @@ -41,9 +41,9 @@ trait Scopes extends api.Scopes { self: SymbolTable => * This is necessary because when run from reflection every scope needs to have a * SynchronizedScope as mixin. */ - class Scope protected[Scopes] (initElems: ScopeEntry = null, initFingerPrints: Long = 0L) extends Iterable[Symbol] { - - /** A bitset containing the last 6 bits of the start value of every name + class Scope protected[Scopes] (initElems: ScopeEntry = null, initFingerPrints: Long = 0L) extends ScopeBase with MemberScopeBase { + + /** A bitset containing the last 6 bits of the start value of every name * stored in this scope. */ var fingerPrints: Long = initFingerPrints @@ -118,10 +118,10 @@ trait Scopes extends api.Scopes { self: SymbolTable => * * @param sym ... */ - def enter[T <: Symbol](sym: T): T = { + def enter[T <: Symbol](sym: T): T = { fingerPrints |= sym.name.fingerPrint - enterEntry(newScopeEntry(sym, this)) - sym + enterEntry(newScopeEntry(sym, this)) + sym } /** enter a symbol, asserting that no symbol with same name exists in scope @@ -282,6 +282,10 @@ trait Scopes extends api.Scopes { self: SymbolTable => elemsCache } + /** Vanilla scope - symbols are stored in declaration order. + */ + def sorted: List[Symbol] = toList + /** Return the nesting level of this scope, i.e. the number of times this scope * was nested in another */ def nestingLevel = nestinglevel @@ -320,18 +324,53 @@ trait Scopes extends api.Scopes { self: SymbolTable => override def filter(p: Symbol => Boolean): Scope = if (!(toList forall p)) newScopeWith(toList filter p: _*) else this + @deprecated("Use `toList.reverse` instead", "2.10.0") + def reverse: List[Symbol] = toList.reverse + override def mkString(start: String, sep: String, end: String) = toList.map(_.defString).mkString(start, sep, end) override def toString(): String = mkString("Scope{\n ", ";\n ", "\n}") - } implicit val ScopeTag = ClassTag[Scope](classOf[Scope]) + type MemberScope = Scope + + implicit val MemberScopeTag = ClassTag[MemberScope](classOf[MemberScope]) + /** Create a new scope */ def newScope: Scope = new Scope() + /** Create a new scope to be used in `findMembers`. + * + * But why do we need a special scope for `findMembers`? + * Let me tell you a story. + * + * `findMembers` creates a synthetic scope and then iterates over + * base classes in linearization order, and for every scrutinized class + * iterates over `decls`, the collection of symbols declared in that class. + * Declarations that fit the filter get appended to the created scope. + * + * The problem is that `decls` returns a Scope, and to iterate a scope performantly + * one needs to go from its end to its beginning. + * + * Hence the `findMembers` scope is populated in a wicked order: + * symbols that belong to the same declaring class come in reverse order of their declaration, + * however, the scope itself is ordered w.r.t the linearization of the target type. + * + * Once `members` became a public API, this has been confusing countless numbers of users. + * Therefore we introduce a special flavor of scopes to accommodate this quirk of `findMembers` + */ + private[scala] def newFindMemberScope: Scope = new Scope() { + override def sorted = { + val members = toList + val owners = members.map(_.owner).distinct + val grouped = members groupBy (_.owner) + owners.flatMap(owner => grouped(owner).reverse) + } + } + /** Create a new scope nested in another one with which it shares its elements */ def newNestedScope(outer: Scope): Scope = new Scope(outer) diff --git a/src/reflect/scala/reflect/internal/StdNames.scala b/src/reflect/scala/reflect/internal/StdNames.scala index 75962ff9d0..c1e5f78d50 100644 --- a/src/reflect/scala/reflect/internal/StdNames.scala +++ b/src/reflect/scala/reflect/internal/StdNames.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ @@ -616,7 +616,6 @@ trait StdNames { val apply: NameType = "apply" val applyDynamic: NameType = "applyDynamic" val applyDynamicNamed: NameType = "applyDynamicNamed" - val applyImpl: NameType = "applyImpl" val applyOrElse: NameType = "applyOrElse" val args : NameType = "args" val argv : NameType = "argv" @@ -628,14 +627,13 @@ trait StdNames { val array_length : NameType = "array_length" val array_update : NameType = "array_update" val arraycopy: NameType = "arraycopy" - val asTermSymbol: NameType = "asTermSymbol" - val asModuleSymbol: NameType = "asModuleSymbol" - val asMethodSymbol: NameType = "asMethodSymbol" - val asTypeSymbol: NameType = "asTypeSymbol" - val asClassSymbol: NameType = "asClassSymbol" + val asTerm: NameType = "asTerm" + val asModule: NameType = "asModule" + val asMethod: NameType = "asMethod" + val asType: NameType = "asType" + val asClass: NameType = "asClass" val asInstanceOf_ : NameType = "asInstanceOf" val asInstanceOf_Ob : NameType = "$asInstanceOf" - val asTypeConstructor: NameType = "asTypeConstructor" val assert_ : NameType = "assert" val assume_ : NameType = "assume" val basis : NameType = "basis" @@ -767,6 +765,7 @@ trait StdNames { val toObjectArray : NameType = "toObjectArray" val toSeq: NameType = "toSeq" val toString_ : NameType = if (forMSIL) "ToString" else "toString" + val toTypeConstructor: NameType = "toTypeConstructor" val tpe : NameType = "tpe" val tree : NameType = "tree" val true_ : NameType = "true" @@ -938,6 +937,12 @@ trait StdNames { case _ => NO_NAME } + def primitiveMethodName(name: Name): TermName = + primitiveInfixMethodName(name) match { + case NO_NAME => primitivePostfixMethodName(name) + case name => name + } + /** Translate a String into a list of simple TypeNames and TermNames. * In all segments before the last, type/term is determined by whether * the following separator char is '.' or '#'. In the last segment, diff --git a/src/reflect/scala/reflect/internal/SymbolTable.scala b/src/reflect/scala/reflect/internal/SymbolTable.scala index 5ae8f22c64..c564a93b62 100644 --- a/src/reflect/scala/reflect/internal/SymbolTable.scala +++ b/src/reflect/scala/reflect/internal/SymbolTable.scala @@ -1,5 +1,5 @@ /* NSC -- new scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ @@ -9,7 +9,7 @@ package internal import scala.collection.{ mutable, immutable } import util._ -abstract class SymbolTable extends makro.Universe +abstract class SymbolTable extends macros.Universe with Collections with Names with Symbols diff --git a/src/reflect/scala/reflect/internal/Symbols.scala b/src/reflect/scala/reflect/internal/Symbols.scala index e6a9cb46c6..2a306d7c6e 100644 --- a/src/reflect/scala/reflect/internal/Symbols.scala +++ b/src/reflect/scala/reflect/internal/Symbols.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ @@ -64,6 +64,8 @@ trait Symbols extends api.Symbols { self: SymbolTable => def kind: String = kindString def isExistential: Boolean = this.isExistentiallyBound + def isParamWithDefault: Boolean = this.hasDefault + def isByNameParam: Boolean = this.isValueParameter && (this hasFlag BYNAMEPARAM) def newNestedSymbol(name: Name, pos: Position, newFlags: Long, isClass: Boolean): Symbol = name match { case n: TermName => newTermSymbol(n, pos, newFlags) @@ -75,15 +77,17 @@ trait Symbols extends api.Symbols { self: SymbolTable => def typeSignature: Type = info def typeSignatureIn(site: Type): Type = site memberInfo this - def asType: Type = tpe - def asTypeIn(site: Type): Type = site.memberType(this) - def asTypeConstructor: Type = typeConstructor + def toType: Type = tpe + def toTypeIn(site: Type): Type = site.memberType(this) + def toTypeConstructor: Type = typeConstructor def setFlags(flags: FlagSet): this.type = setInternalFlags(flags) def setInternalFlags(flag: Long): this.type = { setFlag(flag); this } def setTypeSignature(tpe: Type): this.type = { setInfo(tpe); this } def getAnnotations: List[AnnotationInfo] = { initialize; annotations } def setAnnotations(annots: AnnotationInfo*): this.type = { setAnnotations(annots.toList); this } + def getter: Symbol = getter(owner) + def setter: Symbol = setter(owner) } /** The class for all symbols */ @@ -311,10 +315,16 @@ trait Symbols extends api.Symbols { self: SymbolTable => skolem setInfo (basis.info cloneInfo skolem) } + // don't test directly -- use isGADTSkolem + // used to single out a gadt skolem symbol in deskolemizeGADT + // gadtskolems are created in adaptConstrPattern and removed at the end of typedCase + @inline final protected[Symbols] def GADT_SKOLEM_FLAGS = CASEACCESSOR | SYNTHETIC + // flags set up to maintain TypeSkolem's invariant: origin.isInstanceOf[Symbol] == !hasFlag(EXISTENTIAL) - // CASEACCESSOR | SYNTHETIC used to single this symbol out in deskolemizeGADT + // GADT_SKOLEM_FLAGS (== CASEACCESSOR | SYNTHETIC) used to single this symbol out in deskolemizeGADT + // TODO: it would be better to allocate a new bit in the flag long for GADTSkolem rather than OR'ing together CASEACCESSOR | SYNTHETIC def newGADTSkolem(name: TypeName, origin: Symbol, info: Type): TypeSkolem = - newTypeSkolemSymbol(name, origin, origin.pos, origin.flags & ~(EXISTENTIAL | PARAM) | CASEACCESSOR | SYNTHETIC) setInfo info + newTypeSkolemSymbol(name, origin, origin.pos, origin.flags & ~(EXISTENTIAL | PARAM) | GADT_SKOLEM_FLAGS) setInfo info final def freshExistential(suffix: String): TypeSymbol = newExistential(freshExistentialName(suffix), pos) @@ -454,6 +464,7 @@ trait Symbols extends api.Symbols { self: SymbolTable => def isAliasType = false def isAbstractType = false def isSkolem = false + def isMacro = this hasFlag MACRO /** A Type, but not a Class. */ def isNonClassType = false @@ -2484,6 +2495,21 @@ trait Symbols extends api.Symbols { self: SymbolTable => mtpeResult = res res } + + override def params: List[List[Symbol]] = paramss + + override def isVarargs: Boolean = definitions.isVarArgsList(paramss.flatten) + + override def returnType: Type = { + def loop(tpe: Type): Type = + tpe match { + case NullaryMethodType(ret) => loop(ret) + case MethodType(_, ret) => loop(ret) + case PolyType(_, tpe) => loop(tpe) + case tpe => tpe + } + loop(info) + } } implicit val MethodSymbolTag = ClassTag[MethodSymbol](classOf[MethodSymbol]) @@ -2683,7 +2709,7 @@ trait Symbols extends api.Symbols { self: SymbolTable => // a type symbol bound by an existential type, for instance the T in // List[T] forSome { type T } override def isExistentialSkolem = this hasFlag EXISTENTIAL - override def isGADTSkolem = this hasFlag CASEACCESSOR | SYNTHETIC + override def isGADTSkolem = this hasAllFlags GADT_SKOLEM_FLAGS override def isTypeSkolem = this hasFlag PARAM override def isAbstractType = this hasFlag DEFERRED @@ -2747,8 +2773,10 @@ trait Symbols extends api.Symbols { self: SymbolTable => override def isJavaInterface = hasAllFlags(JAVA | TRAIT) override def isNestedClass = !owner.isPackageClass override def isNumericValueClass = definitions.isNumericValueClass(this) + override def isNumeric = isNumericValueClass override def isPackageObjectClass = isModuleClass && (name == tpnme.PACKAGE) override def isPrimitiveValueClass = definitions.isPrimitiveValueClass(this) + override def isPrimitive = isPrimitiveValueClass // The corresponding interface is the last parent by convention. private def lastParent = if (tpe.parents.isEmpty) NoSymbol else tpe.parents.last.typeSymbol @@ -2890,7 +2918,7 @@ trait Symbols extends api.Symbols { self: SymbolTable => private[this] var typeOfThisCache: Type = _ private[this] var typeOfThisPeriod = NoPeriod - private var implicitMembersCacheValue: List[Symbol] = Nil + private var implicitMembersCacheValue: Scope = EmptyScope private var implicitMembersCacheKey1: Type = NoType private var implicitMembersCacheKey2: ScopeEntry = null @@ -2909,7 +2937,7 @@ trait Symbols extends api.Symbols { self: SymbolTable => typeOfThisCache } - def implicitMembers: List[Symbol] = { + def implicitMembers: Scope = { val tp = info if ((implicitMembersCacheKey1 ne tp) || (implicitMembersCacheKey2 ne tp.decls.elems)) { // Skip a package object class, because the members are also in diff --git a/src/reflect/scala/reflect/internal/TreeGen.scala b/src/reflect/scala/reflect/internal/TreeGen.scala index 285700f9ff..d160695e67 100644 --- a/src/reflect/scala/reflect/internal/TreeGen.scala +++ b/src/reflect/scala/reflect/internal/TreeGen.scala @@ -1,7 +1,7 @@ package scala.reflect package internal -abstract class TreeGen extends makro.TreeBuilder { +abstract class TreeGen extends macros.TreeBuilder { val global: SymbolTable import global._ diff --git a/src/reflect/scala/reflect/internal/TreeInfo.scala b/src/reflect/scala/reflect/internal/TreeInfo.scala index 7ba749ed2c..1b4c1b2877 100644 --- a/src/reflect/scala/reflect/internal/TreeInfo.scala +++ b/src/reflect/scala/reflect/internal/TreeInfo.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ @@ -326,9 +326,6 @@ abstract class TreeInfo { case _ => false } - /** a Match(Typed(_, tpt), _) is unchecked if isUncheckedAnnotation(tpt.tpe) */ - def isUncheckedAnnotation(tpe: Type) = tpe hasAnnotation definitions.UncheckedClass - /** a Match(Typed(_, tpt), _) must be translated into a switch if isSwitchAnnotation(tpt.tpe) */ def isSwitchAnnotation(tpe: Type) = tpe hasAnnotation definitions.SwitchClass @@ -464,6 +461,16 @@ abstract class TreeInfo { case _ => false } + + // used in the symbols for labeldefs and valdefs emitted by the pattern matcher + // tailcalls, cps,... use this flag combination to detect translated matches + // TODO: move to Flags + final val SYNTH_CASE_FLAGS = CASE | SYNTHETIC + + def isSynthCaseSymbol(sym: Symbol) = sym hasAllFlags SYNTH_CASE_FLAGS + def hasSynthCaseSymbol(t: Tree) = t.symbol != null && isSynthCaseSymbol(t.symbol) + + /** The method part of an application node */ def methPart(tree: Tree): Tree = tree match { diff --git a/src/reflect/scala/reflect/internal/Trees.scala b/src/reflect/scala/reflect/internal/Trees.scala index 619e3bc170..220869e4d2 100644 --- a/src/reflect/scala/reflect/internal/Trees.scala +++ b/src/reflect/scala/reflect/internal/Trees.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ @@ -1024,14 +1024,14 @@ trait Trees extends api.Trees { self: SymbolTable => } } - + /** Delegate for a TypeTree symbol. This operation is unsafe because * it may trigger type checking when forcing the type symbol of the * underlying type. */ protected def typeTreeSymbol(tree: TypeTree): Symbol = if (tree.tpe == null) null else tree.tpe.typeSymbol - + // --- generic traversers and transformers override protected def itraverse(traverser: Traverser, tree: Tree): Unit = { @@ -1266,7 +1266,7 @@ trait Trees extends api.Trees { self: SymbolTable => } } - private def mclass(sym: Symbol) = sym map (_.asModuleSymbol.moduleClass) + private def mclass(sym: Symbol) = sym map (_.asModule.moduleClass) // --- specific traversers and transformers diff --git a/src/reflect/scala/reflect/internal/TypeDebugging.scala b/src/reflect/scala/reflect/internal/TypeDebugging.scala index 33f6a645e8..a4d426171d 100644 --- a/src/reflect/scala/reflect/internal/TypeDebugging.scala +++ b/src/reflect/scala/reflect/internal/TypeDebugging.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala index 8972dfa828..e9a9ce1aa0 100644 --- a/src/reflect/scala/reflect/internal/Types.scala +++ b/src/reflect/scala/reflect/internal/Types.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ @@ -323,6 +323,7 @@ trait Types extends api.Types { self: SymbolTable => /** Is this type higher-kinded, i.e., is it a type constructor @M */ def isHigherKinded: Boolean = false + def takesTypeArgs: Boolean = this.isHigherKinded /** Does this type denote a stable reference (i.e. singleton type)? */ def isStable: Boolean = false @@ -612,21 +613,21 @@ trait Types extends api.Types { self: SymbolTable => * Members appear in linearization order of their owners. * Members with the same owner appear in reverse order of their declarations. */ - def members: List[Symbol] = membersBasedOnFlags(0, 0) + def members: Scope = membersBasedOnFlags(0, 0) /** A list of all non-private members of this type (defined or inherited) */ - def nonPrivateMembers: List[Symbol] = membersBasedOnFlags(BridgeAndPrivateFlags, 0) + def nonPrivateMembers: Scope = membersBasedOnFlags(BridgeAndPrivateFlags, 0) /** A list of all non-private members of this type (defined or inherited), * admitting members with given flags `admit` */ - def nonPrivateMembersAdmitting(admit: Long): List[Symbol] = membersBasedOnFlags(BridgeAndPrivateFlags & ~admit, 0) + def nonPrivateMembersAdmitting(admit: Long): Scope = membersBasedOnFlags(BridgeAndPrivateFlags & ~admit, 0) /** A list of all implicit symbols of this type (defined or inherited) */ - def implicitMembers: List[Symbol] = membersBasedOnFlags(BridgeFlags, IMPLICIT) + def implicitMembers: Scope = membersBasedOnFlags(BridgeFlags, IMPLICIT) /** A list of all deferred symbols of this type (defined or inherited) */ - def deferredMembers: List[Symbol] = membersBasedOnFlags(BridgeFlags, DEFERRED) + def deferredMembers: Scope = membersBasedOnFlags(BridgeFlags, DEFERRED) /** The member with given name, * an OverloadedSymbol if several exist, NoSymbol if none exist */ @@ -642,12 +643,12 @@ trait Types extends api.Types { self: SymbolTable => /** All members with the given flags, excluding bridges. */ - def membersWithFlags(requiredFlags: Long): List[Symbol] = + def membersWithFlags(requiredFlags: Long): Scope = membersBasedOnFlags(BridgeFlags, requiredFlags) /** All non-private members with the given flags, excluding bridges. */ - def nonPrivateMembersWithFlags(requiredFlags: Long): List[Symbol] = + def nonPrivateMembersWithFlags(requiredFlags: Long): Scope = membersBasedOnFlags(BridgeAndPrivateFlags, requiredFlags) /** The non-private member with given name, admitting members with given flags `admit`. @@ -668,7 +669,7 @@ trait Types extends api.Types { self: SymbolTable => /** Members excluding and requiring the given flags. * Note: unfortunately it doesn't work to exclude DEFERRED this way. */ - def membersBasedOnFlags(excludedFlags: Long, requiredFlags: Long): List[Symbol] = + def membersBasedOnFlags(excludedFlags: Long, requiredFlags: Long): Scope = findMembers(excludedFlags, requiredFlags) // findMember(nme.ANYNAME, excludedFlags, requiredFlags, false).alternatives @@ -1020,7 +1021,7 @@ trait Types extends api.Types { self: SymbolTable => else (baseClasses.head.newOverloaded(this, alts)) } - def findMembers(excludedFlags: Long, requiredFlags: Long): List[Symbol] = { + def findMembers(excludedFlags: Long, requiredFlags: Long): Scope = { // if this type contains type variables, put them to sleep for a while -- don't just wipe them out by // replacing them by the corresponding type parameter, as that messes up (e.g.) type variables in type refinements // without this, the matchesType call would lead to type variables on both sides @@ -1054,7 +1055,7 @@ trait Types extends api.Types { self: SymbolTable => (bcs eq bcs0) || (flags & PrivateLocal) != PrivateLocal || (bcs0.head.hasTransOwner(bcs.head)))) { - if (members eq null) members = newScope + if (members eq null) members = newFindMemberScope var others: ScopeEntry = members.lookupEntry(sym.name) var symtpe: Type = null while ((others ne null) && { @@ -1083,7 +1084,7 @@ trait Types extends api.Types { self: SymbolTable => } // while (continue) Statistics.popTimer(typeOpsStack, start) if (suspension ne null) suspension foreach (_.suspended = false) - if (members eq null) Nil else members.toList + if (members eq null) EmptyScope else members } /** @@ -3821,6 +3822,7 @@ trait Types extends api.Types { self: SymbolTable => Statistics.incCounter(rawTypeCount) if (uniqueRunId != currentRunId) { uniques = util.HashSet[Type]("uniques", initialUniquesCapacity) + perRunCaches.recordCache(uniques) uniqueRunId = currentRunId } (uniques findEntryOrUpdate tp).asInstanceOf[T] diff --git a/src/reflect/scala/reflect/internal/pickling/PickleBuffer.scala b/src/reflect/scala/reflect/internal/pickling/PickleBuffer.scala index 7f0895ce64..5d3cb92dc0 100644 --- a/src/reflect/scala/reflect/internal/pickling/PickleBuffer.scala +++ b/src/reflect/scala/reflect/internal/pickling/PickleBuffer.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/reflect/scala/reflect/internal/pickling/UnPickler.scala b/src/reflect/scala/reflect/internal/pickling/UnPickler.scala index 4411b79b97..55746f414b 100644 --- a/src/reflect/scala/reflect/internal/pickling/UnPickler.scala +++ b/src/reflect/scala/reflect/internal/pickling/UnPickler.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/reflect/scala/reflect/internal/settings/AbsSettings.scala b/src/reflect/scala/reflect/internal/settings/AbsSettings.scala index 9bbba3f079..89281e9835 100644 --- a/src/reflect/scala/reflect/internal/settings/AbsSettings.scala +++ b/src/reflect/scala/reflect/internal/settings/AbsSettings.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/reflect/scala/reflect/internal/settings/MutableSettings.scala b/src/reflect/scala/reflect/internal/settings/MutableSettings.scala index e9899f690d..459326e96f 100644 --- a/src/reflect/scala/reflect/internal/settings/MutableSettings.scala +++ b/src/reflect/scala/reflect/internal/settings/MutableSettings.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ // $Id$ @@ -14,6 +14,7 @@ abstract class MutableSettings extends AbsSettings { type Setting <: SettingValue type BooleanSetting <: Setting { type T = Boolean } type IntSetting <: Setting { type T = Int } + type MultiStringSetting <: Setting { type T = List[String] } // basically this is a value which remembers if it's been modified trait SettingValue extends AbsSettingValue { @@ -46,4 +47,4 @@ abstract class MutableSettings extends AbsSettings { def XoldPatmat: BooleanSetting def XnoPatmatAnalysis: BooleanSetting def XfullLubs: BooleanSetting -}
\ No newline at end of file +} diff --git a/src/reflect/scala/reflect/internal/util/Collections.scala b/src/reflect/scala/reflect/internal/util/Collections.scala index 1f8eb15c90..2ac0e64edd 100644 --- a/src/reflect/scala/reflect/internal/util/Collections.scala +++ b/src/reflect/scala/reflect/internal/util/Collections.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/reflect/scala/reflect/internal/util/HashSet.scala b/src/reflect/scala/reflect/internal/util/HashSet.scala index a771dad2b0..51e540e235 100644 --- a/src/reflect/scala/reflect/internal/util/HashSet.scala +++ b/src/reflect/scala/reflect/internal/util/HashSet.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ @@ -13,7 +13,7 @@ object HashSet { new HashSet[T](label, initialCapacity) } -class HashSet[T >: Null <: AnyRef](val label: String, initialCapacity: Int) extends Set[T] { +class HashSet[T >: Null <: AnyRef](val label: String, initialCapacity: Int) extends Set[T] with collection.generic.Clearable { private var used = 0 private var table = new Array[AnyRef](initialCapacity) private def index(x: Int): Int = math.abs(x % table.length) diff --git a/src/reflect/scala/reflect/internal/util/Origins.scala b/src/reflect/scala/reflect/internal/util/Origins.scala index 3111730f76..e7a0c5b8f6 100644 --- a/src/reflect/scala/reflect/internal/util/Origins.scala +++ b/src/reflect/scala/reflect/internal/util/Origins.scala @@ -1,5 +1,5 @@ /* NSC -- new scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/reflect/scala/reflect/internal/util/Position.scala b/src/reflect/scala/reflect/internal/util/Position.scala index 3c251b3b31..e4c6e4aca1 100644 --- a/src/reflect/scala/reflect/internal/util/Position.scala +++ b/src/reflect/scala/reflect/internal/util/Position.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky * */ diff --git a/src/reflect/scala/reflect/internal/util/Set.scala b/src/reflect/scala/reflect/internal/util/Set.scala index cfc3e7eada..d708a09de7 100644 --- a/src/reflect/scala/reflect/internal/util/Set.scala +++ b/src/reflect/scala/reflect/internal/util/Set.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ package scala.reflect.internal.util diff --git a/src/reflect/scala/reflect/internal/util/SourceFile.scala b/src/reflect/scala/reflect/internal/util/SourceFile.scala index 793ef0ac22..747c1ad298 100644 --- a/src/reflect/scala/reflect/internal/util/SourceFile.scala +++ b/src/reflect/scala/reflect/internal/util/SourceFile.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/reflect/scala/reflect/makro/Aliases.scala b/src/reflect/scala/reflect/macros/Aliases.scala index 4bd246572f..46b7066902 100644 --- a/src/reflect/scala/reflect/makro/Aliases.scala +++ b/src/reflect/scala/reflect/macros/Aliases.scala @@ -1,5 +1,5 @@ package scala.reflect -package makro +package macros trait Aliases { self: Context => diff --git a/src/reflect/scala/reflect/makro/CapturedVariables.scala b/src/reflect/scala/reflect/macros/CapturedVariables.scala index 592e28b3b2..60ed6f5e7b 100644 --- a/src/reflect/scala/reflect/makro/CapturedVariables.scala +++ b/src/reflect/scala/reflect/macros/CapturedVariables.scala @@ -1,5 +1,5 @@ package scala.reflect -package makro +package macros trait CapturedVariables { self: Context => diff --git a/src/reflect/scala/reflect/makro/Context.scala b/src/reflect/scala/reflect/macros/Context.scala index f093016a38..37c8f9057e 100644 --- a/src/reflect/scala/reflect/makro/Context.scala +++ b/src/reflect/scala/reflect/macros/Context.scala @@ -1,11 +1,9 @@ package scala.reflect -package makro - -import language.experimental.macros +package macros // todo. introduce context hierarchy // the most lightweight context should just expose the stuff from the SIP -// the full context should include all traits from scala.reflect.makro (and probably reside in scala-compiler.jar) +// the full context should include all traits from scala.reflect.macros (and probably reside in scala-compiler.jar) trait Context extends Aliases with CapturedVariables diff --git a/src/reflect/scala/reflect/makro/Enclosures.scala b/src/reflect/scala/reflect/macros/Enclosures.scala index ff5c13a785..a07ff85a08 100644 --- a/src/reflect/scala/reflect/makro/Enclosures.scala +++ b/src/reflect/scala/reflect/macros/Enclosures.scala @@ -1,5 +1,5 @@ package scala.reflect -package makro +package macros trait Enclosures { self: Context => diff --git a/src/reflect/scala/reflect/makro/Evals.scala b/src/reflect/scala/reflect/macros/Evals.scala index 4e5fc2f97f..3837d749da 100644 --- a/src/reflect/scala/reflect/makro/Evals.scala +++ b/src/reflect/scala/reflect/macros/Evals.scala @@ -1,5 +1,5 @@ package scala.reflect -package makro +package macros trait Evals { self: Context => diff --git a/src/reflect/scala/reflect/makro/ExprUtils.scala b/src/reflect/scala/reflect/macros/ExprUtils.scala index c3e5cc6bc1..adcdc78c78 100644 --- a/src/reflect/scala/reflect/makro/ExprUtils.scala +++ b/src/reflect/scala/reflect/macros/ExprUtils.scala @@ -1,5 +1,5 @@ package scala.reflect -package makro +package macros trait ExprUtils { self: Context => diff --git a/src/reflect/scala/reflect/makro/Exprs.scala b/src/reflect/scala/reflect/macros/Exprs.scala index 91d3dafbf2..ceaab06d12 100644 --- a/src/reflect/scala/reflect/makro/Exprs.scala +++ b/src/reflect/scala/reflect/macros/Exprs.scala @@ -1,5 +1,5 @@ package scala.reflect -package makro +package macros trait Exprs { self: Context => diff --git a/src/reflect/scala/reflect/makro/FrontEnds.scala b/src/reflect/scala/reflect/macros/FrontEnds.scala index 5087f90174..d15db0725f 100644 --- a/src/reflect/scala/reflect/makro/FrontEnds.scala +++ b/src/reflect/scala/reflect/macros/FrontEnds.scala @@ -1,5 +1,5 @@ package scala.reflect -package makro +package macros trait FrontEnds extends scala.reflect.api.FrontEnds { self: Context => diff --git a/src/reflect/scala/reflect/makro/Infrastructure.scala b/src/reflect/scala/reflect/macros/Infrastructure.scala index e6bfe33366..5ae2c08265 100644 --- a/src/reflect/scala/reflect/makro/Infrastructure.scala +++ b/src/reflect/scala/reflect/macros/Infrastructure.scala @@ -1,5 +1,5 @@ package scala.reflect -package makro +package macros trait Infrastructure { self: Context => @@ -35,7 +35,7 @@ trait Infrastructure { * * def staticEval[T](x: T) = macro staticEval[T] * - * def staticEval[T: c.TypeTag](c: Context)(x: c.Expr[T]) = { + * def staticEval[T](c: Context)(x: c.Expr[T]) = { * import scala.reflect.runtime.{universe => ru} * val mirror = ru.runtimeMirror(c.libraryClassLoader) * import scala.tools.reflect.ToolBox diff --git a/src/reflect/scala/reflect/makro/Names.scala b/src/reflect/scala/reflect/macros/Names.scala index 909976d83c..fab9bbbca5 100644 --- a/src/reflect/scala/reflect/makro/Names.scala +++ b/src/reflect/scala/reflect/macros/Names.scala @@ -1,5 +1,5 @@ package scala.reflect -package makro +package macros trait Names { self: Context => diff --git a/src/reflect/scala/reflect/makro/Parsers.scala b/src/reflect/scala/reflect/macros/Parsers.scala index 9866b7e491..ea87c5842e 100644 --- a/src/reflect/scala/reflect/makro/Parsers.scala +++ b/src/reflect/scala/reflect/macros/Parsers.scala @@ -1,5 +1,5 @@ package scala.reflect -package makro +package macros trait Parsers { self: Context => diff --git a/src/reflect/scala/reflect/makro/Reifiers.scala b/src/reflect/scala/reflect/macros/Reifiers.scala index f39f56f935..1bee17d548 100644 --- a/src/reflect/scala/reflect/makro/Reifiers.scala +++ b/src/reflect/scala/reflect/macros/Reifiers.scala @@ -1,5 +1,5 @@ package scala.reflect -package makro +package macros trait Reifiers { self: Context => diff --git a/src/reflect/scala/reflect/makro/Settings.scala b/src/reflect/scala/reflect/macros/Settings.scala index c6c7e5870b..8d166056c3 100644 --- a/src/reflect/scala/reflect/makro/Settings.scala +++ b/src/reflect/scala/reflect/macros/Settings.scala @@ -1,5 +1,5 @@ package scala.reflect -package makro +package macros trait Settings { self: Context => diff --git a/src/reflect/scala/reflect/makro/TreeBuilder.scala b/src/reflect/scala/reflect/macros/TreeBuilder.scala index c4179b9c80..06f5caf68b 100644 --- a/src/reflect/scala/reflect/makro/TreeBuilder.scala +++ b/src/reflect/scala/reflect/macros/TreeBuilder.scala @@ -1,5 +1,5 @@ package scala.reflect -package makro +package macros // [Eugene] I added some stuff that was necessary for typetag materialization macros // but we should think it over and pick other generally useful stuff diff --git a/src/reflect/scala/reflect/makro/TypeTags.scala b/src/reflect/scala/reflect/macros/TypeTags.scala index 53a9b116e3..8f590d1de4 100644 --- a/src/reflect/scala/reflect/makro/TypeTags.scala +++ b/src/reflect/scala/reflect/macros/TypeTags.scala @@ -1,5 +1,5 @@ package scala.reflect -package makro +package macros trait TypeTags { self: Context => diff --git a/src/reflect/scala/reflect/makro/Typers.scala b/src/reflect/scala/reflect/macros/Typers.scala index 4176c184d0..eef6507418 100644 --- a/src/reflect/scala/reflect/makro/Typers.scala +++ b/src/reflect/scala/reflect/macros/Typers.scala @@ -1,5 +1,5 @@ package scala.reflect -package makro +package macros trait Typers { self: Context => diff --git a/src/reflect/scala/reflect/makro/Universe.scala b/src/reflect/scala/reflect/macros/Universe.scala index d88e7e0bb8..4074dd9e93 100644 --- a/src/reflect/scala/reflect/makro/Universe.scala +++ b/src/reflect/scala/reflect/macros/Universe.scala @@ -1,5 +1,5 @@ package scala.reflect -package makro +package macros abstract class Universe extends scala.reflect.api.Universe { diff --git a/src/reflect/scala/reflect/makro/package.scala b/src/reflect/scala/reflect/macros/package.scala index 3c0e51030e..06ce0b3244 100644 --- a/src/reflect/scala/reflect/makro/package.scala +++ b/src/reflect/scala/reflect/macros/package.scala @@ -1,6 +1,6 @@ package scala.reflect -package object makro { +package object macros { type MirrorOf[U <: base.Universe with Singleton] = base.MirrorOf[U] } diff --git a/src/reflect/scala/reflect/runtime/JavaMirrors.scala b/src/reflect/scala/reflect/runtime/JavaMirrors.scala index 0878801715..2bf57d61cc 100644 --- a/src/reflect/scala/reflect/runtime/JavaMirrors.scala +++ b/src/reflect/scala/reflect/runtime/JavaMirrors.scala @@ -20,6 +20,8 @@ import internal.Flags._ //import scala.tools.nsc.util.ScalaClassLoader._ import ReflectionUtils.{singletonInstance} import language.existentials +import scala.runtime.{ScalaRunTime, BoxesRunTime} +import scala.reflect.internal.util.Collections._ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: SymbolTable => @@ -124,15 +126,16 @@ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: Sym private def ErrorStaticClass(wannabe: Symbol) = throw new ScalaReflectionException(s"$wannabe is a static class, use reflectClass on a RuntimeMirror to obtain its ClassMirror") private def ErrorStaticModule(wannabe: Symbol) = throw new ScalaReflectionException(s"$wannabe is a static module, use reflectModule on a RuntimeMirror to obtain its ModuleMirror") private def ErrorNotMember(wannabe: Symbol, owner: Symbol) = throw new ScalaReflectionException(s"expected a member of $owner, you provided ${wannabe.kind} ${wannabe.fullName}") - private def ErrorNotField(wannabe: Symbol) = throw new ScalaReflectionException(s"expected a field or an accessor method symbol, you provided $wannabe}") + private def ErrorNotField(wannabe: Symbol) = throw new ScalaReflectionException(s"expected a field or an accessor method symbol, you provided $wannabe") private def ErrorNonExistentField(wannabe: Symbol) = throw new ScalaReflectionException(s""" |Scala field ${wannabe.name} isn't represented as a Java field, neither it has a Java accessor method |note that private parameters of class constructors don't get mapped onto fields and/or accessors, |unless they are used outside of their declaring constructors. """.trim.stripMargin) private def ErrorSetImmutableField(wannabe: Symbol) = throw new ScalaReflectionException(s"cannot set an immutable field ${wannabe.name}") + private def ErrorNotConstructor(wannabe: Symbol, owner: Symbol) = throw new ScalaReflectionException(s"expected a constructor of $owner, you provided $wannabe") - def reflect(obj: Any): InstanceMirror = new JavaInstanceMirror(obj.asInstanceOf[AnyRef]) + def reflect[T: ClassTag](obj: T): InstanceMirror = new JavaInstanceMirror(obj) def reflectClass(cls: ClassSymbol): ClassMirror = { if (!cls.isStatic) ErrorInnerClass(cls) @@ -150,15 +153,27 @@ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: Sym def classSymbol(rtcls: RuntimeClass): ClassSymbol = classToScala(rtcls) - def moduleSymbol(rtcls: RuntimeClass): ModuleSymbol = classToScala(rtcls).companionModule.asModuleSymbol + def moduleSymbol(rtcls: RuntimeClass): ModuleSymbol = classToScala(rtcls).companionModule.asModule - private def checkMemberOf(wannabe: Symbol, owner: Symbol) = - if (!owner.info.member(wannabe.name).alternatives.contains(wannabe)) ErrorNotMember(wannabe, owner) + private def checkMemberOf(wannabe: Symbol, owner: ClassSymbol) { + if (wannabe.owner == AnyClass || wannabe.owner == AnyRefClass || wannabe.owner == ObjectClass) { + // do nothing + } else if (wannabe.owner == AnyValClass) { + if (!owner.isPrimitiveValueClass && !owner.isDerivedValueClass) ErrorNotMember(wannabe, owner) + } else { + if (!(owner.info.baseClasses contains wannabe.owner)) ErrorNotMember(wannabe, owner) + } + } + + private def preciseClass[T: ClassTag](instance: T) = { + val staticClazz = classTag[T].runtimeClass + val dynamicClazz = instance.getClass + if (staticClazz.isPrimitive) staticClazz else dynamicClazz + } - private class JavaInstanceMirror(obj: AnyRef) + private class JavaInstanceMirror[T: ClassTag](val instance: T) extends InstanceMirror { - def instance = obj - def symbol = wholemirror.classSymbol(obj.getClass) + def symbol = wholemirror.classSymbol(preciseClass(instance)) def reflectField(field: TermSymbol): FieldMirror = { checkMemberOf(field, symbol) if ((field.isMethod && !field.isAccessor) || field.isModule) ErrorNotField(field) @@ -166,30 +181,31 @@ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: Sym if (field.isGetter) nme.getterToLocal(field.name) else if (field.isSetter) nme.getterToLocal(nme.setterToGetter(field.name)) else field.name - val field1 = (field.owner.info decl name).asTermSymbol + val field1 = (field.owner.info decl name).asTerm try fieldToJava(field1) catch { case _: NoSuchFieldException => ErrorNonExistentField(field1) } - new JavaFieldMirror(obj, field1) + new JavaFieldMirror(instance, field1) } def reflectMethod(method: MethodSymbol): MethodMirror = { checkMemberOf(method, symbol) - new JavaMethodMirror(obj, method) + mkJavaMethodMirror(instance, method) } def reflectClass(cls: ClassSymbol): ClassMirror = { if (cls.isStatic) ErrorStaticClass(cls) checkMemberOf(cls, symbol) - new JavaClassMirror(instance, cls) + new JavaClassMirror(instance.asInstanceOf[AnyRef], cls) } def reflectModule(mod: ModuleSymbol): ModuleMirror = { if (mod.isStatic) ErrorStaticModule(mod) checkMemberOf(mod, symbol) - new JavaModuleMirror(instance, mod) + new JavaModuleMirror(instance.asInstanceOf[AnyRef], mod) } + override def toString = s"instance mirror for $instance" } - private class JavaFieldMirror(val receiver: AnyRef, val symbol: TermSymbol) + private class JavaFieldMirror(val receiver: Any, val symbol: TermSymbol) extends FieldMirror { lazy val jfield = { val jfield = fieldToJava(symbol) @@ -201,25 +217,141 @@ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: Sym if (!symbol.isMutable) ErrorSetImmutableField(symbol) jfield.set(receiver, value) } + override def toString = s"field mirror for ${symbol.fullName} (bound to $receiver)" + } + + private def showMethodSig(symbol: MethodSymbol): String = { + var sig = s"${symbol.fullName}" + if (symbol.typeParams.nonEmpty) { + def showTparam(tparam: Symbol) = + tparam.typeSignature match { + case tpe @ TypeBounds(_, _) => s"${tparam.name}$tpe" + case _ => tparam.name + } + def showTparams(tparams: List[Symbol]) = "[" + (tparams map showTparam mkString ", ") + "]" + sig += showTparams(symbol.typeParams) + } + if (symbol.params.nonEmpty) { + def showParam(param: Symbol) = s"${param.name}: ${param.typeSignature}" + def showParams(params: List[Symbol]) = { + val s_mods = if (params.nonEmpty && params(0).hasFlag(IMPLICIT)) "implicit " else "" + val s_params = params map showParam mkString ", " + "(" + s_mods + s_params + ")" + } + def showParamss(paramss: List[List[Symbol]]) = paramss map showParams mkString "" + sig += showParamss(symbol.params) + } + sig += s": ${symbol.returnType}" + sig + } + + // the "symbol == Any_getClass || symbol == Object_getClass" test doesn't cut it + // because both AnyVal and its primitive descendants define their own getClass methods + private def isGetClass(meth: MethodSymbol) = meth.name.toString == "getClass" && meth.params.flatten.isEmpty + private def isMagicPrimitiveMethod(meth: MethodSymbol) = meth.owner.isPrimitiveValueClass + private def isStringConcat(meth: MethodSymbol) = meth == String_+ || (isMagicPrimitiveMethod(meth) && meth.returnType =:= StringClass.toType) + lazy val magicMethodOwners = Set[Symbol](AnyClass, AnyValClass, AnyRefClass, ObjectClass, ArrayClass) ++ ScalaPrimitiveValueClasses + lazy val nonMagicObjectMethods = Set[Symbol](Object_clone, Object_equals, Object_finalize, Object_hashCode, Object_toString, + Object_notify, Object_notifyAll) ++ ObjectClass.info.member(nme.wait_).asTerm.alternatives.map(_.asMethod) + private def isMagicMethod(meth: MethodSymbol): Boolean = { + if (isGetClass(meth) || isStringConcat(meth) || isMagicPrimitiveMethod(meth) || meth == Predef_classOf || meth.isTermMacro) return true + magicMethodOwners(meth.owner) && !nonMagicObjectMethods(meth) + } + + // unlike other mirrors, method mirrors are created by a factory + // that's because we want to have decent performance + // therefore we move special cases into separate subclasses + // rather than have them on a hot path them in a unified implementation of the `apply` method + private def mkJavaMethodMirror[T: ClassTag](receiver: T, symbol: MethodSymbol): JavaMethodMirror = { + if (isMagicMethod(symbol)) new JavaMagicMethodMirror(receiver, symbol) + else if (symbol.params.flatten exists (p => isByNameParamType(p.info))) new JavaByNameMethodMirror(receiver, symbol) + else new JavaVanillaMethodMirror(receiver, symbol) } - private class JavaMethodMirror(val receiver: AnyRef, val symbol: MethodSymbol) + private abstract class JavaMethodMirror(val symbol: MethodSymbol) extends MethodMirror { lazy val jmeth = { val jmeth = methodToJava(symbol) if (!jmeth.isAccessible) jmeth.setAccessible(true) jmeth } - def apply(args: Any*): Any = - if (symbol.owner == ArrayClass) - symbol.name match { - case nme.length => jArray.getLength(receiver) - case nme.apply => jArray.get(receiver, args(0).asInstanceOf[Int]) - case nme.update => jArray.set(receiver, args(0).asInstanceOf[Int], args(1)) - case _ => assert(false, s"unexpected array method: $symbol") - } - else - jmeth.invoke(receiver, args.asInstanceOf[Seq[AnyRef]]: _*) + + def jinvoke(jmeth: jMethod, receiver: Any, args: Seq[Any]): Any = { + val result = jmeth.invoke(receiver, args.asInstanceOf[Seq[AnyRef]]: _*) + if (jmeth.getReturnType == java.lang.Void.TYPE) () + else result + } + + override def toString = s"method mirror for ${showMethodSig(symbol)} (bound to $receiver)" + } + + private class JavaVanillaMethodMirror(val receiver: Any, symbol: MethodSymbol) + extends JavaMethodMirror(symbol) { + def apply(args: Any*): Any = jinvoke(jmeth, receiver, args) + } + + private class JavaByNameMethodMirror(val receiver: Any, symbol: MethodSymbol) + extends JavaMethodMirror(symbol) { + def apply(args: Any*): Any = { + val transformed = map2(args.toList, symbol.params.flatten)((arg, param) => if (isByNameParamType(param.info)) () => arg else arg) + jinvoke(jmeth, receiver, transformed) + } + } + + private class JavaMagicMethodMirror[T: ClassTag](val receiver: T, symbol: MethodSymbol) + extends JavaMethodMirror(symbol) { + def apply(args: Any*): Any = { + // checking type conformance is too much of a hassle, so we don't do it here + // actually it's not even necessary, because we manually dispatch arguments to magic methods below + val params = symbol.paramss.flatten + val perfectMatch = args.length == params.length + // todo. this doesn't account for multiple vararg parameter lists + // however those aren't supported by the mirror API: https://issues.scala-lang.org/browse/SI-6182 + // hence I leave this code as is, to be fixed when the corresponding bug is fixed + val varargMatch = args.length >= params.length - 1 && isVarArgsList(params) + if (!perfectMatch && !varargMatch) { + val n_arguments = if (isVarArgsList(params)) s"${params.length - 1} or more" else s"${params.length}" + var s_arguments = if (params.length == 1 && !isVarArgsList(params)) "argument" else "arguments" + throw new ScalaReflectionException(s"${showMethodSig(symbol)} takes $n_arguments $s_arguments") + } + + def objReceiver = receiver.asInstanceOf[AnyRef] + def objArg0 = args(0).asInstanceOf[AnyRef] + def objArgs = args.asInstanceOf[Seq[AnyRef]] + def fail(msg: String) = throw new ScalaReflectionException(msg + ", it cannot be invoked with mirrors") + + def invokeMagicPrimitiveMethod = { + val jmeths = classOf[BoxesRunTime].getDeclaredMethods.filter(_.getName == nme.primitiveMethodName(symbol.name).toString) + assert(jmeths.length == 1, jmeths.toList) + jinvoke(jmeths.head, null, objReceiver +: objArgs) + } + + symbol match { + case Any_== | Object_== => ScalaRunTime.inlinedEquals(objReceiver, objArg0) + case Any_!= | Object_!= => !ScalaRunTime.inlinedEquals(objReceiver, objArg0) + case Any_## | Object_## => ScalaRunTime.hash(objReceiver) + case Any_equals => receiver.equals(objArg0) + case Any_hashCode => receiver.hashCode + case Any_toString => receiver.toString + case Object_eq => objReceiver eq objArg0 + case Object_ne => objReceiver ne objArg0 + case Object_synchronized => objReceiver.synchronized(objArg0) + case sym if isGetClass(sym) => preciseClass(receiver) + case Any_asInstanceOf => fail("Any.asInstanceOf requires a type argument") + case Any_isInstanceOf => fail("Any.isInstanceOf requires a type argument") + case Object_asInstanceOf => fail("AnyRef.$asInstanceOf is an internal method") + case Object_isInstanceOf => fail("AnyRef.$isInstanceOf is an internal method") + case Array_length => ScalaRunTime.array_length(objReceiver) + case Array_apply => ScalaRunTime.array_apply(objReceiver, args(0).asInstanceOf[Int]) + case Array_update => ScalaRunTime.array_update(objReceiver, args(0).asInstanceOf[Int], args(1)) + case Array_clone => ScalaRunTime.array_clone(objReceiver) + case sym if isStringConcat(sym) => receiver.toString + objArg0 + case sym if isMagicPrimitiveMethod(sym) => invokeMagicPrimitiveMethod + case sym if sym == Predef_classOf => fail("Predef.classOf is a compile-time function") + case sym if sym.isTermMacro => fail(s"${symbol.fullName} is a macro, i.e. a compile-time function") + case _ => assert(false, this) + } + } } private class JavaConstructorMirror(val outer: AnyRef, val symbol: MethodSymbol) @@ -231,14 +363,17 @@ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: Sym jconstr } def apply(args: Any*): Any = { + if (symbol.owner == ArrayClass) + throw new ScalaReflectionException("Cannot instantiate arrays with mirrors. Consider using `scala.reflect.ClassTag(<class of element>).newArray(<length>)` instead") + val effectiveArgs = if (outer == null) args.asInstanceOf[Seq[AnyRef]] else outer +: args.asInstanceOf[Seq[AnyRef]] jconstr.newInstance(effectiveArgs: _*) } + override def toString = s"constructor mirror for ${showMethodSig(symbol)} (bound to $outer)" } - private abstract class JavaTemplateMirror extends TemplateMirror { def outer: AnyRef @@ -251,16 +386,21 @@ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: Sym extends JavaTemplateMirror with ClassMirror { def erasure = symbol def isStatic = false - def reflectConstructor(constructor: MethodSymbol) = new JavaConstructorMirror(outer, constructor) + def reflectConstructor(constructor: MethodSymbol) = { + if (!constructor.isClassConstructor) ErrorNotConstructor(constructor, symbol) + if (!symbol.info.decls.toList.contains(constructor)) ErrorNotConstructor(constructor, symbol) + new JavaConstructorMirror(outer, constructor) + } def companion: Option[ModuleMirror] = symbol.companionModule match { case module: ModuleSymbol => Some(new JavaModuleMirror(outer, module)) case _ => None } + override def toString = s"class mirror for ${symbol.fullName} (bound to $outer)" } private class JavaModuleMirror(val outer: AnyRef, val symbol: ModuleSymbol) extends JavaTemplateMirror with ModuleMirror { - def erasure = symbol.moduleClass.asClassSymbol + def erasure = symbol.moduleClass.asClass def isStatic = true def instance = { if (!symbol.owner.isPackageClass) throw new Error("inner and nested modules are not supported yet") @@ -270,6 +410,7 @@ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: Sym case cls: ClassSymbol => Some(new JavaClassMirror(outer, cls)) case _ => None } + override def toString = s"module mirror for ${symbol.fullName} (bound to $outer)" } // -------------------- Java to Scala ----------------------------------- @@ -629,7 +770,7 @@ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: Sym val preOwner = classToScala(jOwner) val owner = followStatic(preOwner, jmeth.getModifiers) (lookup(owner, jmeth.getName) suchThat (erasesTo(_, jmeth)) orElse jmethodAsScala(jmeth)) - .asMethodSymbol + .asMethod } /** @@ -643,7 +784,7 @@ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: Sym private def constructorToScala1(jconstr: jConstructor[_]): MethodSymbol = { val owner = followStatic(classToScala(jconstr.getDeclaringClass), jconstr.getModifiers) (lookup(owner, jconstr.getName) suchThat (erasesTo(_, jconstr)) orElse jconstrAsScala(jconstr)) - .asMethodSymbol + .asMethod } /** @@ -657,8 +798,7 @@ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: Sym private def fieldToScala1(jfield: jField): TermSymbol = { val owner = followStatic(classToScala(jfield.getDeclaringClass), jfield.getModifiers) - (lookup(owner, jfield.getName) suchThat (!_.isMethod) orElse jfieldAsScala(jfield)) - .asTermSymbol + (lookup(owner, jfield.getName) suchThat (!_.isMethod) orElse jfieldAsScala(jfield)).asTerm } /** @@ -691,7 +831,7 @@ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: Sym val name = (fullname: TermName) drop split + 1 val opkg = owner.info decl name if (opkg.isPackage) - opkg.asModuleSymbol + opkg.asModule else if (opkg == NoSymbol) { val pkg = owner.newPackage(name) pkg.moduleClass setInfo new LazyPackageType @@ -748,7 +888,16 @@ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: Sym lookupClass else if (jclazz.isLocalClass0 || isInvalidClassName(jname)) // local classes and implementation classes not preserved by unpickling - treat as Java - jclassAsScala(jclazz) + // + // upd. but only if they cannot be loaded as top-level classes + // otherwise we may mistake mangled symbolic names for mangled nested names + // + // in case when a Java binary name can be treated both as a top-level class and as a nested class + // (as described in http://groups.google.com/group/scala-internals/browse_thread/thread/10855403bbf04298) + // we check for a top-level class first + // this is totally correct, because a top-level class and a nested class with the same name cannot coexist + // so it's either one or another, but not both - therefore we always load $-bearing classes correctly + lookupClass orElse jclassAsScala(jclazz) else if (jclazz.isArray) ArrayClass else @@ -758,7 +907,7 @@ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: Sym s"""${if (cls == NoSymbol) "not a type: symbol" else "no symbol could be"} | loaded from $jclazz in $owner with name $simpleName and classloader $classLoader""".stripMargin) - cls.asClassSymbol + cls.asClass } } @@ -773,7 +922,7 @@ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: Sym private def typeParamToScala1(jparam: jTypeVariable[_ <: GenericDeclaration]): TypeSymbol = { val owner = genericDeclarationToScala(jparam.getGenericDeclaration) owner.info match { - case PolyType(tparams, _) => tparams.find(_.name.toString == jparam.getName).get.asTypeSymbol + case PolyType(tparams, _) => tparams.find(_.name.toString == jparam.getName).get.asType } } @@ -941,7 +1090,7 @@ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: Sym else if (clazz.owner.isPackageClass) javaClass(clazz.javaClassName) else if (clazz.owner.isClass) - classToJava(clazz.owner.asClassSymbol) + classToJava(clazz.owner.asClass) .getDeclaredClasses .find(_.getSimpleName == clazz.name.toString) .getOrElse(noClass) @@ -957,7 +1106,7 @@ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: Sym * @param meth The Scala field. */ def fieldToJava(fld: TermSymbol): jField = fieldCache.toJava(fld) { - val jclazz = classToJava(fld.owner.asClassSymbol) + val jclazz = classToJava(fld.owner.asClass) val jname = nme.dropLocalSuffix(fld.name).toString try jclazz getDeclaredField jname catch { @@ -969,7 +1118,7 @@ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: Sym * @param meth The Scala method */ def methodToJava(meth: MethodSymbol): jMethod = methodCache.toJava(meth) { - val jclazz = classToJava(meth.owner.asClassSymbol) + val jclazz = classToJava(meth.owner.asClass) val paramClasses = transformedType(meth).paramTypes map typeToJavaClass val jname = nme.dropLocalSuffix(meth.name).toString try jclazz getDeclaredMethod (jname, paramClasses: _*) @@ -983,7 +1132,7 @@ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: Sym * @param constr The Scala constructor */ def constructorToJava(constr: MethodSymbol): jConstructor[_] = constructorCache.toJava(constr) { - val jclazz = classToJava(constr.owner.asClassSymbol) + val jclazz = classToJava(constr.owner.asClass) val paramClasses = transformedType(constr).paramTypes map typeToJavaClass val effectiveParamClasses = if (!constr.owner.owner.isStaticOwner) jclazz.getEnclosingClass +: paramClasses @@ -1001,7 +1150,7 @@ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: Sym def typeToJavaClass(tpe: Type): jClass[_] = tpe match { case ExistentialType(_, rtpe) => typeToJavaClass(rtpe) case TypeRef(_, ArrayClass, List(elemtpe)) => jArrayClass(typeToJavaClass(elemtpe)) - case TypeRef(_, sym: ClassSymbol, _) => classToJava(sym.asClassSymbol) + case TypeRef(_, sym: ClassSymbol, _) => classToJava(sym.asClass) case tpe @ TypeRef(_, sym: AliasTypeSymbol, _) => typeToJavaClass(tpe.dealias) case _ => throw new NoClassDefFoundError("no Java class corresponding to "+tpe+" found") } @@ -1029,7 +1178,7 @@ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: Sym mirrors(rootToLoader getOrElseUpdate(root, findLoader)).get.get } - private lazy val magicSymbols: Map[(String, Name), Symbol] = { + private lazy val magicClasses: Map[(String, Name), Symbol] = { def mapEntry(sym: Symbol): ((String, Name), Symbol) = (sym.owner.fullName, sym.name) -> sym Map() ++ (definitions.magicSymbols filter (_.isType) map mapEntry) } @@ -1050,7 +1199,7 @@ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: Sym if (name.isTermName && !owner.isEmptyPackageClass) return mirror.makeScalaPackage( if (owner.isRootSymbol) name.toString else owner.fullName+"."+name) - magicSymbols get (owner.fullName, name) match { + magicClasses get (owner.fullName, name) match { case Some(tsym) => owner.info.decls enter tsym return tsym diff --git a/src/reflect/scala/reflect/runtime/ReflectionUtils.scala b/src/reflect/scala/reflect/runtime/ReflectionUtils.scala index f696aceb93..2c7be6e317 100644 --- a/src/reflect/scala/reflect/runtime/ReflectionUtils.scala +++ b/src/reflect/scala/reflect/runtime/ReflectionUtils.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/reflect/scala/reflect/runtime/Settings.scala b/src/reflect/scala/reflect/runtime/Settings.scala index eedb88320b..da4f4fbda1 100644 --- a/src/reflect/scala/reflect/runtime/Settings.scala +++ b/src/reflect/scala/reflect/runtime/Settings.scala @@ -1,11 +1,13 @@ package scala.reflect package runtime +import scala.reflect.internal.settings.MutableSettings + /** The Settings class for runtime reflection. * This should be refined, so that settings are settable via command * line options or properties. */ -class Settings extends internal.settings.MutableSettings { +class Settings extends MutableSettings { trait Setting extends SettingValue { } @@ -21,20 +23,27 @@ class Settings extends internal.settings.MutableSettings { override def value: Int = v } - val overrideObjects = new BooleanSetting(false) - val debug = new BooleanSetting(false) - val Ynotnull = new BooleanSetting(false) - val explaintypes = new BooleanSetting(false) - val verbose = new BooleanSetting(false) - val uniqid = new BooleanSetting(false) - val Yshowsymkinds = new BooleanSetting(false) - val Xprintpos = new BooleanSetting(false) - val printtypes = new BooleanSetting(false) - val Yrecursion = new IntSetting(0) - val maxClassfileName = new IntSetting(255) - val Xexperimental = new BooleanSetting(false) - val deepCloning = new BooleanSetting (false) - val XoldPatmat = new BooleanSetting(false) + class MultiStringSetting(xs: List[String]) extends Setting { + type T = List[String] + protected var v: List[String] = xs + override def value: List[String] = v + } + + val Xexperimental = new BooleanSetting(false) + val XfullLubs = new BooleanSetting(false) val XnoPatmatAnalysis = new BooleanSetting(false) - val XfullLubs = new BooleanSetting(false) + val XoldPatmat = new BooleanSetting(false) + val Xprintpos = new BooleanSetting(false) + val Ynotnull = new BooleanSetting(false) + val Yshowsymkinds = new BooleanSetting(false) + val debug = new BooleanSetting(false) + val deepCloning = new BooleanSetting(false) + val explaintypes = new BooleanSetting(false) + val overrideObjects = new BooleanSetting(false) + val printtypes = new BooleanSetting(false) + val uniqid = new BooleanSetting(false) + val verbose = new BooleanSetting(false) + + val Yrecursion = new IntSetting(0) + val maxClassfileName = new IntSetting(255) } diff --git a/src/reflect/scala/reflect/runtime/SynchronizedSymbols.scala b/src/reflect/scala/reflect/runtime/SynchronizedSymbols.scala index 3b28ddf42c..c65357b652 100644 --- a/src/reflect/scala/reflect/runtime/SynchronizedSymbols.scala +++ b/src/reflect/scala/reflect/runtime/SynchronizedSymbols.scala @@ -110,6 +110,8 @@ trait SynchronizedSymbols extends internal.Symbols { self: SymbolTable => trait SynchronizedMethodSymbol extends MethodSymbol with SynchronizedTermSymbol { override def typeAsMemberOf(pre: Type): Type = synchronized { super.typeAsMemberOf(pre) } + override def params: List[List[Symbol]] = synchronized { super.params } + override def returnType: Type = synchronized { super.returnType } } trait SynchronizedTypeSymbol extends TypeSymbol with SynchronizedSymbol { @@ -134,7 +136,7 @@ trait SynchronizedSymbols extends internal.Symbols { self: SymbolTable => override def sourceModule = synchronized { super.sourceModule } // [Eugene++ to Martin] doesn't override anything. no longer necessary? // def sourceModule_=(module: ModuleSymbol) = synchronized { super.sourceModule_=(module) } - override def implicitMembers: List[Symbol] = synchronized { super.implicitMembers } + override def implicitMembers: Scope = synchronized { super.implicitMembers } } } diff --git a/src/reflect/scala/reflect/runtime/package.scala b/src/reflect/scala/reflect/runtime/package.scala index a5809a2629..d00094c0c1 100644 --- a/src/reflect/scala/reflect/runtime/package.scala +++ b/src/reflect/scala/reflect/runtime/package.scala @@ -1,7 +1,5 @@ package scala.reflect -import language.experimental.macros - package object runtime { // type is api.JavaUniverse because we only want to expose the `scala.reflect.api.*` subset of reflection @@ -9,18 +7,19 @@ package object runtime { // [Eugene++ to Martin] removed `mirrorOfLoader`, because one can use `universe.runtimeMirror` instead - def currentMirror: universe.Mirror = macro Macros.currentMirror + // implementation magically hardwired to the `currentMirror` method below + def currentMirror: universe.Mirror = ??? // macro } package runtime { object Macros { - def currentMirror(c: scala.reflect.makro.Context): c.Expr[universe.Mirror] = { + def currentMirror(c: scala.reflect.macros.Context): c.Expr[universe.Mirror] = { import c.universe._ val runtimeClass = c.reifyEnclosingRuntimeClass if (runtimeClass.isEmpty) c.abort(c.enclosingPosition, "call site does not have an enclosing class") val runtimeUniverse = Select(Select(Select(Ident(newTermName("scala")), newTermName("reflect")), newTermName("runtime")), newTermName("universe")) val currentMirror = Apply(Select(runtimeUniverse, newTermName("runtimeMirror")), List(Select(runtimeClass, newTermName("getClassLoader")))) - c.Expr[Nothing](currentMirror)(c.TypeTag.Nothing) + c.Expr[Nothing](currentMirror)(c.AbsTypeTag.Nothing) } } } diff --git a/src/reflect/scala/tools/nsc/io/AbstractFile.scala b/src/reflect/scala/tools/nsc/io/AbstractFile.scala index fd56608fab..8d55b708b1 100644 --- a/src/reflect/scala/tools/nsc/io/AbstractFile.scala +++ b/src/reflect/scala/tools/nsc/io/AbstractFile.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/reflect/scala/tools/nsc/io/NoAbstractFile.scala b/src/reflect/scala/tools/nsc/io/NoAbstractFile.scala index 04568b0e2e..2af933c27b 100644 --- a/src/reflect/scala/tools/nsc/io/NoAbstractFile.scala +++ b/src/reflect/scala/tools/nsc/io/NoAbstractFile.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/reflect/scala/tools/nsc/io/Path.scala b/src/reflect/scala/tools/nsc/io/Path.scala index 74bd6cf16b..bfad4b93c5 100644 --- a/src/reflect/scala/tools/nsc/io/Path.scala +++ b/src/reflect/scala/tools/nsc/io/Path.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/reflect/scala/tools/nsc/io/PlainFile.scala b/src/reflect/scala/tools/nsc/io/PlainFile.scala index 21276e8740..a4f378ad5e 100644 --- a/src/reflect/scala/tools/nsc/io/PlainFile.scala +++ b/src/reflect/scala/tools/nsc/io/PlainFile.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/reflect/scala/tools/nsc/io/Streamable.scala b/src/reflect/scala/tools/nsc/io/Streamable.scala index 4d872c0221..ff770bd396 100644 --- a/src/reflect/scala/tools/nsc/io/Streamable.scala +++ b/src/reflect/scala/tools/nsc/io/Streamable.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ diff --git a/src/reflect/scala/tools/nsc/io/VirtualDirectory.scala b/src/reflect/scala/tools/nsc/io/VirtualDirectory.scala index 7272921054..fa016f86f4 100644 --- a/src/reflect/scala/tools/nsc/io/VirtualDirectory.scala +++ b/src/reflect/scala/tools/nsc/io/VirtualDirectory.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL */ package scala.tools.nsc diff --git a/src/reflect/scala/tools/nsc/io/VirtualFile.scala b/src/reflect/scala/tools/nsc/io/VirtualFile.scala index 805bc04165..be888e92e6 100644 --- a/src/reflect/scala/tools/nsc/io/VirtualFile.scala +++ b/src/reflect/scala/tools/nsc/io/VirtualFile.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Martin Odersky */ diff --git a/src/reflect/scala/tools/nsc/io/ZipArchive.scala b/src/reflect/scala/tools/nsc/io/ZipArchive.scala index 766b1fd093..852dba9ec8 100644 --- a/src/reflect/scala/tools/nsc/io/ZipArchive.scala +++ b/src/reflect/scala/tools/nsc/io/ZipArchive.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL * @author Paul Phillips */ |