diff options
author | Martin Odersky <odersky@gmail.com> | 2008-10-21 14:25:46 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2008-10-21 14:25:46 +0000 |
commit | 4c9ef158c68d2add782d81ae490e8e32f2cc1b83 (patch) | |
tree | 420b437b3a3fc9522ab950af62a13664101be131 | |
parent | b3057cb638d7ad4ad978d164ff58d838e074ca12 (diff) | |
download | scala-4c9ef158c68d2add782d81ae490e8e32f2cc1b83.tar.gz scala-4c9ef158c68d2add782d81ae490e8e32f2cc1b83.tar.bz2 scala-4c9ef158c68d2add782d81ae490e8e32f2cc1b83.zip |
fixed #1428, plus stopgap fix for #1438
-rw-r--r-- | src/compiler/scala/tools/nsc/symtab/Types.scala | 2 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 8 |
2 files changed, 8 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala index 036bd0735c..0cb94b899f 100644 --- a/src/compiler/scala/tools/nsc/symtab/Types.scala +++ b/src/compiler/scala/tools/nsc/symtab/Types.scala @@ -1561,7 +1561,7 @@ A type's typeSymbol should never be inspected directly. if (isFunctionType(this)) return normalize.typeArgs.init.mkString("(", ", ", ")") + " => " + normalize.typeArgs.last if (isTupleType(this)) - return args.mkString("(", ", ", if (args.length == 1) ",)" else ")") + 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 diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 9c82ffad1f..ee50021da3 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -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 { |