Skip to content

Commit fd2a03e

Browse files
authored
Re-lub also hard union types in simplify (#20027)
Simplify had some elaborate condition that prevented hard union types to be recomputed with a lub. I am not sure why that was. In the concrete scenario of i10693.scala, we had an explicitly written union result type `B | A` where `A` and `B` are type parameters. So that is a hard union type. Then `A` was instantiated to `Int | String` and `B` was instantiated to `String | Int`. Re-forming the lub of that union would have eliminated one pair, but since the union type was hard that was not done. On the other hand I see no reason why hard unions should not be re-lubbed. Hard unions are about preventing the widening of or types with a join. I don't see a connection with avoiding re-lubbing. Fixes #10693
2 parents 6e17c0e + 5a15892 commit fd2a03e

File tree

1 file changed

+16
-0
lines changed
  • compiler/test-resources/repl

1 file changed

+16
-0
lines changed

Diff for: compiler/test-resources/repl/10693

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
scala> def test[A, B](a: A, b: B): A | B = a
2+
def test[A, B](a: A, b: B): A | B
3+
scala> def d0 = test("string", 1)
4+
def d0: String | Int
5+
scala> def d1 = test(1, "string")
6+
def d1: Int | String
7+
scala> def d2 = test(d0, d1)
8+
def d2: String | Int
9+
scala> def d3 = test(d1, d0)
10+
def d3: Int | String
11+
scala> def d4 = test(d2, d3)
12+
def d4: String | Int
13+
scala> def d5 = test(d3, d2)
14+
def d5: Int | String
15+
scala> def d6 = test(d4, d5)
16+
def d6: String | Int

0 commit comments

Comments
 (0)