File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change
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()
Original file line number Diff line number Diff line change
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()
You can’t perform that action at this time.
0 commit comments