Skip to content

Commit 60d36ab

Browse files
committed
Don't simplify lubs when unpickling Ifs
I was not able to find out why that's the case, but the original test case with the import in the function body requires that if's are _not_ simplified by Unpickler. The interaction with lubs and unsafenulls seems to be very tricky. Anyway, we now have two versions of all test cases, with local as well as globak unsafe nulls.
1 parent 0bf7e62 commit 60d36ab

File tree

2 files changed

+28
-12
lines changed

2 files changed

+28
-12
lines changed

compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,13 +1236,12 @@ class TreeUnpickler(reader: TastyReader,
12361236
val expansion = exprReader.readTerm() // need bindings in scope, so needs to be read before
12371237
Inlined(call, bindings, expansion)
12381238
case IF =>
1239-
simplifyLub(
1240-
if (nextByte == INLINE) {
1241-
readByte()
1242-
InlineIf(readTerm(), readTerm(), readTerm())
1243-
}
1244-
else
1245-
If(readTerm(), readTerm(), readTerm()))
1239+
if (nextByte == INLINE) {
1240+
readByte()
1241+
InlineIf(readTerm(), readTerm(), readTerm())
1242+
}
1243+
else
1244+
If(readTerm(), readTerm(), readTerm())
12461245
case LAMBDA =>
12471246
val meth = readTerm()
12481247
val tpt = ifBefore(end)(readTpt(), EmptyTree)

tests/pos/i15097.scala

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,30 @@
1-
import scala.language.unsafeNulls
2-
class C {
1+
class C:
32
def g: String | Null = ???
43

54
def f =
5+
import scala.language.unsafeNulls
66
try g catch case _ => ""
77

8-
def f2 = if ??? then g else ""
8+
def f2 =
9+
import scala.language.unsafeNulls
10+
if ??? then g else ""
911

10-
def f3 = (??? : Boolean) match
12+
def f3 =
13+
(??? : Boolean) match
14+
case true => g
15+
case _ => ""
16+
17+
class C2:
18+
import scala.language.unsafeNulls
19+
def g: String | Null = ???
20+
21+
def f =
22+
try g catch case _ => ""
23+
24+
def f2 =
25+
if ??? then g else ""
26+
27+
def f3 =
28+
(??? : Boolean) match
1129
case true => g
1230
case _ => ""
13-
}

0 commit comments

Comments
 (0)