From 261a8076558d98dbf1311ec6b1db6dbb10f8e9c9 Mon Sep 17 00:00:00 2001 From: Adriaan Moors Date: Fri, 13 Nov 2009 12:17:50 +0000 Subject: fixed #1236 another Symbol::tpe bites the dust (should'be been tpeHK) --- src/compiler/scala/tools/nsc/symtab/Types.scala | 21 +++++++++++---------- .../scala/tools/nsc/typechecker/Infer.scala | 2 +- test/files/pos/t1236.scala | 14 ++++++++++++++ 3 files changed, 26 insertions(+), 11 deletions(-) create mode 100644 test/files/pos/t1236.scala diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala index 6145c4a0d7..35afe7cf5f 100644 --- a/src/compiler/scala/tools/nsc/symtab/Types.scala +++ b/src/compiler/scala/tools/nsc/symtab/Types.scala @@ -1988,16 +1988,17 @@ A type's typeSymbol should never be inspected directly. case class AntiPolyType(pre: Type, targs: List[Type]) extends Type { override def safeToString = pre.toString + targs.mkString("(with type arguments ", ",", ")"); - override def memberType(sym: Symbol) = pre.memberType(sym) match { - case PolyType(tparams, restp) => - restp.subst(tparams, targs) -/* I don't think this is needed, as existential types close only over value types - case ExistentialType(tparams, qtpe) => - existentialAbstraction(tparams, qtpe.memberType(sym)) -*/ - case ErrorType => - ErrorType - } + override def memberType(sym: Symbol) = appliedType(pre.memberType(sym), targs) +// override def memberType(sym: Symbol) = pre.memberType(sym) match { +// case PolyType(tparams, restp) => +// restp.subst(tparams, targs) +// /* I don't think this is needed, as existential types close only over value types +// case ExistentialType(tparams, qtpe) => +// existentialAbstraction(tparams, qtpe.memberType(sym)) +// */ +// case ErrorType => +// ErrorType +// } override def kind = "AntiPolyType" } diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala index 0c3e34f8c5..69407ef0f1 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala @@ -1736,7 +1736,7 @@ trait Infer { if (sym.hasFlag(OVERLOADED)) { val tparams = new AsSeenFromMap(pre, sym.alternatives.head.owner).mapOver( sym.alternatives.head.typeParams) - val bounds = tparams map (_.tpe) //@M TODO: might be affected by change to tpe in Symbol + val bounds = tparams map (_.tpeHK) // see e.g., #1236 val tpe = PolyType(tparams, OverloadedType(AntiPolyType(pre, bounds), sym.alternatives)) diff --git a/test/files/pos/t1236.scala b/test/files/pos/t1236.scala new file mode 100644 index 0000000000..5e221ce411 --- /dev/null +++ b/test/files/pos/t1236.scala @@ -0,0 +1,14 @@ +trait Empty[E[_]] { + def e[A]: E[A] +} + +object T { + val ListEmpty = new Empty[List] { + def e[A] = Nil + } + + def foo[F[_]](q:(String,String)) = "hello" + def foo[F[_]](e: Empty[F]) = "world" + + val x = foo[List](ListEmpty) +} \ No newline at end of file -- cgit v1.2.3