summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/reflect/runtime/ConversionUtil.scala7
-rw-r--r--src/compiler/scala/reflect/runtime/JavaToScala.scala2
-rw-r--r--src/compiler/scala/reflect/runtime/Loaders.scala4
-rw-r--r--src/compiler/scala/reflect/runtime/ScalaToJava.scala2
-rw-r--r--src/compiler/scala/reflect/runtime/SymbolTable.scala9
-rw-r--r--src/compiler/scala/reflect/runtime/Universe.scala2
-rw-r--r--src/compiler/scala/tools/nsc/Global.scala4
-rw-r--r--src/compiler/scala/tools/nsc/ReflectGlobal.scala16
-rw-r--r--src/compiler/scala/tools/nsc/ReflectMain.scala7
-rw-r--r--src/compiler/scala/tools/nsc/doc/DocFactory.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala2
11 files changed, 47 insertions, 10 deletions
diff --git a/src/compiler/scala/reflect/runtime/ConversionUtil.scala b/src/compiler/scala/reflect/runtime/ConversionUtil.scala
index 47e57a2173..4213506c3b 100644
--- a/src/compiler/scala/reflect/runtime/ConversionUtil.scala
+++ b/src/compiler/scala/reflect/runtime/ConversionUtil.scala
@@ -7,7 +7,7 @@ import java.lang.reflect.{
Member => jMember, Type => jType, TypeVariable => jTypeVariable, GenericDeclaration}
import collection.mutable.HashMap
-trait ConversionUtil extends internal.transform.Transforms { self: Universe =>
+trait ConversionUtil { self: internal.SymbolTable =>
/** A cache that maintains a bijection between Java reflection type `J`
* and Scala reflection type `S`.
@@ -56,6 +56,11 @@ trait ConversionUtil extends internal.transform.Transforms { self: Universe =>
protected val fieldCache = new TwoWayCache[jField, Symbol]
protected val tparamCache = new TwoWayCache[jTypeVariable[_], Symbol]
+ /** the type of this symbol after Scala -> Java transformsi in refChecks, uncurry, erasure
+ */
+ def transformedType(sym: Symbol): Type
+
+ /** The Java class thaty given type compiles to */
def typeToJavaClass(tpe: Type): jClass[_]
/** Does method `meth` erase to Java method `jmeth`?
diff --git a/src/compiler/scala/reflect/runtime/JavaToScala.scala b/src/compiler/scala/reflect/runtime/JavaToScala.scala
index 4406ab74be..b03a956fdb 100644
--- a/src/compiler/scala/reflect/runtime/JavaToScala.scala
+++ b/src/compiler/scala/reflect/runtime/JavaToScala.scala
@@ -21,7 +21,7 @@ import internal.pickling.UnPickler
import collection.mutable.{ HashMap, ListBuffer }
import internal.Flags._
-trait JavaToScala extends ConversionUtil { self: Universe =>
+trait JavaToScala extends ConversionUtil { self: SymbolTable =>
import definitions._
diff --git a/src/compiler/scala/reflect/runtime/Loaders.scala b/src/compiler/scala/reflect/runtime/Loaders.scala
index b508c8e2fe..e25254a6fc 100644
--- a/src/compiler/scala/reflect/runtime/Loaders.scala
+++ b/src/compiler/scala/reflect/runtime/Loaders.scala
@@ -1,11 +1,11 @@
package scala.reflect
package runtime
-import internal.Flags
+import internal.{Flags, SymbolTable}
import java.lang.{Class => jClass, Package => jPackage}
-trait Loaders { self: Universe =>
+trait Loaders { self: SymbolTable =>
/** The lazy type for root.
*/
diff --git a/src/compiler/scala/reflect/runtime/ScalaToJava.scala b/src/compiler/scala/reflect/runtime/ScalaToJava.scala
index 06ce2cfca2..f6e6087bf9 100644
--- a/src/compiler/scala/reflect/runtime/ScalaToJava.scala
+++ b/src/compiler/scala/reflect/runtime/ScalaToJava.scala
@@ -6,7 +6,7 @@ import java.lang.reflect.{
Method => jMethod, Constructor => jConstructor, Modifier => jModifier, Field => jField,
Member => jMember, Type => jType, Array => jArray, GenericDeclaration}
-trait ScalaToJava extends ConversionUtil { self: Universe =>
+trait ScalaToJava extends ConversionUtil { self: SymbolTable =>
import definitions._
diff --git a/src/compiler/scala/reflect/runtime/SymbolTable.scala b/src/compiler/scala/reflect/runtime/SymbolTable.scala
new file mode 100644
index 0000000000..9e560e0d20
--- /dev/null
+++ b/src/compiler/scala/reflect/runtime/SymbolTable.scala
@@ -0,0 +1,9 @@
+package scala.reflect
+package runtime
+
+/**
+ * This symbol table trait fills in the definitions so that class information is obtained by refection.
+ * It can be used either from the reflexive mirror itself (class Universe), or else from
+ * a runtime compiler that uses reflection to get a class information (class scala.tools.nsc.ReflectGlobal)
+ */
+trait SymbolTable extends internal.SymbolTable with JavaToScala with ScalaToJava with Loaders
diff --git a/src/compiler/scala/reflect/runtime/Universe.scala b/src/compiler/scala/reflect/runtime/Universe.scala
index 5794dfc5da..752b0f13ac 100644
--- a/src/compiler/scala/reflect/runtime/Universe.scala
+++ b/src/compiler/scala/reflect/runtime/Universe.scala
@@ -8,7 +8,7 @@ import internal.{SomePhase, NoPhase, Phase, TreeGen}
* It also provides methods to go from Java members to Scala members,
* using the code in JavaConversions.
*/
-class Universe extends internal.SymbolTable with JavaToScala with ScalaToJava with Loaders {
+class Universe extends ReflexiveLoaders with internal.transform.Transforms {
type AbstractFileType = AbstractFile
diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala
index 592540f450..b502da91fc 100644
--- a/src/compiler/scala/tools/nsc/Global.scala
+++ b/src/compiler/scala/tools/nsc/Global.scala
@@ -397,7 +397,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter) extends Symb
} with Pickler
// phaseName = "refchecks"
- object refchecks extends {
+ object refChecks extends {
val global: Global.this.type = Global.this
val runsAfter = List[String]("pickler")
val runsRightAfter = None
@@ -597,7 +597,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter) extends Symb
analyzer.typerFactory -> "the meat and potatoes: type the trees",
superAccessors -> "add super accessors in traits and nested classes",
pickler -> "serialize symbol tables",
- refchecks -> "reference/override checking, translate nested objects",
+ refChecks -> "reference/override checking, translate nested objects",
uncurry -> "uncurry, translate function values to anonymous classes",
tailCalls -> "replace tail calls by jumps",
specializeTypes -> "@specialized-driven class and method specialization",
diff --git a/src/compiler/scala/tools/nsc/ReflectGlobal.scala b/src/compiler/scala/tools/nsc/ReflectGlobal.scala
new file mode 100644
index 0000000000..3132a9987d
--- /dev/null
+++ b/src/compiler/scala/tools/nsc/ReflectGlobal.scala
@@ -0,0 +1,16 @@
+package scala.tools.nsc
+
+import reporters.Reporter
+
+/** A version of Global that uses reflection to get class
+ * infos, instead of reading class or source files.
+ */
+class ReflectGlobal(currentSettings: Settings, reporter: Reporter)
+ extends Global(currentSettings, reporter) with reflect.runtime.SymbolTable {
+
+ override def transformedType(sym: Symbol) =
+ erasure.transformInfo(sym,
+ uncurry.transformInfo(sym,
+ refChecks.transformInfo(sym, sym.info)))
+
+}
diff --git a/src/compiler/scala/tools/nsc/ReflectMain.scala b/src/compiler/scala/tools/nsc/ReflectMain.scala
new file mode 100644
index 0000000000..7167f5aa27
--- /dev/null
+++ b/src/compiler/scala/tools/nsc/ReflectMain.scala
@@ -0,0 +1,7 @@
+package scala.tools.nsc
+
+object ReflectMain extends Driver {
+
+ override def newCompiler(): Global = new ReflectGlobal(settings, reporter)
+
+} \ No newline at end of file
diff --git a/src/compiler/scala/tools/nsc/doc/DocFactory.scala b/src/compiler/scala/tools/nsc/doc/DocFactory.scala
index 43363f7961..5a510803ed 100644
--- a/src/compiler/scala/tools/nsc/doc/DocFactory.scala
+++ b/src/compiler/scala/tools/nsc/doc/DocFactory.scala
@@ -41,7 +41,7 @@ class DocFactory(val reporter: Reporter, val settings: doc.Settings) { processor
phasesSet += analyzer.typerFactory
phasesSet += superAccessors
phasesSet += pickler
- phasesSet += refchecks
+ phasesSet += refChecks
}
override def forScaladoc = true
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala
index 914e9c7dbc..03d1c66a36 100644
--- a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala
@@ -284,7 +284,7 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT
val accName = nme.protName(sym.originalName)
val hasArgs = sym.tpe.paramTypes != Nil
- val memberType = refchecks.toScalaRepeatedParam(sym.tpe) // fix for #2413
+ val memberType = refChecks.toScalaRepeatedParam(sym.tpe) // fix for #2413
// if the result type depends on the this type of an enclosing class, the accessor
// has to take an object of exactly this type, otherwise it's more general