fixed #1428, plus stopgap fix for #1438

git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@16306 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
This commit is contained in:
odersky 2008-10-21 14:25:46 +00:00
parent b378ec2523
commit b31649fbca
2 changed files with 10 additions and 4 deletions

View File

@ -63,7 +63,7 @@ trait Types {
self: SymbolTable =>
import definitions._
//statistics
var singletonBaseTypeSeqCount = 0
var compoundBaseTypeSeqCount = 0
@ -1560,8 +1560,8 @@ A type's typeSymbol should never be inspected directly.
return "=> " + args(0).toString
if (isFunctionType(this))
return normalize.typeArgs.init.mkString("(", ", ", ")") + " => " + normalize.typeArgs.last
if (isTupleType(this))
return args.mkString("(", ", ", if (args.length == 1) ",)" else ")")
if (isTupleType(this))
return normalize.typeArgs.mkString("(", ", ", if (normalize.typeArgs.length == 1) ",)" else ")")
if (sym.isAliasType && (prefixChain exists (_.termSymbol hasFlag SYNTHETIC))) {
val normed = normalize;
if (normed ne this) return normed.toString

View File

@ -2560,10 +2560,16 @@ trait Typers { self: Analyzer =>
fun.symbol == Any_isInstanceOf && !targs.isEmpty)
checkCheckable(tree.pos, targs.head, "")
val resultpe0 = restpe.instantiateTypeParams(tparams, targs)
//println("instantiating type params "+restpe+" "+tparams+" "+targs+" = "+resultpe0)
//@M TODO -- probably ok
//@M example why asSeenFrom is necessary: class Foo[a] { def foo[m[x]]: m[a] } (new Foo[Int]).foo[List] : List[Int]
//@M however, asSeenFrom widens a singleton type, thus cannot use it for those types
val resultpe = if (resultpe0.isInstanceOf[SingletonType]) resultpe0 else resultpe0.asSeenFrom(prefixType(fun), fun.symbol.owner)
// Martin to Adriaan: This is a mess in need of cleanup. For now I have simply speacial treated HK types, bit this is still wrong.
val resultpe =
if (resultpe0.isInstanceOf[SingletonType] || !targs.exists(_.isHigherKinded))
resultpe0
else
resultpe0.asSeenFrom(prefixType(fun), fun.symbol.owner)
copy.TypeApply(tree, fun, args) setType resultpe
}
} else {