Skip to content

Commit 78488cb

Browse files
committed
Always fully define the types of lifted expressions
Fixes #822
1 parent bea9aa2 commit 78488cb

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

src/dotty/tools/dotc/typer/EtaExpansion.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import Decorators._
1313
import Names._
1414
import StdNames._
1515
import Trees._
16+
import Inferencing._
1617
import util.Positions._
1718
import collection.mutable
1819

@@ -24,7 +25,8 @@ object EtaExpansion {
2425
if (isPureExpr(expr)) expr
2526
else {
2627
val name = ctx.freshName(prefix).toTermName
27-
val sym = ctx.newSymbol(ctx.owner, name, EmptyFlags, expr.tpe.widen, coord = positionCoord(expr.pos))
28+
val liftedType = fullyDefinedType(expr.tpe.widen, "lifted expression", expr.pos)
29+
val sym = ctx.newSymbol(ctx.owner, name, EmptyFlags, liftedType, coord = positionCoord(expr.pos))
2830
defs += ValDef(sym, expr)
2931
ref(sym.valRef)
3032
}

test/dotc/tests.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class tests extends CompilerTest {
5353
// This directory doesn't exist anymore
5454
// @Test def pickle_pickling = compileDir(coreDir, "pickling", testPickling)
5555
@Test def pickle_ast = compileDir(dotcDir, "ast", testPickling)
56+
@Test def pickle_inf = compileFile(posDir, "pickleinf", testPickling)
5657

5758
//@Test def pickle_core = compileDir(dotcDir, "core", testPickling, xerrors = 2) // two spurious comparison errors in Types and TypeOps
5859

tests/pos/pickleinf.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class Bar[N] {
2+
def bar(name: N, dummy: Int = 42): N = name
3+
}
4+
5+
object Test {
6+
def test(): Unit = {
7+
(new Bar).bar(10)
8+
}
9+
}

0 commit comments

Comments
 (0)