diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2012-08-15 13:37:26 +0200 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2012-08-15 17:46:11 +0200 |
commit | 46d57d47e81c8794a9a3594e080576788cc92324 (patch) | |
tree | b527c1dfb44d2753c8ae925580838d688e5fccd0 /src/reflect | |
parent | ce90a46a6964e524933ffe193ac38d58d3df07be (diff) | |
download | scala-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/reflect')
24 files changed, 61 insertions, 190 deletions
diff --git a/src/reflect/scala/reflect/api/FrontEnds.scala b/src/reflect/scala/reflect/api/FrontEnds.scala index a201b83444..a27450d49d 100644 --- a/src/reflect/scala/reflect/api/FrontEnds.scala +++ b/src/reflect/scala/reflect/api/FrontEnds.scala @@ -1,8 +1,6 @@ package scala.reflect package api -// [Martin to Eugene] Todo: Needs to be evicted from API -// [Eugene++ to Martin] but how? we need them for macros trait FrontEnds { type Position >: Null diff --git a/src/reflect/scala/reflect/api/Importers.scala b/src/reflect/scala/reflect/api/Importers.scala index de540a9605..fbc29a514e 100644 --- a/src/reflect/scala/reflect/api/Importers.scala +++ b/src/reflect/scala/reflect/api/Importers.scala @@ -1,8 +1,6 @@ package scala.reflect package api -// [Martin] Importers need to be made mirror aware. -// [Eugene++] this is important trait Importers { self: Universe => def mkImporter(from0: Universe): Importer { val from: from0.type } diff --git a/src/reflect/scala/reflect/api/JavaUniverse.scala b/src/reflect/scala/reflect/api/JavaUniverse.scala index 8bf62a357c..f2388433c4 100644 --- a/src/reflect/scala/reflect/api/JavaUniverse.scala +++ b/src/reflect/scala/reflect/api/JavaUniverse.scala @@ -1,8 +1,6 @@ package scala.reflect package api -// [Martin] Moved to compiler because it needs to see runtime.Universe -// The two will be united in scala-reflect anyway. trait JavaUniverse extends Universe with Mirrors with TagInterop { self => type RuntimeClass = java.lang.Class[_] diff --git a/src/reflect/scala/reflect/api/Mirrors.scala b/src/reflect/scala/reflect/api/Mirrors.scala index f2f96645e3..2530b20644 100644 --- a/src/reflect/scala/reflect/api/Mirrors.scala +++ b/src/reflect/scala/reflect/api/Mirrors.scala @@ -5,19 +5,7 @@ trait Mirrors { self: Universe => type RuntimeClass >: Null - // [Eugene] also, it might make sense to provide shortcuts for the API - // - // for example, right now to invoke the same method for several different instances, you need: - // 1) get the method symbol - // 2) get the instance mirror for every instance - // 3) call reflectMethod on the instance mirrors for every instance - // 4) call apply for every instance (okay, this can be united with step #3, but still) - // - // I have several suggestions that we can discuss later: - // 1) For every `reflectXXX(sym: Symbol): XXXMirror`, add `reflectXXX(name: String, types: Type*): XXXMirror` and `reflectXXXs(): List[XXXMirror]` - // 2) Provide a way to skip obtaining InstanceMirror (step #2 in the outline provided above) - - // [Eugene] another improvement would be have mirrors reproduce the structure of the reflection domain + // todo. an improvement might be having mirrors reproduce the structure of the reflection domain // e.g. a ClassMirror could also have a list of fields, methods, constructors and so on // read up more on the proposed design in "Reflecting Scala" by Y. Coppel diff --git a/src/reflect/scala/reflect/api/Positions.scala b/src/reflect/scala/reflect/api/Positions.scala index 9d3d90d9f8..5e8d958f02 100644 --- a/src/reflect/scala/reflect/api/Positions.scala +++ b/src/reflect/scala/reflect/api/Positions.scala @@ -7,6 +7,10 @@ trait Positions extends base.Positions { /** .. */ type Position >: Null <: PositionApi { type Pos = Position } + /** Assigns a given position to all position-less nodes of a given AST. + */ + def atPos[T <: Tree](pos: Position)(tree: T): T + /** A position that wraps a set of trees. * The point of the wrapping position is the point of the default position. * If some of the trees are ranges, returns a range position enclosing all ranges @@ -20,14 +24,6 @@ trait Positions extends base.Positions { * Otherwise returns a synthetic offset position to point. */ def wrappingPos(trees: List[Tree]): Position - - /** Ensure that given tree has no positions that overlap with - * any of the positions of `others`. This is done by - * shortening the range or assigning TransparentPositions - * to some of the nodes in `tree`. - */ - //def ensureNonOverlapping(tree: Tree, others: List[Tree]) - // [Eugene++] can this method be of use for macros? } /** The Position class and its subclasses represent positions of ASTs and symbols. diff --git a/src/reflect/scala/reflect/api/Symbols.scala b/src/reflect/scala/reflect/api/Symbols.scala index fda76c7b95..c1221a62ab 100644 --- a/src/reflect/scala/reflect/api/Symbols.scala +++ b/src/reflect/scala/reflect/api/Symbols.scala @@ -21,7 +21,7 @@ trait Symbols extends base.Symbols { self: Universe => /** A list of annotations attached to this Symbol. */ - // [Eugene++] we cannot expose the `annotations` method because it doesn't auto-initialize a symbol (see SI-5423) + // we cannot expose the `annotations` method because it doesn't auto-initialize a symbol (see SI-5423) // there was an idea to use the `isCompilerUniverse` flag and auto-initialize symbols in `annotations` whenever this flag is false // but it doesn't work, because the unpickler (that is shared between reflective universes and global universes) is very picky about initialization // scala.reflect.internal.Types$TypeError: bad reference while unpickling scala.collection.immutable.Nil: type Nothing not found in scala.type not found. @@ -200,7 +200,6 @@ trait Symbols extends base.Symbols { self: Universe => /** 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? - * [Eugene++] I need a review of the implementation */ def isValue: Boolean diff --git a/src/reflect/scala/reflect/api/TagInterop.scala b/src/reflect/scala/reflect/api/TagInterop.scala index 4d2254cb9f..5ab085741e 100644 --- a/src/reflect/scala/reflect/api/TagInterop.scala +++ b/src/reflect/scala/reflect/api/TagInterop.scala @@ -4,16 +4,10 @@ package api import scala.reflect.base.TypeCreator import scala.reflect.base.{Universe => BaseUniverse} -// [Martin] Moved to compiler because it needs to see runtime.Universe -// The two will be united in scala-reflect anyway. trait TagInterop { self: JavaUniverse => - // [Eugene++] would be great if we could approximate the interop without any mirrors - // todo. think how to implement that - override def typeTagToManifest[T: ClassTag](mirror0: Any, tag: base.Universe # TypeTag[T]): Manifest[T] = { - // [Eugene++] implement more sophisticated logic - // Martin said it'd be okay to simply copypaste `Implicits.manifestOfType` + // SI-6239: make this conversion more precise val mirror = mirror0.asInstanceOf[Mirror] val runtimeClass = mirror.runtimeClass(tag.in(mirror).tpe) Manifest.classType(runtimeClass).asInstanceOf[Manifest[T]] diff --git a/src/reflect/scala/reflect/api/Types.scala b/src/reflect/scala/reflect/api/Types.scala index 199cf9b9e5..ebaedd7ac3 100644 --- a/src/reflect/scala/reflect/api/Types.scala +++ b/src/reflect/scala/reflect/api/Types.scala @@ -293,7 +293,6 @@ trait Types extends base.Types { self: Universe => // Creators --------------------------------------------------------------- // too useful and too non-trivial to be left out of public API - // [Eugene to Paul] needs review! /** The canonical creator for single-types */ def singleType(pre: Type, sym: Symbol): Type diff --git a/src/reflect/scala/reflect/internal/Definitions.scala b/src/reflect/scala/reflect/internal/Definitions.scala index c6815d10c3..fcbe7d0ed9 100644 --- a/src/reflect/scala/reflect/internal/Definitions.scala +++ b/src/reflect/scala/reflect/internal/Definitions.scala @@ -19,23 +19,6 @@ trait Definitions extends api.StandardDefinitions { object definitions extends DefinitionsClass - // [Eugene] find a way to make these non-lazy - 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 * creation as a function from those symbols to (formal types, result type). @@ -143,6 +126,16 @@ trait Definitions extends api.StandardDefinitions { lazy val Boolean_or = getMemberMethod(BooleanClass, nme.ZOR) lazy val Boolean_not = getMemberMethod(BooleanClass, nme.UNARY_!) + lazy val UnitTpe = UnitClass.toTypeConstructor + lazy val ByteTpe = ByteClass.toTypeConstructor + lazy val ShortTpe = ShortClass.toTypeConstructor + lazy val CharTpe = CharClass.toTypeConstructor + lazy val IntTpe = IntClass.toTypeConstructor + lazy val LongTpe = LongClass.toTypeConstructor + lazy val FloatTpe = FloatClass.toTypeConstructor + lazy val DoubleTpe = DoubleClass.toTypeConstructor + lazy val BooleanTpe = BooleanClass.toTypeConstructor + lazy val ScalaNumericValueClasses = ScalaValueClasses filterNot Set[Symbol](UnitClass, BooleanClass) def ScalaValueClassesNoUnit = ScalaValueClasses filterNot (_ eq UnitClass) @@ -242,6 +235,9 @@ trait Definitions extends api.StandardDefinitions { lazy val AnyClass = enterNewClass(ScalaPackageClass, tpnme.Any, Nil, ABSTRACT) lazy val AnyRefClass = newAlias(ScalaPackageClass, tpnme.AnyRef, ObjectClass.tpe) lazy val ObjectClass = getRequiredClass(sn.Object.toString) + lazy val AnyTpe = definitions.AnyClass.toTypeConstructor + lazy val AnyRefTpe = definitions.AnyRefClass.toTypeConstructor + lazy val ObjectTpe = definitions.ObjectClass.toTypeConstructor // Note: this is not the type alias AnyRef, it's a companion-like // object used by the @specialize annotation. @@ -255,6 +251,7 @@ trait Definitions extends api.StandardDefinitions { anyval.info.decls enter av_constr anyval }).asInstanceOf[ClassSymbol] + lazy val AnyValTpe = definitions.AnyValClass.toTypeConstructor // bottom types lazy val RuntimeNothingClass = getClassByName(fulltpnme.RuntimeNothing) @@ -276,6 +273,8 @@ trait Definitions extends api.StandardDefinitions { || (that ne NothingClass) && (that isSubClass ObjectClass) ) } + lazy val NothingTpe = definitions.NothingClass.toTypeConstructor + lazy val NullTpe = definitions.NullClass.toTypeConstructor // exceptions and other throwables lazy val ClassCastExceptionClass = requiredClass[ClassCastException] @@ -302,7 +301,7 @@ trait Definitions extends api.StandardDefinitions { def Sys_error = getMemberMethod(SysPackage, nme.error) // Modules whose members are in the default namespace - // [Eugene++] ScalaPackage and JavaLangPackage are never ever shared between mirrors + // SI-5941: ScalaPackage and JavaLangPackage are never ever shared between mirrors // as a result, `Int` becomes `scala.Int` and `String` becomes `java.lang.String` // I could just change `isOmittablePrefix`, but there's more to it, so I'm leaving this as a todo for now lazy val UnqualifiedModules = List(PredefModule, ScalaPackage, JavaLangPackage) @@ -338,7 +337,6 @@ trait Definitions extends api.StandardDefinitions { lazy val SymbolModule = requiredModule[scala.Symbol.type] lazy val Symbol_apply = getMemberMethod(SymbolModule, nme.apply) - def SeqFactory = getMember(ScalaRunTimeModule, nme.Seq) // [Eugene++] obsolete? def arrayApplyMethod = getMemberMethod(ScalaRunTimeModule, nme.array_apply) def arrayUpdateMethod = getMemberMethod(ScalaRunTimeModule, nme.array_update) def arrayLengthMethod = getMemberMethod(ScalaRunTimeModule, nme.array_length) @@ -978,12 +976,7 @@ trait Definitions extends api.StandardDefinitions { throw new FatalError(owner + " does not have a " + what + " " + name) } - def getLanguageFeature(name: String, owner: Symbol = languageFeatureModule): Symbol = - // [Eugene++] `getMemberClass` leads to crashes in mixin: - // "object languageFeature does not have a member class implicitConversions" - // that's because by that time `implicitConversions` becomes a module - // getMemberClass(owner, newTypeName(name)) - getMember(owner, newTypeName(name)) + def getLanguageFeature(name: String, owner: Symbol = languageFeatureModule): Symbol = getMember(owner, newTypeName(name)) def termMember(owner: Symbol, name: String): Symbol = owner.info.member(newTermName(name)) def typeMember(owner: Symbol, name: String): Symbol = owner.info.member(newTypeName(name)) @@ -1008,28 +1001,24 @@ trait Definitions extends api.StandardDefinitions { } } def getMemberValue(owner: Symbol, name: Name): TermSymbol = { - // [Eugene++] should be a ClassCastException instead? getMember(owner, name.toTermName) match { case x: TermSymbol => x case _ => fatalMissingSymbol(owner, name, "member value") } } def getMemberModule(owner: Symbol, name: Name): ModuleSymbol = { - // [Eugene++] should be a ClassCastException instead? getMember(owner, name.toTermName) match { case x: ModuleSymbol => x case _ => fatalMissingSymbol(owner, name, "member object") } } def getMemberType(owner: Symbol, name: Name): TypeSymbol = { - // [Eugene++] should be a ClassCastException instead? getMember(owner, name.toTypeName) match { case x: TypeSymbol => x case _ => fatalMissingSymbol(owner, name, "member type") } } def getMemberClass(owner: Symbol, name: Name): ClassSymbol = { - // [Eugene++] should be a ClassCastException instead? val y = getMember(owner, name.toTypeName) getMember(owner, name.toTypeName) match { case x: ClassSymbol => x @@ -1037,48 +1026,8 @@ trait Definitions extends api.StandardDefinitions { } } def getMemberMethod(owner: Symbol, name: Name): TermSymbol = { - // [Eugene++] is this a bug? - // - // System.err.println(result.getClass) - // System.err.println(result.flags) - // System.err.println("isMethod = " + result.isMethod) - // System.err.println("isTerm = " + result.isTerm) - // System.err.println("isValue = " + result.isValue) - // result.asMethod - // - // prints this: - // - // quick.lib: - // [javac] Compiling 1 source file to C:\Projects\KeplerUnderRefactoring\build\quick\classes\library - // [scalacfork] Compiling 769 files to C:\Projects\KeplerUnderRefactoring\build\quick\classes\library - // [scalacfork] class scala.reflect.internal.Symbols$TermSymbol - // [scalacfork] 8589934592 - // [scalacfork] isMethod = false - // [scalacfork] isTerm = true - // [scalacfork] isValue = true - // [scalacfork] - // [scalacfork] while compiling: C:\Projects\KeplerUnderRefactoring\src\library\scala\LowPriorityImplicits.scala - // [scalacfork] current phase: cleanup - // [scalacfork] library version: version 2.10.0-20120507-185519-665d1d9127 - // [scalacfork] compiler version: version 2.10.0-20120507-185519-665d1d9127 - // [scalacfork] reconstructed args: -Xmacros -classpath C:\\Projects\\KeplerUnderRefactoring\\build\\quick\\classes\\library;C:\\Projects\\KeplerUnderRefactoring\\lib\\forkjoin.jar -d C:\\Projects\\KeplerUnderRefactoring\\build\\quick\\classes\\library -sourcepath C:\\Projects\\KeplerUnderRefactoring\\src\\library - // [scalacfork] - // [scalacfork] unhandled exception while transforming LowPriorityImplicits.scala - // [scalacfork] error: - // [scalacfork] while compiling: C:\Projects\KeplerUnderRefactoring\src\library\scala\LowPriorityImplicits.scala - // [scalacfork] current phase: cleanup - // [scalacfork] library version: version 2.10.0-20120507-185519-665d1d9127 - // [scalacfork] compiler version: version 2.10.0-20120507-185519-665d1d9127 - // [scalacfork] reconstructed args: -Xmacros -classpath C:\\Projects\\KeplerUnderRefactoring\\build\\quick\\classes\\library;C:\\Projects\\KeplerUnderRefactoring\\lib\\forkjoin.jar -d C:\\Projects\\KeplerUnderRefactoring\\build\\quick\\classes\\library -sourcepath C:\\Projects\\KeplerUnderRefactoring\\src\\library - // [scalacfork] - // [scalacfork] uncaught exception during compilation: java.lang.ClassCastException - // [scalacfork] error: java.lang.ClassCastException: value apply - // [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? getMember(owner, name.toTermName) match { + // todo. member symbol becomes a term symbol in cleanup. is this a bug? // case x: MethodSymbol => x case x: TermSymbol => x case _ => fatalMissingSymbol(owner, name, "method") diff --git a/src/reflect/scala/reflect/internal/Importers.scala b/src/reflect/scala/reflect/internal/Importers.scala index 00017e087a..25441f9812 100644 --- a/src/reflect/scala/reflect/internal/Importers.scala +++ b/src/reflect/scala/reflect/internal/Importers.scala @@ -2,10 +2,9 @@ package scala.reflect package internal import scala.collection.mutable.WeakHashMap -// todo: move importers to a mirror +// SI-6241: move importers to a mirror trait Importers { self: SymbolTable => - // [Eugene] possible to make this less cast-heavy? def mkImporter(from0: api.Universe): Importer { val from: from0.type } = ( if (self eq from0) { new Importer { diff --git a/src/reflect/scala/reflect/internal/Printers.scala b/src/reflect/scala/reflect/internal/Printers.scala index 0c86e4fba0..9580ed1f72 100644 --- a/src/reflect/scala/reflect/internal/Printers.scala +++ b/src/reflect/scala/reflect/internal/Printers.scala @@ -3,7 +3,7 @@ * @author Martin Odersky */ -// [Eugene++ to Martin] we need to unify this prettyprinter with NodePrinters +// todo. we need to unify this prettyprinter with NodePrinters package scala.reflect package internal @@ -174,12 +174,7 @@ trait Printers extends api.Printers { self: SymbolTable => } def printAnnotations(tree: Tree) { - if (!isCompilerUniverse && tree.symbol != null && tree.symbol != NoSymbol) - // [Eugene++] todo. this is not 100% correct, but is necessary for sane printing - // the problem is that getting annotations doesn't automatically initialize the symbol - // so we might easily print something as if it doesn't have annotations, whereas it does - tree.symbol.initialize - + // SI-5885: by default this won't print annotations of not yet initialized symbols val annots = tree.symbol.annotations match { case Nil => tree.asInstanceOf[MemberDef].mods.annotations case anns => anns diff --git a/src/reflect/scala/reflect/internal/StdNames.scala b/src/reflect/scala/reflect/internal/StdNames.scala index c1e5f78d50..f63e2602b1 100644 --- a/src/reflect/scala/reflect/internal/StdNames.scala +++ b/src/reflect/scala/reflect/internal/StdNames.scala @@ -1008,8 +1008,6 @@ trait StdNames { val javanme = nme.javaKeywords - // [Eugene++ to Martin] had to move a lot of stuff from here to TermNames to satisfy the contract - // why do we even have stuff in object nme? cf. object tpnme object nme extends TermNames { def isModuleVarName(name: Name): Boolean = diff --git a/src/reflect/scala/reflect/internal/Symbols.scala b/src/reflect/scala/reflect/internal/Symbols.scala index ac8b254f83..4dd40c8a4f 100644 --- a/src/reflect/scala/reflect/internal/Symbols.scala +++ b/src/reflect/scala/reflect/internal/Symbols.scala @@ -839,7 +839,6 @@ trait Symbols extends api.Symbols { self: SymbolTable => final def isInitialized: Boolean = validTo != NoPeriod - // [Eugene] todo. needs to be reviewed and [only then] rewritten without explicit returns /** Determines whether this symbol can be loaded by subsequent reflective compilation */ final def isLocatable: Boolean = { if (this == NoSymbol) return false diff --git a/src/reflect/scala/reflect/internal/Trees.scala b/src/reflect/scala/reflect/internal/Trees.scala index 94d51b7455..3894870252 100644 --- a/src/reflect/scala/reflect/internal/Trees.scala +++ b/src/reflect/scala/reflect/internal/Trees.scala @@ -979,12 +979,7 @@ trait Trees extends api.Trees { self: SymbolTable => */ def New(tpt: Tree, argss: List[List[Tree]]): Tree = argss match { case Nil => ApplyConstructor(tpt, Nil) - case xs :: rest => { - def mkApply(fun: Tree, args: List[Tree]) = Apply(fun, args) - rest.foldLeft(ApplyConstructor(tpt, xs): Tree)(mkApply) - // [Eugene++] no longer compiles after I moved the `Apply` case class here - // rest.foldLeft(ApplyConstructor(tpt, xs): Tree)(Apply) - } + case xs :: rest => rest.foldLeft(ApplyConstructor(tpt, xs): Tree)(Apply.apply) } /** 0-1 argument list new, based on a type. diff --git a/src/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala index b6305e773a..56506246ca 100644 --- a/src/reflect/scala/reflect/internal/Types.scala +++ b/src/reflect/scala/reflect/internal/Types.scala @@ -265,14 +265,14 @@ trait Types extends api.Types { self: SymbolTable => def declarations = decls def typeArguments = typeArgs def erasure = this match { - case ConstantType(value) => widen.erasure // [Eugene to Martin] constant types are unaffected by erasure. weird. + case ConstantType(value) => widen.erasure case _ => var result: Type = transformedType(this) result = result.normalize match { // necessary to deal with erasures of HK types, typeConstructor won't work case PolyType(undets, underlying) => existentialAbstraction(undets, underlying) // we don't want undets in the result case _ => result } - // [Eugene] erasure screws up all ThisTypes for modules into PackageTypeRefs + // erasure screws up all ThisTypes for modules into PackageTypeRefs // we need to unscrew them, or certain typechecks will fail mysteriously // http://groups.google.com/group/scala-internals/browse_thread/thread/6d3277ae21b6d581 result = result.map(tpe => tpe match { @@ -284,7 +284,6 @@ trait Types extends api.Types { self: SymbolTable => def substituteSymbols(from: List[Symbol], to: List[Symbol]): Type = substSym(from, to) def substituteTypes(from: List[Symbol], to: List[Type]): Type = subst(from, to) - // [Eugene] to be discussed and refactored def isConcrete = { def notConcreteSym(sym: Symbol) = sym.isAbstractType && !sym.isExistential @@ -304,11 +303,8 @@ trait Types extends api.Types { self: SymbolTable => !notConcreteTpe(this) } - // [Eugene] is this comprehensive? - // the only thingies that we want to splice are: 1) type parameters, 2) type members + // the only thingies that we want to splice are: 1) type parameters, 2) abstract type members // the thingies that we don't want to splice are: 1) concrete types (obviously), 2) existential skolems - // this check seems to cover them all, right? - // todo. after we discuss this, move the check to subclasses def isSpliceable = { this.isInstanceOf[TypeRef] && typeSymbol.isAbstractType && !typeSymbol.isExistential } diff --git a/src/reflect/scala/reflect/macros/Infrastructure.scala b/src/reflect/scala/reflect/macros/Infrastructure.scala index 5ae2c08265..a8a8b814b1 100644 --- a/src/reflect/scala/reflect/macros/Infrastructure.scala +++ b/src/reflect/scala/reflect/macros/Infrastructure.scala @@ -46,10 +46,6 @@ trait Infrastructure { * val valueOfX = toolBox.runExpr(imported).asInstanceOf[T] * ... * } - * - * // [Eugene++] using this guy will tremendously slow down the compilation - * // https://twitter.com/xeno_by/status/201248317831774208 - * // todo. we need to address this somehow */ def libraryClassLoader: ClassLoader diff --git a/src/reflect/scala/reflect/macros/Settings.scala b/src/reflect/scala/reflect/macros/Settings.scala index 8d166056c3..a2cdb4c8e1 100644 --- a/src/reflect/scala/reflect/macros/Settings.scala +++ b/src/reflect/scala/reflect/macros/Settings.scala @@ -12,14 +12,10 @@ trait Settings { /** Exposes current compiler settings as a list of options. * Use `scalac -help`, `scalac -X` and `scalac -Y` to learn about currently supported options. */ - // [Eugene] ugly? yes, but I don't really fancy copy/pasting all our settings here and keep it synchronized at all times - // why all settings? because macros need to be in full control of the stuff going on - // maybe later we can implement a gettable/settable list of important settings, but for now let's leave it like that def compilerSettings: List[String] /** Updates current compiler settings with an option string. * Use `scalac -help`, `scalac -X` and `scalac -Y` to learn about currently supported options. - * todo. http://groups.google.com/group/scala-internals/browse_thread/thread/07c18cff41f59203 */ def setCompilerSettings(options: String): this.type @@ -28,12 +24,12 @@ trait Settings { */ def setCompilerSettings(options: List[String]): this.type - /** Temporary sets compiler settings to a given option string and executes a given closure. + /** Temporarily sets compiler settings to a given option string and executes a given closure. * Use `scalac -help`, `scalac -X` and `scalac -Y` to learn about currently supported options. */ def withCompilerSettings[T](options: String)(op: => T): T - /** Temporary sets compiler settings to a given list of options and executes a given closure. + /** Temporarily sets compiler settings to a given list of options and executes a given closure. * Use `scalac -help`, `scalac -X` and `scalac -Y` to learn about currently supported options. */ def withCompilerSettings[T](options: List[String])(op: => T): T diff --git a/src/reflect/scala/reflect/macros/TreeBuilder.scala b/src/reflect/scala/reflect/macros/TreeBuilder.scala index 06f5caf68b..ca29194859 100644 --- a/src/reflect/scala/reflect/macros/TreeBuilder.scala +++ b/src/reflect/scala/reflect/macros/TreeBuilder.scala @@ -1,10 +1,6 @@ package scala.reflect 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 -// same goes for tree traversers/transformers, type maps, etc -// and once we expose all that, there's another question: how do we stay in sync? abstract class TreeBuilder { val global: Universe diff --git a/src/reflect/scala/reflect/runtime/JavaMirrors.scala b/src/reflect/scala/reflect/runtime/JavaMirrors.scala index 4ce2cda04a..967ac69148 100644 --- a/src/reflect/scala/reflect/runtime/JavaMirrors.scala +++ b/src/reflect/scala/reflect/runtime/JavaMirrors.scala @@ -88,7 +88,6 @@ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: Sym // ----------- Caching ------------------------------------------------------------------ - // [Eugene++ to Martin] not weak? why? private val classCache = new TwoWayCache[jClass[_], ClassSymbol] private val packageCache = new TwoWayCache[Package, ModuleSymbol] private val methodCache = new TwoWayCache[jMethod, MethodSymbol] @@ -659,43 +658,33 @@ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: Sym private def followStatic(clazz: Symbol, mods: Int) = if (jModifier.isStatic(mods)) clazz.companionModule.moduleClass else clazz - implicit class RichClass(jclazz: jClass[_]) { - // [Eugene++] `jclazz.isLocalClass` doesn't work because of problems with `getSimpleName` - // java.lang.Error: sOwner(class Test$A$1) has failed - // Caused by: java.lang.InternalError: Malformed class name - // at java.lang.Class.getSimpleName(Class.java:1133) - // at java.lang.Class.isAnonymousClass(Class.java:1188) - // at java.lang.Class.isLocalClass(Class.java:1199) - // (see t5256c.scala for more details) + /** Methods which need to be treated with care + * because they either are getSimpleName or call getSimpleName: + * + * public String getSimpleName() + * public boolean isAnonymousClass() + * public boolean isLocalClass() + * public String getCanonicalName() + * + * A typical manifestation: + * + * // java.lang.Error: sOwner(class Test$A$1) has failed + * // Caused by: java.lang.InternalError: Malformed class name + * // at java.lang.Class.getSimpleName(Class.java:1133) + * // at java.lang.Class.isAnonymousClass(Class.java:1188) + * // at java.lang.Class.isLocalClass(Class.java:1199) + * // (see t5256c.scala for more details) + * + * TODO - find all such calls and wrap them. + * TODO - create mechanism to avoid the recurrence of unwrapped calls. + */ + implicit class RichClass(jclazz: jClass[_]) { + // `jclazz.isLocalClass` doesn't work because of problems with `getSimpleName` // hence we have to approximate by removing the `isAnonymousClass` check // def isLocalClass0: Boolean = jclazz.isLocalClass def isLocalClass0: Boolean = jclazz.getEnclosingMethod != null || jclazz.getEnclosingConstructor != null } - // [Eugene++] overflow from Paul's changes made concurrently with reflection refactoring - // https://github.com/scala/scala/commit/90d2bee45b25844f809f8c5300aefcb1bfe9e336 - // - // /** Methods which need to be wrapped because they either are getSimpleName - // * or call getSimpleName: - // * - // * public String getSimpleName() - // * public boolean isAnonymousClass() - // * public boolean isLocalClass() - // * public boolean isMemberClass() - // * public String getCanonicalName() - // * - // * TODO - find all such calls and wrap them. - // * TODO - create mechanism to avoid the recurrence of unwrapped calls. - // */ - // private def wrapClassCheck[T](alt: T)(body: => T): T = - // try body catch { case x: InternalError if x.getMessage == "Malformed class name" => alt } - - // private def wrapIsLocalClass(clazz: jClass[_]): Boolean = - // wrapClassCheck(false)(clazz.isLocalClass) - - // private def wrapGetSimpleName(clazz: jClass[_]): String = - // wrapClassCheck("")(clazz.getSimpleName) - /** * The Scala owner of the Scala class corresponding to the Java class `jclazz` */ @@ -1208,7 +1197,7 @@ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { self: Sym override def missingHook(owner: Symbol, name: Name): Symbol = { if (owner.hasPackageFlag) { val mirror = mirrorThatLoaded(owner) - // [Eugene++] this makes toolbox tests pass, but it's a mere workaround for SI-5865 + // todo. this makes toolbox tests pass, but it's a mere workaround for SI-5865 // assert((owner.info decl name) == NoSymbol, s"already exists: $owner . $name") if (owner.isRootSymbol && mirror.tryJavaClass(name.toString).isDefined) return mirror.EmptyPackageClass.info decl name diff --git a/src/reflect/scala/reflect/runtime/SymbolLoaders.scala b/src/reflect/scala/reflect/runtime/SymbolLoaders.scala index eb48e9dc79..583b9d93f3 100644 --- a/src/reflect/scala/reflect/runtime/SymbolLoaders.scala +++ b/src/reflect/scala/reflect/runtime/SymbolLoaders.scala @@ -61,10 +61,8 @@ trait SymbolLoaders { self: SymbolTable => assert(!(name.toString endsWith "[]"), name) val clazz = owner.newClass(name) val module = owner.newModule(name.toTermName) - // [Eugene++] am I doing this right? - // todo: drop condition, see what goes wrong - // [Eugene++ to Martin] test/files/run/t5256g and test/files/run/t5256h will crash - // reflection meeting verdict: need to enter the symbols into the first symbol in the owner chain that has a non-empty scope + // without this check test/files/run/t5256g and test/files/run/t5256h will crash + // todo. reflection meeting verdict: need to enter the symbols into the first symbol in the owner chain that has a non-empty scope if (owner.info.decls != EmptyScope) { owner.info.decls enter clazz owner.info.decls enter module diff --git a/src/reflect/scala/reflect/runtime/SynchronizedOps.scala b/src/reflect/scala/reflect/runtime/SynchronizedOps.scala index 907c0dd369..1a17dd12d2 100644 --- a/src/reflect/scala/reflect/runtime/SynchronizedOps.scala +++ b/src/reflect/scala/reflect/runtime/SynchronizedOps.scala @@ -1,6 +1,7 @@ package scala.reflect package runtime +// SI-6240: test thread-safety, make trees synchronized as well trait SynchronizedOps extends internal.SymbolTable with SynchronizedSymbols with SynchronizedTypes { self: SymbolTable => diff --git a/src/reflect/scala/reflect/runtime/SynchronizedSymbols.scala b/src/reflect/scala/reflect/runtime/SynchronizedSymbols.scala index c65357b652..12db7a7bf9 100644 --- a/src/reflect/scala/reflect/runtime/SynchronizedSymbols.scala +++ b/src/reflect/scala/reflect/runtime/SynchronizedSymbols.scala @@ -134,8 +134,6 @@ trait SynchronizedSymbols extends internal.Symbols { self: SymbolTable => trait SynchronizedModuleClassSymbol extends ModuleClassSymbol with SynchronizedClassSymbol { 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: Scope = synchronized { super.implicitMembers } } } diff --git a/src/reflect/scala/reflect/runtime/package.scala b/src/reflect/scala/reflect/runtime/package.scala index d00094c0c1..ccdea3e82d 100644 --- a/src/reflect/scala/reflect/runtime/package.scala +++ b/src/reflect/scala/reflect/runtime/package.scala @@ -5,8 +5,6 @@ package object runtime { // type is api.JavaUniverse because we only want to expose the `scala.reflect.api.*` subset of reflection lazy val universe: api.JavaUniverse = new runtime.JavaUniverse - // [Eugene++ to Martin] removed `mirrorOfLoader`, because one can use `universe.runtimeMirror` instead - // implementation magically hardwired to the `currentMirror` method below def currentMirror: universe.Mirror = ??? // macro } diff --git a/src/reflect/scala/tools/nsc/io/Path.scala b/src/reflect/scala/tools/nsc/io/Path.scala index bfad4b93c5..e965c70111 100644 --- a/src/reflect/scala/tools/nsc/io/Path.scala +++ b/src/reflect/scala/tools/nsc/io/Path.scala @@ -43,8 +43,6 @@ object Path { if (i < 0) "" else name.substring(i + 1).toLowerCase } - // [Eugene++] I hope that noone relied on this method -// def isJarOrZip(f: Path, examineFile: Boolean = true) = Jar.isJarOrZip(f, examineFile) // not certain these won't be problematic, but looks good so far implicit def string2path(s: String): Path = apply(s) |