summaryrefslogtreecommitdiff
path: root/src/reflect
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@typesafe.com>2014-09-01 22:00:20 +0200
committerLukas Rytz <lukas.rytz@typesafe.com>2014-09-01 22:00:20 +0200
commitbb3b08dd675a68c5245a8ad64470c796e346ba91 (patch)
tree92f5a1108d68114b6c9423630998c4bdbeea0432 /src/reflect
parent7693cecc8b3cf56984a041bb2d7979e2a040314a (diff)
parent2256753502c2c099da17a20d45c3f23974d0eafd (diff)
downloadscala-bb3b08dd675a68c5245a8ad64470c796e346ba91.tar.gz
scala-bb3b08dd675a68c5245a8ad64470c796e346ba91.tar.bz2
scala-bb3b08dd675a68c5245a8ad64470c796e346ba91.zip
Merge pull request #3931 from lrytz/opt/tracked-final
GenBCode refactoring (remove Tracked) and fix InnerClass / EnclosingMethod attributes
Diffstat (limited to 'src/reflect')
-rw-r--r--src/reflect/scala/reflect/internal/Symbols.scala20
-rw-r--r--src/reflect/scala/reflect/runtime/JavaMirrors.scala25
2 files changed, 10 insertions, 35 deletions
diff --git a/src/reflect/scala/reflect/internal/Symbols.scala b/src/reflect/scala/reflect/internal/Symbols.scala
index b6cce4524b..d132b76f30 100644
--- a/src/reflect/scala/reflect/internal/Symbols.scala
+++ b/src/reflect/scala/reflect/internal/Symbols.scala
@@ -74,15 +74,6 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
}
}
- protected def originalEnclosingMethod(sym: Symbol): Symbol = {
- if (sym.isMethod || sym == NoSymbol) sym
- else {
- val owner = sym.originalOwner
- if (sym.isLocalDummy) owner.enclClass.primaryConstructor
- else originalEnclosingMethod(owner)
- }
- }
-
def symbolOf[T: WeakTypeTag]: TypeSymbol = weakTypeOf[T].typeSymbolDirect.asType
abstract class SymbolContextApiImpl extends SymbolApi {
@@ -2122,16 +2113,6 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
* is not one. */
def enclosingPackage: Symbol = enclosingPackageClass.companionModule
- /** Return the original enclosing method of this symbol. It should return
- * the same thing as enclMethod when called before lambda lift,
- * but it preserves the original nesting when called afterwards.
- *
- * @note This method is NOT available in the presentation compiler run. The
- * originalOwner map is not populated for memory considerations (the symbol
- * may hang on to lazy types and in turn to whole (outdated) compilation units.
- */
- def originalEnclosingMethod: Symbol = Symbols.this.originalEnclosingMethod(this)
-
/** The method or class which logically encloses the current symbol.
* If the symbol is defined in the initialization part of a template
* this is the template's primary constructor, otherwise it is
@@ -3532,7 +3513,6 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
override def rawInfo: Type = NoType
override def accessBoundary(base: Symbol): Symbol = enclosingRootClass
def cloneSymbolImpl(owner: Symbol, newFlags: Long) = abort("NoSymbol.clone()")
- override def originalEnclosingMethod = this
}
protected def makeNoSymbol: NoSymbol = new NoSymbol
diff --git a/src/reflect/scala/reflect/runtime/JavaMirrors.scala b/src/reflect/scala/reflect/runtime/JavaMirrors.scala
index 6584d80de3..b7f229b6e5 100644
--- a/src/reflect/scala/reflect/runtime/JavaMirrors.scala
+++ b/src/reflect/scala/reflect/runtime/JavaMirrors.scala
@@ -807,31 +807,26 @@ private[scala] trait JavaMirrors extends internal.SymbolTable with api.JavaUnive
// field containing the cache for structural calls.
if (mods.isStatic) module.moduleClass.orElse(clazz) else clazz
- /** Methods which need to be treated with care
- * because they either are getSimpleName or call getSimpleName:
+ /**
+ * Certain method of the Java reflection api cannot be used on classfiles created by Scala.
+ * See the comment in test/files/jvm/javaReflection/Test.scala. The methods are
*
* 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)
+ * public boolean isSynthetic()
*
* 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
+ // As explained in the javaReflection test, Class.isLocalClass is true for all non-member
+ // nested classes in Scala. This is fine per se, however the implementation may throw an
+ // InternalError. We therefore re-implement it here.
+ // TODO: this method should be renamed to `isLocalOrAnonymousClass`.
+ // due to bin compat that's only possible in 2.12, we cannot introduce a new alias in 2.11.
+ def isLocalClass0: Boolean = jclazz.getEnclosingClass != null && !jclazz.isMemberClass
}
/**