diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala index 2d7cda767..7c2294c45 100644 --- a/src/compiler/scala/tools/nsc/symtab/Types.scala +++ b/src/compiler/scala/tools/nsc/symtab/Types.scala @@ -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 diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index e5cb97980..af580b136 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 {