Skip to content

Commit e599efb

Browse files
Merge pull request #13604 from dotty-staging/fix-11631
add tests for #11631
2 parents a4f2671 + 0aefc4f commit e599efb

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

tests/pos/i11631.scala

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
trait MyTrait:
2+
def a(): String = ""
3+
4+
class Nul
5+
6+
extension [T](x: T | Nul) inline def nnn: x.type & T = ???
7+
8+
class MyClass:
9+
var myTrait: MyTrait|Null = null
10+
11+
def printA(): Unit = println(myTrait.nnn.a())
12+
13+
@main def runTest(): Unit =
14+
val mt = new MyTrait:
15+
override def a(): String = "hello world"
16+
17+
val mc = MyClass()
18+
mc.myTrait = mt
19+
mc.printA()

tests/pos/i11631b.scala

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
trait MyTrait:
2+
def a(): String = ""
3+
4+
class MyClass:
5+
var myTrait: MyTrait|Null = null
6+
7+
def printA(): Unit = println(myTrait.nn.a())
8+
9+
@main def runTest(): Unit =
10+
val mt = new MyTrait:
11+
override def a(): String = "hello world"
12+
13+
val mc = MyClass()
14+
mc.myTrait = mt
15+
mc.printA()

0 commit comments

Comments
 (0)