summaryrefslogtreecommitdiff
path: root/src/compiler/scala/reflect/internal/SymbolTable.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2011-09-05 10:44:04 +0000
committerMartin Odersky <odersky@gmail.com>2011-09-05 10:44:04 +0000
commit0d99f59ebaa42eb8717b01de06e8582371b6ccbf (patch)
treec5d7574aeda099ac7826bd4a7e49024bc1966707 /src/compiler/scala/reflect/internal/SymbolTable.scala
parent0d379b728ae11dcc2f15d1e3e3143cb650acf0c3 (diff)
downloadscala-0d99f59ebaa42eb8717b01de06e8582371b6ccbf.tar.gz
scala-0d99f59ebaa42eb8717b01de06e8582371b6ccbf.tar.bz2
scala-0d99f59ebaa42eb8717b01de06e8582371b6ccbf.zip
More refinements to reflection and the reflecti...
More refinements to reflection and the reflective compiler.
Diffstat (limited to 'src/compiler/scala/reflect/internal/SymbolTable.scala')
-rw-r--r--src/compiler/scala/reflect/internal/SymbolTable.scala27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/compiler/scala/reflect/internal/SymbolTable.scala b/src/compiler/scala/reflect/internal/SymbolTable.scala
index 3ab2408cf7..65c2dc4d46 100644
--- a/src/compiler/scala/reflect/internal/SymbolTable.scala
+++ b/src/compiler/scala/reflect/internal/SymbolTable.scala
@@ -147,12 +147,37 @@ abstract class SymbolTable extends api.Universe
}
}
+ /** Convert array parameters denoting a repeated parameter of a Java method
+ * to `JavaRepeatedParamClass` types.
+ */
+ def arrayToRepeated(tp: Type): Type = tp match {
+ case MethodType(params, rtpe) =>
+ val formals = tp.paramTypes
+ assert(formals.last.typeSymbol == definitions.ArrayClass)
+ val method = params.last.owner
+ val elemtp = formals.last.typeArgs.head match {
+ case RefinedType(List(t1, t2), _) if (t1.typeSymbol.isAbstractType && t2.typeSymbol == definitions.ObjectClass) =>
+ t1 // drop intersection with Object for abstract types in varargs. UnCurry can handle them.
+ case t =>
+ t
+ }
+ val newParams = method.newSyntheticValueParams(
+ formals.init :+ appliedType(definitions.JavaRepeatedParamClass.typeConstructor, List(elemtp)))
+ MethodType(newParams, rtpe)
+ case PolyType(tparams, rtpe) =>
+ PolyType(tparams, arrayToRepeated(rtpe))
+ }
+
+ abstract class SymLoader extends LazyType {
+ def fromSource = false
+ }
+
/** if there's a `package` member object in `pkgClass`, enter its members into it. */
def openPackageModule(pkgClass: Symbol) {
val pkgModule = pkgClass.info.decl(nme.PACKAGEkw)
def fromSource = pkgModule.rawInfo match {
- case ltp: LazyType => ltp.fromSource
+ case ltp: SymLoader => ltp.fromSource
case _ => false
}
if (pkgModule.isModule && !fromSource) {