summaryrefslogtreecommitdiff
path: root/src/compiler/scala
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2012-08-15 13:37:26 +0200
committerEugene Burmako <xeno.by@gmail.com>2012-08-15 17:46:11 +0200
commit46d57d47e81c8794a9a3594e080576788cc92324 (patch)
treeb527c1dfb44d2753c8ae925580838d688e5fccd0 /src/compiler/scala
parentce90a46a6964e524933ffe193ac38d58d3df07be (diff)
downloadscala-46d57d47e81c8794a9a3594e080576788cc92324.tar.gz
scala-46d57d47e81c8794a9a3594e080576788cc92324.tar.bz2
scala-46d57d47e81c8794a9a3594e080576788cc92324.zip
cleanup of reflection- and macro-related stuff
mostly removes [Eugene] marks that I left back then and reviews related code some of those tokens got left in place, because I don't know to how fix them without imposing risks on 2.10.0
Diffstat (limited to 'src/compiler/scala')
-rw-r--r--src/compiler/scala/reflect/macros/runtime/Infrastructure.scala14
-rw-r--r--src/compiler/scala/reflect/macros/runtime/Settings.scala5
-rw-r--r--src/compiler/scala/reflect/macros/util/Traces.scala5
-rw-r--r--src/compiler/scala/reflect/reify/Reifier.scala8
-rw-r--r--src/compiler/scala/reflect/reify/codegen/GenSymbols.scala1
-rw-r--r--src/compiler/scala/reflect/reify/codegen/GenTypes.scala3
-rw-r--r--src/compiler/scala/reflect/reify/phases/Calculate.scala2
-rw-r--r--src/compiler/scala/reflect/reify/phases/Reshape.scala3
-rw-r--r--src/compiler/scala/reflect/reify/utils/NodePrinters.scala1
-rw-r--r--src/compiler/scala/tools/nsc/Global.scala14
-rw-r--r--src/compiler/scala/tools/nsc/ast/NodePrinters.scala3
-rw-r--r--src/compiler/scala/tools/nsc/ast/Positions.scala7
-rw-r--r--src/compiler/scala/tools/nsc/ast/Trees.scala5
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala5
-rw-r--r--src/compiler/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala2
-rw-r--r--src/compiler/scala/tools/nsc/interpreter/IMain.scala2
-rw-r--r--src/compiler/scala/tools/nsc/interpreter/TypeStrings.scala2
-rw-r--r--src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala12
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Implicits.scala7
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Macros.scala24
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala14
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala4
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala1
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala9
-rw-r--r--src/compiler/scala/tools/reflect/MacroImplementations.scala7
-rw-r--r--src/compiler/scala/tools/reflect/ToolBoxFactory.scala8
26 files changed, 47 insertions, 121 deletions
diff --git a/src/compiler/scala/reflect/macros/runtime/Infrastructure.scala b/src/compiler/scala/reflect/macros/runtime/Infrastructure.scala
index 19fb03364e..0a8a8d015d 100644
--- a/src/compiler/scala/reflect/macros/runtime/Infrastructure.scala
+++ b/src/compiler/scala/reflect/macros/runtime/Infrastructure.scala
@@ -18,19 +18,7 @@ trait Infrastructure {
val libraryClassPath: List[java.net.URL] = universe.classPath.asURLs
- lazy val libraryClassLoader: ClassLoader = {
- val classpath = libraryClassPath
- var loader: ClassLoader = ScalaClassLoader.fromURLs(classpath, self.getClass.getClassLoader)
-
- // [Eugene] a heuristic to detect REPL
- if (universe.settings.exposeEmptyPackage.value) {
- import scala.tools.nsc.interpreter._
- val virtualDirectory = universe.settings.outputDirs.getSingleOutput.get
- loader = new AbstractFileClassLoader(virtualDirectory, loader) {}
- }
-
- loader
- }
+ lazy val libraryClassLoader: ClassLoader = universe.analyzer.macroClassloader
type Run = universe.Run
diff --git a/src/compiler/scala/reflect/macros/runtime/Settings.scala b/src/compiler/scala/reflect/macros/runtime/Settings.scala
index 9c24273cd7..c602532ea4 100644
--- a/src/compiler/scala/reflect/macros/runtime/Settings.scala
+++ b/src/compiler/scala/reflect/macros/runtime/Settings.scala
@@ -13,18 +13,17 @@ trait Settings {
def compilerSettings: List[String] = universe.settings.recreateArgs
def setCompilerSettings(options: String): this.type =
- // todo. is not going to work with quoted arguments with embedded whitespaces
+ // SI-5925: doesn't work with arguments that contains whitespaces
setCompilerSettings(options.split(" ").toList)
def setCompilerSettings(options: List[String]): this.type = {
val settings = new tools.nsc.Settings(_ => ())
- // [Eugene] what settings should we exclude?
settings.copyInto(universe.settings)
this
}
def withCompilerSettings[T](options: String)(op: => T): T =
- // todo. is not going to work with quoted arguments with embedded whitespaces
+ // SI-5925: doesn't work with arguments that contains whitespaces
withCompilerSettings(options.split(" ").toList)(op)
def withCompilerSettings[T](options: List[String])(op: => T): T = {
diff --git a/src/compiler/scala/reflect/macros/util/Traces.scala b/src/compiler/scala/reflect/macros/util/Traces.scala
index 6c2f115994..078cd2b74f 100644
--- a/src/compiler/scala/reflect/macros/util/Traces.scala
+++ b/src/compiler/scala/reflect/macros/util/Traces.scala
@@ -4,11 +4,6 @@ package util
trait Traces {
def globalSettings: tools.nsc.Settings
- // [Eugene] lots of ways to log:
- // 1) trace(...)
- // 2) log(...)
- // 3) if (foo) { doStuff(); includingSomeLogs(); }
- // what is the conventional way of unifying this?
val macroDebugLite = globalSettings.YmacrodebugLite.value
val macroDebugVerbose = globalSettings.YmacrodebugVerbose.value
val macroTraceLite = scala.tools.nsc.util.trace when (macroDebugLite || macroDebugVerbose)
diff --git a/src/compiler/scala/reflect/reify/Reifier.scala b/src/compiler/scala/reflect/reify/Reifier.scala
index 53e01309cb..f602fe9b99 100644
--- a/src/compiler/scala/reflect/reify/Reifier.scala
+++ b/src/compiler/scala/reflect/reify/Reifier.scala
@@ -52,7 +52,6 @@ abstract class Reifier extends States
*/
lazy val reification: Tree = {
try {
- // [Eugene] conventional way of doing this?
if (universe exists (_.isErroneous)) CannotReifyErroneousPrefix(universe)
if (universe.tpe == null) CannotReifyUntypedPrefix(universe)
@@ -62,7 +61,6 @@ abstract class Reifier extends States
reifyTrace("reifee is located at: ")(tree.pos)
reifyTrace("universe = ")(universe)
reifyTrace("mirror = ")(mirror)
- // [Eugene] conventional way of doing this?
if (tree exists (_.isErroneous)) CannotReifyErroneousReifee(tree)
if (tree.tpe == null) CannotReifyUntypedReifee(tree)
val pipeline = mkReificationPipeline
@@ -108,11 +106,7 @@ abstract class Reifier extends States
//
// todo. this is a common problem with non-trivial macros in our current macro system
// needs to be solved some day
- //
- // list of non-hygienic transformations:
- // todo. to be updated
- // [Eugene++] yeah, ugly and extremely brittle, but we do need to do resetAttrs. will be fixed later
- // todo. maybe try `resetLocalAttrs` once the dust settles
+ // maybe try `resetLocalAttrs` once the dust settles
var importantSymbols = Set[Symbol](
NothingClass, AnyClass, SingletonClass, PredefModule, ScalaRunTimeModule, TypeCreatorClass, TreeCreatorClass, MirrorOfClass,
BaseUniverseClass, JavaUniverseClass, ReflectRuntimePackage, ReflectRuntimeCurrentMirror)
diff --git a/src/compiler/scala/reflect/reify/codegen/GenSymbols.scala b/src/compiler/scala/reflect/reify/codegen/GenSymbols.scala
index 7f066a2cc3..ca6e14cfd3 100644
--- a/src/compiler/scala/reflect/reify/codegen/GenSymbols.scala
+++ b/src/compiler/scala/reflect/reify/codegen/GenSymbols.scala
@@ -72,6 +72,7 @@ trait GenSymbols {
*/
val hasPackagelessParent = sym.ownerChain.tail.tail exists (_.isEmptyPackageClass)
if (sym.isStatic && (sym.isClass || sym.isModule) && !hasPackagelessParent) {
+ // SI-6238: if applicable, emit references to StandardDefinitions instead of staticClass/staticModule calls
val resolver = if (sym.isType) nme.staticClass else nme.staticModule
mirrorMirrorCall(resolver, reify(sym.fullName))
} else {
diff --git a/src/compiler/scala/reflect/reify/codegen/GenTypes.scala b/src/compiler/scala/reflect/reify/codegen/GenTypes.scala
index c762a28f99..1d2e177688 100644
--- a/src/compiler/scala/reflect/reify/codegen/GenTypes.scala
+++ b/src/compiler/scala/reflect/reify/codegen/GenTypes.scala
@@ -23,7 +23,7 @@ trait GenTypes {
if (isSemiConcreteTypeMember(tpe))
return reifySemiConcreteTypeMember(tpe)
- // [Eugene] how do I check that the substitution is legal w.r.t tpe.info?
+ // SI-6242: splicing might violate type bounds
val spliced = spliceType(tpe)
if (spliced != EmptyTree)
return spliced
@@ -69,7 +69,6 @@ trait GenTypes {
def reificationIsConcrete: Boolean = state.reificationIsConcrete
def spliceType(tpe: Type): Tree = {
- // [Eugene] it seems that depending on the context the very same symbol can be either a spliceable tparam or a quantified existential. very weird!
val quantified = currentQuantified
if (tpe.isSpliceable && !(quantified contains tpe.typeSymbol)) {
if (reifyDebug) println("splicing " + tpe)
diff --git a/src/compiler/scala/reflect/reify/phases/Calculate.scala b/src/compiler/scala/reflect/reify/phases/Calculate.scala
index 41cf6c066a..4d1e22abe7 100644
--- a/src/compiler/scala/reflect/reify/phases/Calculate.scala
+++ b/src/compiler/scala/reflect/reify/phases/Calculate.scala
@@ -9,7 +9,7 @@ trait Calculate {
implicit class RichCalculateSymbol(sym: Symbol) {
def metalevel: Int = { assert(sym != null && sym != NoSymbol); localSymbols.getOrElse(sym, 0) }
- def isLocalToReifee = (localSymbols contains sym) // [Eugene] how do I account for local skolems?
+ def isLocalToReifee = (localSymbols contains sym) // todo. how do I account for local skolems?
}
implicit class RichCalculateType(tpe: Type) {
diff --git a/src/compiler/scala/reflect/reify/phases/Reshape.scala b/src/compiler/scala/reflect/reify/phases/Reshape.scala
index e26dd7e227..fcf3c0e65c 100644
--- a/src/compiler/scala/reflect/reify/phases/Reshape.scala
+++ b/src/compiler/scala/reflect/reify/phases/Reshape.scala
@@ -248,7 +248,6 @@ trait Reshape {
New(TypeTree(ann.atp) setOriginal extractOriginal(ann.original), List(args))
}
- // [Eugene] is this implemented correctly?
private def trimAccessors(deff: Tree, stats: List[Tree]): List[Tree] = {
val symdefs = (stats collect { case vodef: ValOrDefDef => vodef } map (vodeff => vodeff.symbol -> vodeff)).toMap
val accessors = collection.mutable.Map[ValDef, List[DefDef]]()
@@ -287,7 +286,7 @@ trait Reshape {
val name1 = nme.dropLocalSuffix(name)
val vdef1 = ValDef(mods2, name1, tpt, rhs)
if (reifyDebug) println("resetting visibility of field: %s => %s".format(vdef, vdef1))
- Some(vdef1) // no copyAttrs here, because new ValDef and old symbols are not out of sync
+ Some(vdef1) // no copyAttrs here, because new ValDef and old symbols are now out of sync
case ddef @ DefDef(mods, name, tparams, vparamss, tpt, rhs) =>
if (accessors.values.exists(_.contains(ddef))) {
if (reifyDebug) println("discarding accessor method: " + ddef)
diff --git a/src/compiler/scala/reflect/reify/utils/NodePrinters.scala b/src/compiler/scala/reflect/reify/utils/NodePrinters.scala
index 420f55c0e0..ec1f132c1b 100644
--- a/src/compiler/scala/reflect/reify/utils/NodePrinters.scala
+++ b/src/compiler/scala/reflect/reify/utils/NodePrinters.scala
@@ -23,6 +23,7 @@ trait NodePrinters {
// depended upon. Of more fragile code I cannot conceive.
// @Eugene: This stuff is only needed to debug-print out reifications in human-readable format
// Rolling a full-fledged, robust TreePrinter would be several times more code.
+ // Also as of late we have tests that ensure that UX won't be broken by random changes to the reifier.
val lines = (tree.toString.split(EOL) drop 1 dropRight 1).toList splitAt 2
var (List(universe, mirror), reification) = lines
reification = (for (line <- reification) yield {
diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala
index c60a3c941f..574129a2f1 100644
--- a/src/compiler/scala/tools/nsc/Global.scala
+++ b/src/compiler/scala/tools/nsc/Global.scala
@@ -43,8 +43,6 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
with DocComments
with Positions { self =>
- // [Eugene++] would love to find better homes for the new things dumped into Global
-
// the mirror --------------------------------------------------
override def isCompilerUniverse = true
@@ -62,16 +60,14 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
}
def RootClass: ClassSymbol = rootMirror.RootClass
def EmptyPackageClass: ClassSymbol = rootMirror.EmptyPackageClass
- // [Eugene++] this little inconvenience gives us precise types for Expr.mirror and TypeTag.mirror
- // by the way, is it possible to define variant type members?
-
- override def settings = currentSettings
import definitions.findNamedMember
def findMemberFromRoot(fullName: Name): Symbol = rootMirror.findMemberFromRoot(fullName)
// alternate constructors ------------------------------------------
+ override def settings = currentSettings
+
def this(reporter: Reporter) =
this(new Settings(err => reporter.error(null, err)), reporter)
@@ -873,8 +869,6 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
/** Is given package class a system package class that cannot be invalidated?
*/
private def isSystemPackageClass(pkg: Symbol) =
- // [Eugene++ to Martin] please, verify
-// was: pkg == definitions.RootClass ||
pkg == RootClass ||
pkg == definitions.ScalaPackageClass || {
val pkgname = pkg.fullName
@@ -937,8 +931,6 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
else new MergedClassPath(elems, classPath.context)
val oldEntries = mkClassPath(subst.keys)
val newEntries = mkClassPath(subst.values)
- // [Eugene++ to Martin] please, verify
-// was: reSync(definitions.RootClass, Some(classPath), Some(oldEntries), Some(newEntries), invalidated, failed)
reSync(RootClass, Some(classPath), Some(oldEntries), Some(newEntries), invalidated, failed)
}
}
@@ -998,8 +990,6 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
invalidateOrRemove(root)
} else {
if (classesFound) {
- // [Eugene++ to Martin] please, verify
-// was: if (root.isRoot) invalidateOrRemove(definitions.EmptyPackageClass)
if (root.isRoot) invalidateOrRemove(EmptyPackageClass)
else failed += root
}
diff --git a/src/compiler/scala/tools/nsc/ast/NodePrinters.scala b/src/compiler/scala/tools/nsc/ast/NodePrinters.scala
index 1fdf4c631e..0b54eda66d 100644
--- a/src/compiler/scala/tools/nsc/ast/NodePrinters.scala
+++ b/src/compiler/scala/tools/nsc/ast/NodePrinters.scala
@@ -145,8 +145,7 @@ abstract class NodePrinters {
str.toString
}
def printModifiers(tree: MemberDef) {
- // [Eugene++] there's most likely a bug here (?)
- // see `Printers.printAnnotations` for more information
+ // SI-5885: by default this won't print annotations of not yet initialized symbols
val annots0 = tree.symbol.annotations match {
case Nil => tree.mods.annotations
case xs => xs map annotationInfoToString
diff --git a/src/compiler/scala/tools/nsc/ast/Positions.scala b/src/compiler/scala/tools/nsc/ast/Positions.scala
index 74d1f8ab4b..d8fb632f73 100644
--- a/src/compiler/scala/tools/nsc/ast/Positions.scala
+++ b/src/compiler/scala/tools/nsc/ast/Positions.scala
@@ -11,13 +11,6 @@ trait Positions extends scala.reflect.internal.Positions {
def validatePositions(tree: Tree) {}
- // [Eugene] disabling this for now. imo it doesn't justify pollution of the public API
- // override def _checkSetAnnotation(tree: Tree, annot: TreeAnnotation): Unit = {
- // if (tree.pos != NoPosition && tree.pos != annot.pos) debugwarn("Overwriting annotation "+ tree.annotation +" of tree "+ tree +" with annotation "+ annot)
- // // if ((tree.annotation.isInstanceOf[scala.reflect.internal.util.Position] || !annot.isInstanceOf[scala.reflect.internal.util.Position]) && tree.isInstanceOf[Block])
- // // println("Updating block from "+ tree.annotation +" to "+ annot)
- // }
-
class ValidatingPosAssigner extends PosAssigner {
var pos: Position = _
override def traverse(t: Tree) {
diff --git a/src/compiler/scala/tools/nsc/ast/Trees.scala b/src/compiler/scala/tools/nsc/ast/Trees.scala
index 381b834a0c..6f17a7d625 100644
--- a/src/compiler/scala/tools/nsc/ast/Trees.scala
+++ b/src/compiler/scala/tools/nsc/ast/Trees.scala
@@ -117,10 +117,7 @@ trait Trees extends reflect.internal.Trees { self: Global =>
if (vparamss1.isEmpty || !vparamss1.head.isEmpty && vparamss1.head.head.mods.isImplicit)
vparamss1 = List() :: vparamss1;
val superRef: Tree = atPos(superPos)(gen.mkSuperSelect)
- def mkApply(fun: Tree, args: List[Tree]) = Apply(fun, args)
- val superCall = (superRef /: argss) (mkApply)
- // [Eugene++] no longer compiles after I moved the `Apply` case class into scala.reflect.internal
- // val superCall = (superRef /: argss) (Apply)
+ val superCall = (superRef /: argss) (Apply.apply)
List(
atPos(wrappingPos(superPos, lvdefs ::: argss.flatten)) (
DefDef(constrMods, nme.CONSTRUCTOR, List(), vparamss1, TypeTree(), Block(lvdefs ::: List(superCall), Literal(Constant())))))
diff --git a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala
index ab856f09b8..898045e410 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala
@@ -546,10 +546,7 @@ abstract class TreeBuilder {
rhs1,
List(
atPos(pat1.pos) {
- def mkIdent(name: Name) = Ident(name)
- CaseDef(pat1, EmptyTree, makeTupleTerm(vars map (_._1) map mkIdent, true))
- // [Eugene++] no longer compiles after I moved the `Ident` case class into scala.reflect.internal
- // CaseDef(pat1, EmptyTree, makeTupleTerm(vars map (_._1) map Ident, true))
+ CaseDef(pat1, EmptyTree, makeTupleTerm(vars map (_._1) map Ident.apply, true))
}
))
}
diff --git a/src/compiler/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala b/src/compiler/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala
index 327436ed20..89195020c4 100644
--- a/src/compiler/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala
+++ b/src/compiler/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala
@@ -176,7 +176,7 @@ trait ModelFactoryImplicitSupport {
val appliedTree = new ApplyImplicitView(viewTree, List(Ident("<argument>") setType viewTree.tpe.paramTypes.head))
val appliedTreeTyped: Tree = {
val newContext = context.makeImplicit(context.ambiguousErrors)
- newContext.macrosEnabled = false // [Eugene] I assume you want macro signature, not macro expansion
+ newContext.macrosEnabled = false
val newTyper = global.analyzer.newTyper(newContext)
newTyper.silent(_.typed(appliedTree, global.analyzer.EXPRmode, WildcardType), false) match {
diff --git a/src/compiler/scala/tools/nsc/interpreter/IMain.scala b/src/compiler/scala/tools/nsc/interpreter/IMain.scala
index 6eadc1e63b..96d7dadbd7 100644
--- a/src/compiler/scala/tools/nsc/interpreter/IMain.scala
+++ b/src/compiler/scala/tools/nsc/interpreter/IMain.scala
@@ -145,7 +145,7 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends
private def _initSources = List(new BatchSourceFile("<init>", "class $repl_$init { }"))
private def _initialize() = {
try {
- // [Eugene] todo. if this crashes, REPL will hang
+ // todo. if this crashes, REPL will hang
new _compiler.Run() compileSources _initSources
_initializeComplete = true
true
diff --git a/src/compiler/scala/tools/nsc/interpreter/TypeStrings.scala b/src/compiler/scala/tools/nsc/interpreter/TypeStrings.scala
index d6604499b4..9dcc4006a3 100644
--- a/src/compiler/scala/tools/nsc/interpreter/TypeStrings.scala
+++ b/src/compiler/scala/tools/nsc/interpreter/TypeStrings.scala
@@ -213,7 +213,7 @@ trait TypeStrings {
private def tparamString[T: ru.TypeTag] : String = {
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
+ // [Eugene to Paul] 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))
brackets(typeArguments map (jc => tvarString(List(jc))): _*)
diff --git a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
index db97308f41..282c7251e3 100644
--- a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
+++ b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
@@ -436,7 +436,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
val sClassMap = anyrefSpecCache.getOrElseUpdate(sClass, mutable.Map[Symbol, Symbol]())
sClassMap.getOrElseUpdate(tparam,
- tparam.cloneSymbol(sClass, tparam.flags, (tparam.name append tpnme.SPECIALIZED_SUFFIX).asInstanceOf[Name]) // [Eugene++] why do we need this cast?
+ tparam.cloneSymbol(sClass, tparam.flags, (tparam.name append tpnme.SPECIALIZED_SUFFIX).asInstanceOf[Name]) // [Eugene] why do we need this cast?
modifyInfo (info => TypeBounds(info.bounds.lo, AnyRefClass.tpe))
).tpe
}
@@ -1772,10 +1772,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
private def forwardCall(pos: scala.reflect.internal.util.Position, receiver: Tree, paramss: List[List[ValDef]]): Tree = {
val argss = mmap(paramss)(x => Ident(x.symbol))
- def mkApply(fun: Tree, args: List[Tree]) = Apply(fun, args)
- atPos(pos) { (receiver /: argss) (mkApply) }
- // [Eugene++] no longer compiles after I moved the `Apply` case class into scala.reflect.internal
- // atPos(pos) { (receiver /: argss) (Apply) }
+ atPos(pos) { (receiver /: argss) (Apply.apply) }
}
/** Forward to the generic class constructor. If the current class initializes
@@ -1817,10 +1814,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
else
Ident(x.symbol)
)
- def mkApply(fun: Tree, args: List[Tree]) = Apply(fun, args)
- atPos(pos) { (receiver /: argss) (mkApply) }
- // [Eugene++] no longer compiles after I moved the `Apply` case class into scala.reflect.internal
- // atPos(pos) { (receiver /: argss) (Apply) }
+ atPos(pos) { (receiver /: argss) (Apply.apply) }
}
/** Add method m to the set of symbols for which we need an implementation tree
diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
index f9035f26b9..924d590edb 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
@@ -1185,10 +1185,6 @@ trait Implicits {
// ClassTags are not path-dependent, so their materializer doesn't care about prefixes
if (tagClass eq ClassTagClass) gen.mkBasisUniverseRef
else pre match {
- // [Eugene to Martin] this is the crux of the interaction between
- // implicits and reifiers here we need to turn a (supposedly
- // path-dependent) type into a tree that will be used as a prefix I'm
- // not sure if I've done this right - please, review
case SingleType(prePre, preSym) =>
gen.mkAttributedRef(prePre, preSym) setType pre
// necessary only to compile typetags used inside the Universe cake
@@ -1373,7 +1369,8 @@ trait Implicits {
/** The result of the implicit search:
* First search implicits visible in current context.
* If that fails, search implicits in expected type `pt`.
- * // [Eugene] the following lines should be deleted after we migrate delegate tag materialization to implicit macros
+ *
+ * todo. the following lines should be deleted after we migrate delegate tag materialization to implicit macros
* If that fails, and `pt` is an instance of a ClassTag, try to construct a class tag.
* If that fails, and `pt` is an instance of a TypeTag, try to construct a type tag.
* If that fails, and `pt` is an instance of a ClassManifest, try to construct a class manifest.
diff --git a/src/compiler/scala/tools/nsc/typechecker/Macros.scala b/src/compiler/scala/tools/nsc/typechecker/Macros.scala
index c8bf70e9e0..c2ab5edbb6 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Macros.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Macros.scala
@@ -132,9 +132,7 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces {
// there are some more clever cases when seemingly non-static method ends up being statically accessible
// however, the code below doesn't account for these guys, because it'd take a look of time to get it right
// for now I leave it as a todo and move along to more the important stuff
- // [Eugene] relies on the fact that macro implementations can only be defined in static classes
- // [Martin to Eugene++] There's similar logic buried in Symbol#flatname. Maybe we can refactor?
- // [Eugene] we will refactor once I get my hands on https://issues.scala-lang.org/browse/SI-5498
+ // todo. refactor when fixing SI-5498
def className: String = {
def loop(sym: Symbol): String = sym match {
case sym if sym.owner.isPackageClass =>
@@ -445,7 +443,7 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces {
// because it's adapt which is responsible for automatic expansion during typechecking
def typecheckRhs(rhs: Tree): Tree = {
try {
- val prevNumErrors = reporter.ERROR.count // [Eugene] funnily enough, the isErroneous check is not enough
+ val prevNumErrors = reporter.ERROR.count
var rhs1 = if (hasError) EmptyTree else typer.typed1(rhs, EXPRmode, WildcardType)
def typecheckedWithErrors = (rhs1 exists (_.isErroneous)) || reporter.ERROR.count != prevNumErrors
def rhsNeedsMacroExpansion = rhs1.symbol != null && rhs1.symbol.isTermMacro && !rhs1.symbol.isErroneous
@@ -681,8 +679,7 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces {
// transform type parameters of a macro implementation into type parameters of a macro definition
runtimeType = runtimeType map {
case TypeRef(pre, sym, args) =>
- // [Eugene] not sure which of these deSkolemizes are necessary
- // sym.paramPos is unreliable (see another case below)
+ // sym.paramPos is unreliable (see an example in `macroArgs`)
val tparams = macroImpl.typeParams map (_.deSkolemize)
val paramPos = tparams indexOf sym.deSkolemize
val sym1 =
@@ -745,7 +742,7 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces {
* Loads classes from from -cp (aka the library classpath).
* Is also capable of detecting REPL and reusing its classloader.
*/
- private lazy val macroClassloader: ClassLoader = {
+ lazy val macroClassloader: ClassLoader = {
if (global.forMSIL)
throw new UnsupportedOperationException("Scala reflection not available on this platform")
@@ -753,7 +750,7 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces {
macroLogVerbose("macro classloader: initializing from -cp: %s".format(classpath))
val loader = ScalaClassLoader.fromURLs(classpath, self.getClass.getClassLoader)
- // [Eugene] a heuristic to detect the REPL
+ // 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._
@@ -787,9 +784,11 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces {
val methName = binding.methName
macroLogVerbose(s"resolved implementation as $className.$methName")
- // [Eugene++] I don't use Scala reflection here, because it seems to interfere with JIT magic
+ // I don't use Scala reflection here, because it seems to interfere with JIT magic
// whenever you instantiate a mirror (and not do anything with in, just instantiate), performance drops by 15-20%
// I'm not sure what's the reason - for me it's pure voodoo
+ // upd. my latest experiments show that everything's okay
+ // it seems that in 2.10.1 we can easily switch to Scala reflection
try {
macroTraceVerbose("loading implementation class: ")(className)
macroTraceVerbose("classloader is: ")(ReflectionUtils.show(macroClassloader))
@@ -889,7 +888,7 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces {
val targ = binding.targs(paramPos).tpe.typeSymbol
val tpe = if (targ.isTypeParameterOrSkolem) {
if (targ.owner == macroDef) {
- // [Eugene] doesn't work when macro def is compiled separately from its usages
+ // doesn't work when macro def is compiled separately from its usages
// then targ is not a skolem and isn't equal to any of macroDef.typeParams
// val argPos = targ.deSkolemize.paramPos
val argPos = macroDef.typeParams.indexWhere(_.name == targ.name)
@@ -970,7 +969,6 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces {
// so I added this dummy local for the ease of debugging
var expectedTpe = expandee.tpe
- // [Eugene] weird situation. what's the conventional way to deal with it?
val isNullaryInvocation = expandee match {
case TypeApply(Select(_, _), _) => true
case TypeApply(Ident(_), _) => true
@@ -1117,8 +1115,9 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces {
macroLogLite("typechecking macro expansion %s at %s".format(expandee, expandee.pos))
macroArgs(typer, expandee).fold(failExpansion(): MacroExpansionResult) {
args => (args: @unchecked) match {
- // [Eugene++] crashes virtpatmat:
+ // crashes virtpatmat:
// case args @ ((context: MacroContext) :: _) =>
+ // todo. extract a minimized test case
case args @ (context0 :: _) =>
val context = context0.asInstanceOf[MacroContext]
if (nowDelayed) {
@@ -1197,7 +1196,6 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces {
}
private def handleMacroExpansionException(typer: Typer, expandee: Tree, ex: Throwable): MacroExpansionResult = {
- // [Eugene] any ideas about how to improve this one?
val realex = ReflectionUtils.unwrapThrowable(ex)
realex match {
case realex: reflect.macros.runtime.AbortMacroException =>
diff --git a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala
index dd180e6b76..f7ba189e0f 100644
--- a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala
@@ -31,7 +31,6 @@ trait MethodSynthesis {
else DefDef(sym, body)
def applyTypeInternal(tags: List[TT[_]]): Type = {
- // [Eugene++ to Paul] needs review!!
val symbols = tags map compilerSymbolFromTag
val container :: args = symbols
val tparams = container.typeConstructor.typeParams
@@ -53,21 +52,14 @@ trait MethodSynthesis {
applyTypeInternal(List(t1))
def applyType[CC[X1], X1](implicit t1: TT[CC[_]], t2: TT[X1]): Type =
- applyTypeInternal(List[TT[_]](t1, t2))
+ applyTypeInternal(List(t1, t2))
def applyType[CC[X1, X2], X1, X2](implicit t1: TT[CC[_,_]], t2: TT[X1], t3: TT[X2]): Type =
- // [Eugene++] without an explicit type annotation for List, we get this:
- // [scalacfork] C:\Projects\KeplerUnderRefactoring\src\compiler\scala\tools\nsc\typechecker\MethodSynthesis.scala:59: error: no type parameters for method apply: (xs: A*)List[A] in object List exist so that it can be applied to arguments (scala.tools.nsc.typechecker.MethodSynthesis.synthesisUtil.TT[CC[_, _]], scala.tools.nsc.typechecker.MethodSynthesis.synthesisUtil.TT[X1], scala.tools.nsc.typechecker.MethodSynthesis.synthesisUtil.TT[X2])
- // [scalacfork] --- because ---
- // [scalacfork] undetermined type
- // [scalacfork] applyTypeInternal(List(t1, t2, t3))
- applyTypeInternal(List[TT[_]](t1, t2, t3))
+ applyTypeInternal(List(t1, t2, t3))
def applyType[CC[X1, X2, X3], X1, X2, X3](implicit t1: TT[CC[_,_,_]], t2: TT[X1], t3: TT[X2], t4: TT[X3]): Type =
- applyTypeInternal(List[TT[_]](t1, t2, t3, t4))
+ applyTypeInternal(List(t1, t2, t3, t4))
- // [Martin->Eugene] !!! reinstantiate when typeables are in.
- // [Eugene++->Martin] now this compiles, will soon check it out
def newMethodType[F](owner: Symbol)(implicit t: TT[F]): Type = {
val fnSymbol = compilerSymbolFromTag(t)
val formals = compilerTypeFromTag(t).typeArguments
diff --git a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala
index c7c9d2f4aa..d227f485c2 100644
--- a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala
@@ -63,7 +63,7 @@ trait SyntheticMethods extends ast.TreeDSL {
// in the original order.
def accessors = clazz.caseFieldAccessors sortBy { acc =>
originalAccessors indexWhere { orig =>
- (acc.name == orig.name) || (acc.name startsWith (orig.name append "$").asInstanceOf[Name]) // [Eugene++] why do we need this cast?
+ (acc.name == orig.name) || (acc.name startsWith (orig.name append "$").asInstanceOf[Name]) // [Eugene] why do we need this cast?
}
}
val arity = accessors.size
@@ -87,7 +87,7 @@ trait SyntheticMethods extends ast.TreeDSL {
)
def forwardToRuntime(method: Symbol): Tree =
- forwardMethod(method, getMember(ScalaRunTimeModule, (method.name prepend "_").asInstanceOf[Name]))(mkThis :: _) // [Eugene++] why do we need this cast?
+ forwardMethod(method, getMember(ScalaRunTimeModule, (method.name prepend "_").asInstanceOf[Name]))(mkThis :: _) // [Eugene] why do we need this cast?
def callStaticsMethod(name: String)(args: Tree*): Tree = {
val method = termMember(RuntimeStaticsModule, name)
diff --git a/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala b/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala
index 4a0977eb90..f0dca64a00 100644
--- a/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala
@@ -462,7 +462,6 @@ trait TypeDiagnostics {
case CyclicReference(sym, info: TypeCompleter) =>
if (context0.owner.isTermMacro) {
// see comments to TypeSigError for an explanation of this special case
- // [Eugene] is there a better way?
throw ex
} else {
val pos = info.tree match {
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index a6d7fcda75..7c509f4d33 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -51,7 +51,6 @@ trait Typers extends Modes with Adaptations with Tags {
transformed.clear()
}
- // [Eugene] shouldn't this be converted to resetAllAttrs?
object UnTyper extends Traverser {
override def traverse(tree: Tree) = {
if (tree != EmptyTree) tree.tpe = null
@@ -909,7 +908,7 @@ trait Typers extends Modes with Adaptations with Tags {
def adaptType(): Tree = {
if (inFunMode(mode)) {
- // [Eugene++] the commented line below makes sense for typechecking, say, TypeApply(Ident(`some abstract type symbol`), List(...))
+ // todo. the commented line below makes sense for typechecking, say, TypeApply(Ident(`some abstract type symbol`), List(...))
// because otherwise Ident will have its tpe set to a TypeRef, not to a PolyType, and `typedTypeApply` will fail
// but this needs additional investigation, because it crashes t5228, gadts1 and maybe something else
// tree setType tree.tpe.normalize
@@ -2609,7 +2608,7 @@ trait Typers extends Modes with Adaptations with Tags {
val stats1 = typedStats(stats, NoSymbol)
// this code kicks in only after typer, so `stats` will never be filled in time
// as a result, most of compound type trees with non-empty stats will fail to reify
- // [Eugene++] todo. investigate whether something can be done about this
+ // todo. investigate whether something can be done about this
val att = templ.attachments.get[CompoundTypeTreeOriginalAttachment].getOrElse(CompoundTypeTreeOriginalAttachment(Nil, Nil))
templ.removeAttachment[CompoundTypeTreeOriginalAttachment]
templ addAttachment att.copy(stats = stats1)
@@ -3416,7 +3415,7 @@ trait Typers extends Modes with Adaptations with Tags {
}
if (hasError) annotationError
- else AnnotationInfo(annType, List(), nvPairs map {p => (p._1.asInstanceOf[Name], p._2.get)}).setOriginal(Apply(typedFun, args).setPos(ann.pos)) // [Eugene+] why do we need this cast?
+ else AnnotationInfo(annType, List(), nvPairs map {p => (p._1.asInstanceOf[Name], p._2.get)}).setOriginal(Apply(typedFun, args).setPos(ann.pos)) // [Eugene] why do we need this cast?
}
} else if (requireJava) {
reportAnnotationError(NestedAnnotationError(ann, annType))
@@ -5105,7 +5104,7 @@ trait Typers extends Modes with Adaptations with Tags {
erasure.GenericArray.unapply(tpt.tpe).isDefined) => // !!! todo simplify by using extractor
// convert new Array[T](len) to evidence[ClassTag[T]].newArray(len)
// 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)
+ // 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.toTypeConstructor, List(tpe))).last
val newArrayApp = atPos(tree.pos) {
diff --git a/src/compiler/scala/tools/reflect/MacroImplementations.scala b/src/compiler/scala/tools/reflect/MacroImplementations.scala
index 40ceefcc70..48a4811744 100644
--- a/src/compiler/scala/tools/reflect/MacroImplementations.scala
+++ b/src/compiler/scala/tools/reflect/MacroImplementations.scala
@@ -6,11 +6,12 @@ import scala.collection.mutable.ListBuffer
import scala.collection.mutable.Stack
abstract class MacroImplementations {
- val c: Context
+ val c: Context
- import c.universe.{Position => SPosition, _}
+ import c.universe._
+ import definitions._
- def macro_StringInterpolation_f(parts: List[Tree], args: List[Tree], origApplyPos: SPosition): Tree = {
+ def macro_StringInterpolation_f(parts: List[Tree], args: List[Tree], origApplyPos: c.universe.Position): Tree = {
// the parts all have the same position information (as the expression is generated by the compiler)
// the args have correct position information
diff --git a/src/compiler/scala/tools/reflect/ToolBoxFactory.scala b/src/compiler/scala/tools/reflect/ToolBoxFactory.scala
index eeec973299..8cc5a4e531 100644
--- a/src/compiler/scala/tools/reflect/ToolBoxFactory.scala
+++ b/src/compiler/scala/tools/reflect/ToolBoxFactory.scala
@@ -16,9 +16,6 @@ import scala.reflect.NameTransformer
import scala.reflect.api.JavaUniverse
import scala.reflect.base.MirrorOf
-// [Eugene++ to Martin] by the way, toolboxes are unable to compile anything that involves packages
-// is this intentional?
-
abstract class ToolBoxFactory[U <: JavaUniverse](val u: U) { factorySelf =>
val mirror: u.Mirror
@@ -187,10 +184,7 @@ abstract class ToolBoxFactory[U <: JavaUniverse](val u: U) { factorySelf =>
val meth = obj.moduleClass.newMethod(newTermName(wrapperMethodName))
def makeParam(schema: (FreeTermSymbol, TermName)) = {
val (fv, name) = schema
- // [Eugene] conventional way of doing this?
- val underlying = fv.tpe.resultType
- val tpe = appliedType(definitions.FunctionClass(0).tpe, List(underlying))
- meth.newValueParameter(name) setInfo tpe
+ meth.newValueParameter(name) setInfo appliedType(definitions.FunctionClass(0).tpe, List(fv.tpe.resultType))
}
meth setInfo MethodType(freeTerms.map(makeParam).toList, AnyClass.tpe)
minfo.decls enter meth