summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@typesafe.com>2014-03-06 14:12:56 -0800
committerEugene Burmako <xeno.by@gmail.com>2014-03-07 20:56:18 +0100
commit60aa5771ea92f91ed34778f90c04113e226d09ca (patch)
tree460f5f6ce0d107c8f90e12a4c720c9b9ed437fc8 /src
parent2dddb03b267770afcd0249ad700e55d53019e637 (diff)
downloadscala-60aa5771ea92f91ed34778f90c04113e226d09ca.tar.gz
scala-60aa5771ea92f91ed34778f90c04113e226d09ca.tar.bz2
scala-60aa5771ea92f91ed34778f90c04113e226d09ca.zip
SI-8367 revert SI-8192's change to primaryConstructor when isJavaDefined
this is some weird stuff
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/transform/Erasure.scala2
-rw-r--r--src/reflect/scala/reflect/api/Symbols.scala8
-rw-r--r--src/reflect/scala/reflect/internal/Symbols.scala4
3 files changed, 11 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala
index bd2f6f0018..e036035397 100644
--- a/src/compiler/scala/tools/nsc/transform/Erasure.scala
+++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala
@@ -600,7 +600,7 @@ abstract class Erasure extends AddInterfaces
if (tree.symbol == NoSymbol) {
tree
} else if (name == nme.CONSTRUCTOR) {
- if (tree.symbol.owner == AnyValClass) tree.symbol = ObjectClass.info.decl(nme.CONSTRUCTOR)
+ if (tree.symbol.owner == AnyValClass) tree.symbol = ObjectClass.primaryConstructor
tree
} else if (tree.symbol == Any_asInstanceOf)
adaptMember(atPos(tree.pos)(Select(qual, Object_asInstanceOf)))
diff --git a/src/reflect/scala/reflect/api/Symbols.scala b/src/reflect/scala/reflect/api/Symbols.scala
index a5a50f1088..dddd3c0e61 100644
--- a/src/reflect/scala/reflect/api/Symbols.scala
+++ b/src/reflect/scala/reflect/api/Symbols.scala
@@ -919,6 +919,14 @@ trait Symbols { self: Universe =>
* For a Scala package class, NoSymbol.
* For a Java class, NoSymbol.
*
+ * Known issues: Due to SI-8367, primaryConstructor may return unexpected results
+ * when called for Java classes (for some vague definition of a "Java class", which apparently
+ * not only includes javac-produced classfiles, but also consists of classes defined in
+ * Scala programs under the java.lang package). What's even worse, for some Java classes
+ * we can't even guarantee stability of the return value - depending on your classloader configuration
+ * and/or JDK version you might get different primaryConstructor for the same ClassSymbol.
+ * We have logged these issues at SI-8193.
+ *
* @group Class
*/
// TODO: SI-8193 I think we should only return a non-empty symbol if called for Scala classes
diff --git a/src/reflect/scala/reflect/internal/Symbols.scala b/src/reflect/scala/reflect/internal/Symbols.scala
index 03d8f97831..595d638c28 100644
--- a/src/reflect/scala/reflect/internal/Symbols.scala
+++ b/src/reflect/scala/reflect/internal/Symbols.scala
@@ -1904,6 +1904,7 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
/** The next enclosing method. */
def enclMethod: Symbol = if (isSourceMethod) this else owner.enclMethod
+ /** The primary constructor of a class. */
def primaryConstructor: Symbol = NoSymbol
/** The self symbol (a TermSymbol) of a class with explicit self type, or else the
@@ -3188,8 +3189,7 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
override def primaryConstructor = {
val c = info decl primaryConstructorName
- if (isJavaDefined) NoSymbol // need to force info before checking the flag
- else if (c.isOverloaded) c.alternatives.head else c
+ if (c.isOverloaded) c.alternatives.head else c
}
override def associatedFile = (