summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@epfl.ch>2009-12-02 16:12:14 +0000
committerAdriaan Moors <adriaan.moors@epfl.ch>2009-12-02 16:12:14 +0000
commite4af2ce209abd7565bb45eae1b80ec798b813035 (patch)
tree4da354dcf216387d58889ad74d8772332f47e9bd /src
parenta9a967bc82ee805f095f7b7b525da2da8f6d46d6 (diff)
downloadscala-e4af2ce209abd7565bb45eae1b80ec798b813035.tar.gz
scala-e4af2ce209abd7565bb45eae1b80ec798b813035.tar.bz2
scala-e4af2ce209abd7565bb45eae1b80ec798b813035.zip
closes #2750: cooking java raw types in info of...
closes #2750: cooking java raw types in info of type parameters of Java classes review by: odersky
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Symbols.scala78
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/RefChecks.scala2
2 files changed, 50 insertions, 30 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/Symbols.scala b/src/compiler/scala/tools/nsc/symtab/Symbols.scala
index 2369456b11..3f9f266132 100644
--- a/src/compiler/scala/tools/nsc/symtab/Symbols.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Symbols.scala
@@ -892,40 +892,13 @@ trait Symbols {
*/
private var triedCooking: Boolean = false
final def cookJavaRawInfo() {
- require(isTerm)
// println("cookJavaRawInfo: "+(rawname, triedCooking))
-
if(triedCooking) return else triedCooking = true // only try once...
-
- def cook(sym: Symbol) {
- require(sym hasFlag JAVA)
- // @M: I think this is more desirable, but Martin prefers to leave raw-types as-is as much as possible
- // object rawToExistentialInJava extends TypeMap {
- // def apply(tp: Type): Type = tp match {
- // // any symbol that occurs in a java sig, not just java symbols
- // // see http://lampsvn.epfl.ch/trac/scala/ticket/2454#comment:14
- // case TypeRef(pre, sym, List()) if !sym.typeParams.isEmpty =>
- // val eparams = typeParamsToExistentials(sym, sym.typeParams)
- // existentialAbstraction(eparams, TypeRef(pre, sym, eparams map (_.tpe)))
- // case _ =>
- // mapOver(tp)
- // }
- // }
- val tpe1 = rawToExistential(sym.tpe)
- // println("cooking: "+ sym +": "+ sym.tpe +" to "+ tpe1)
- if (tpe1 ne sym.tpe) {
- sym.setInfo(tpe1)
- }
- }
-
- if (hasFlag(JAVA))
- cook(this)
- else if (hasFlag(OVERLOADED))
- for (sym2 <- alternatives)
- if (sym2 hasFlag JAVA)
- cook(sym2)
+ doCookJavaRawInfo()
}
+ protected def doCookJavaRawInfo(): Unit
+
/** The type constructor of a symbol is:
* For a type symbol, the type corresponding to the symbol itself,
@@ -1744,6 +1717,36 @@ trait Symbols {
assert(hasFlag(LAZY), this)
referenced
}
+
+ protected def doCookJavaRawInfo() {
+ def cook(sym: Symbol) {
+ require(sym hasFlag JAVA)
+ // @M: I think this is more desirable, but Martin prefers to leave raw-types as-is as much as possible
+ // object rawToExistentialInJava extends TypeMap {
+ // def apply(tp: Type): Type = tp match {
+ // // any symbol that occurs in a java sig, not just java symbols
+ // // see http://lampsvn.epfl.ch/trac/scala/ticket/2454#comment:14
+ // case TypeRef(pre, sym, List()) if !sym.typeParams.isEmpty =>
+ // val eparams = typeParamsToExistentials(sym, sym.typeParams)
+ // existentialAbstraction(eparams, TypeRef(pre, sym, eparams map (_.tpe)))
+ // case _ =>
+ // mapOver(tp)
+ // }
+ // }
+ val tpe1 = rawToExistential(sym.tpe)
+ // println("cooking: "+ sym +": "+ sym.tpe +" to "+ tpe1)
+ if (tpe1 ne sym.tpe) {
+ sym.setInfo(tpe1)
+ }
+ }
+
+ if (hasFlag(JAVA))
+ cook(this)
+ else if (hasFlag(OVERLOADED))
+ for (sym2 <- alternatives)
+ if (sym2 hasFlag JAVA)
+ cook(sym2)
+ }
}
/** A class for module symbols */
@@ -1852,6 +1855,20 @@ trait Symbols {
tyconRunId = NoRunId
}
+ /*** example:
+ * public class Test3<T> {}
+ * public class Test1<T extends Test3> {}
+ * info for T in Test1 should be >: Nothing <: Test3[_]
+ */
+ protected def doCookJavaRawInfo() {
+ // don't require hasFlag(JAVA), since T in the above example does not have that flag
+ val tpe1 = rawToExistential(info)
+ // println("cooking type: "+ this +": "+ info +" to "+ tpe1)
+ if (tpe1 ne info) {
+ setInfo(tpe1)
+ }
+ }
+
def cloneSymbolImpl(owner: Symbol): Symbol =
new TypeSymbol(owner, pos, name)
@@ -2034,6 +2051,7 @@ trait Symbols {
override def reset(completer: Type) {}
override def info: Type = NoType
override def rawInfo: Type = NoType
+ protected def doCookJavaRawInfo() {}
override def accessBoundary(base: Symbol): Symbol = RootClass
def cloneSymbolImpl(owner: Symbol): Symbol = throw new Error()
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
index c4a3981a51..d945e213c0 100644
--- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
@@ -955,6 +955,8 @@ abstract class RefChecks extends InfoTransform {
private def checkTypeRef(tp: Type, pos: Position) = tp match {
case TypeRef(pre, sym, args) =>
checkDeprecated(sym, pos)
+ if(sym.hasFlag(JAVA))
+ sym.typeParams foreach (_.cookJavaRawInfo())
if (!tp.isHigherKinded)
checkBounds(pre, sym.owner, sym.typeParams, args, pos)
case _ =>