summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/transform/UnCurry.scala8
-rw-r--r--test/files/pos/t4869.scala8
2 files changed, 14 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
index 4ae4042cc7..2e2ff23881 100644
--- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala
+++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
@@ -271,10 +271,14 @@ abstract class UnCurry extends InfoTransform
def missingCaseCall(scrutinee: Tree): Tree = Apply(Select(This(anonClass), nme.missingCase), List(scrutinee))
def applyMethodDef() = {
- val body =
+ val body = localTyper.typedPos(fun.pos) {
if (isPartial) gen.mkUncheckedMatch(gen.withDefaultCase(fun.body, missingCaseCall))
else fun.body
- DefDef(Modifiers(FINAL), nme.apply, Nil, List(fun.vparams), TypeTree(restpe), body) setSymbol applyMethod
+ }
+ // Have to repack the type to avoid mismatches when existentials
+ // appear in the result - see SI-4869.
+ val applyResultType = localTyper.packedType(body, applyMethod)
+ DefDef(Modifiers(FINAL), nme.apply, Nil, List(fun.vparams), TypeTree(applyResultType), body) setSymbol applyMethod
}
def isDefinedAtMethodDef() = {
val isDefinedAtName = {
diff --git a/test/files/pos/t4869.scala b/test/files/pos/t4869.scala
new file mode 100644
index 0000000000..f84aa4ed07
--- /dev/null
+++ b/test/files/pos/t4869.scala
@@ -0,0 +1,8 @@
+// /scala/trac/4869/a.scala
+// Wed Jan 4 21:17:29 PST 2012
+
+class C[T]
+class A {
+ def f[T](x: T): C[_ <: T] = null
+ def g = List(1d) map f
+}