File tree Expand file tree Collapse file tree 4 files changed +43
-8
lines changed
compiler/src/dotty/tools/dotc/ast Expand file tree Collapse file tree 4 files changed +43
-8
lines changed Original file line number Diff line number Diff line change @@ -203,13 +203,7 @@ object desugar {
203203 * def f$default$1[T] = 1
204204 * def f$default$2[T](x: Int) = x + "m"
205205 *
206- * 3. Convert <: T to : T in specializing inline methods. E.g.
207- *
208- * inline def f(x: Boolean) <: Any = if (x) 1 else ""
209- * ==>
210- * inline def f(x: Boolean): Any = if (x) 1 else ""
211- *
212- * 4. Upcast non-specializing inline methods. E.g.
206+ * 3. Upcast non-specializing inline methods. E.g.
213207 *
214208 * inline def f(x: Boolean): Any = if (x) 1 else ""
215209 * ==>
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ object Test {
22
33 inline def h (x : Boolean ) = if (x) 1 else " "
44 val z = h(true )
5- val zc : Int = z
5+ val zc : Int = z // error
66
77 inline def g <: Any = 1
88 val y = g
Original file line number Diff line number Diff line change 1+ transparent def bar : Any = 2 // error: transparent can be used only with inline
2+
3+ object test1 :
4+
5+ def x : Int = baz(true ) // error: type mismatch
6+ inline def baz (x : Boolean ): Any =
7+ if x then 1 else " "
8+ inline def bam (x : Boolean ): Any =
9+ if x then 1 else " "
10+ def y : Int = bam(true ) // error: type mismatch
11+
12+ object test2 :
13+
14+ def x : 1 = baz(true ) // OK
15+ transparent inline def baz (x : Boolean ) =
16+ if x then 1 else " "
17+ transparent inline def bam (x : Boolean ) =
18+ if x then 1 else " "
19+ def y : 1 = bam(true ) // OK
20+
21+ object test3 :
22+
23+ def x : Int = baz(true ) // error: type mismatch
24+ inline def baz (x : Boolean ) =
25+ if x then 1 else " "
26+ inline def bam (x : Boolean ) =
27+ if x then 1 else " "
28+ def y : Int = bam(true ) // error: type mismatch
29+
30+ object test4 :
31+
32+ def x : 1 = baz(true ) // OK
33+ transparent inline def baz (x : Boolean ): Any =
34+ if x then 1 else " "
35+ transparent inline def bam (x : Boolean ): Any =
36+ if x then 1 else " "
37+ def y : 1 = bam(true ) // OK
Original file line number Diff line number Diff line change 1+ inline def foo : Any = 1
2+ inline transparent def bar : Any = 2
3+ val x : 2 = bar
4+
You can’t perform that action at this time.
0 commit comments