Skip to content

Commit 066b1a1

Browse files
committed
Fix for crasher in uncurry.
A small dose of packedType closes SI-4869.
1 parent d7981e7 commit 066b1a1

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/compiler/scala/tools/nsc/transform/UnCurry.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,14 @@ abstract class UnCurry extends InfoTransform
271271
def missingCaseCall(scrutinee: Tree): Tree = Apply(Select(This(anonClass), nme.missingCase), List(scrutinee))
272272

273273
def applyMethodDef() = {
274-
val body =
274+
val body = localTyper.typedPos(fun.pos) {
275275
if (isPartial) gen.mkUncheckedMatch(gen.withDefaultCase(fun.body, missingCaseCall))
276276
else fun.body
277-
DefDef(Modifiers(FINAL), nme.apply, Nil, List(fun.vparams), TypeTree(restpe), body) setSymbol applyMethod
277+
}
278+
// Have to repack the type to avoid mismatches when existentials
279+
// appear in the result - see SI-4869.
280+
val applyResultType = localTyper.packedType(body, applyMethod)
281+
DefDef(Modifiers(FINAL), nme.apply, Nil, List(fun.vparams), TypeTree(applyResultType), body) setSymbol applyMethod
278282
}
279283
def isDefinedAtMethodDef() = {
280284
val isDefinedAtName = {

test/files/pos/t4869.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// /scala/trac/4869/a.scala
2+
// Wed Jan 4 21:17:29 PST 2012
3+
4+
class C[T]
5+
class A {
6+
def f[T](x: T): C[_ <: T] = null
7+
def g = List(1d) map f
8+
}

0 commit comments

Comments
 (0)