Skip to content

Commit 09daa51

Browse files
Merge pull request #12545 from dotty-staging/fix-12544
Fix #12544: Add test
2 parents c1f0a56 + ecf97e8 commit 09daa51

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

tests/init/neg/i12544.scala

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
enum Enum:
2+
case Case
3+
case Case2(x: Int)
4+
5+
def g(b: Enum.B): Int = b.foo()
6+
7+
object Enum:
8+
object nested:
9+
val a: Enum = Case
10+
11+
val b: Enum = f(nested.a)
12+
13+
def f(e: Enum): Enum = e
14+
15+
class B() { def foo() = n + 1 }
16+
g(new B()) // error
17+
val n: Int = 10
18+
19+
@main def main(): Unit = println(Enum.b)

tests/init/pos/i12544.scala

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
enum Enum:
2+
case Case
3+
4+
object Enum:
5+
object nested:
6+
val a: Enum = Case
7+
8+
val b: Enum = f(nested.a)
9+
10+
def f(e: Enum): Enum = e
11+
12+
@main def main(): Unit = println(Enum.b)

0 commit comments

Comments
 (0)