File tree 9 files changed +46
-2
lines changed
compiler/src/dotty/tools/dotc/inlines
9 files changed +46
-2
lines changed Original file line number Diff line number Diff line change @@ -1046,9 +1046,9 @@ class Inliner(val call: tpd.Tree)(using Context):
1046
1046
new TreeAccumulator [List [Symbol ]] {
1047
1047
private var level = - 1
1048
1048
override def apply (syms : List [Symbol ], tree : tpd.Tree )(using Context ): List [Symbol ] =
1049
- if ( level != - 1 ) foldOver(syms, tree)
1049
+ if level != - 1 then foldOver(syms, tree)
1050
1050
else tree match {
1051
- case tree : RefTree if level == - 1 && tree.symbol.isDefinedInCurrentRun && ! tree.symbol.isLocal =>
1051
+ case tree : RefTree if tree.isTerm && tree.symbol.isDefinedInCurrentRun && ! tree.symbol.isLocal =>
1052
1052
foldOver(tree.symbol :: syms, tree)
1053
1053
case Quoted (body) =>
1054
1054
level += 1
@@ -1062,6 +1062,8 @@ class Inliner(val call: tpd.Tree)(using Context):
1062
1062
level -= 1
1063
1063
try apply(syms, body)
1064
1064
finally level += 1
1065
+ case _ : TypTree =>
1066
+ syms
1065
1067
case _ =>
1066
1068
foldOver(syms, tree)
1067
1069
}
Original file line number Diff line number Diff line change
1
+ import scala .quoted .*
2
+
3
+ class Wrapper [T ](t : T ):
4
+ inline def showType : String = $ { Wrapper .showTypeImpl[T ]}
5
+
6
+ object Wrapper :
7
+ def showTypeImpl [U ](using Quotes ): Expr [String ] = Expr (" foo" )
Original file line number Diff line number Diff line change
1
+ class Person
2
+
3
+ def test = Wrapper (new Person ).showType
Original file line number Diff line number Diff line change
1
+ import scala .quoted .*
2
+
3
+ class Wrapper [T ](t : T ):
4
+ inline def showType : String = $ { Wrapper .showTypeImpl[T ]}
5
+
6
+ object Wrapper :
7
+ def showTypeImpl [U ](using Quotes ): Expr [String ] = Expr (" foo" )
Original file line number Diff line number Diff line change
1
+ class Person
2
+
3
+ def test = Wrapper (new Person ).showType
Original file line number Diff line number Diff line change
1
+ import scala .quoted .*
2
+
3
+
4
+ class Wrapper [T ](t : T ):
5
+ inline def nothing : T = $ { Wrapper .nothing : Expr [T ] }
6
+
7
+ object Wrapper :
8
+ def nothing (using Quotes ): Expr [Nothing ] = ' {??? }
Original file line number Diff line number Diff line change
1
+ class Person
2
+
3
+ def test = Wrapper (new Person ).nothing
Original file line number Diff line number Diff line change
1
+ import scala .quoted .*
2
+
3
+
4
+ class Wrapper [T ](t : T ):
5
+ inline def emptyList : List [T ] = $ { Wrapper .emptyListImpl : Expr [List [T ]] }
6
+
7
+ object Wrapper :
8
+ def emptyListImpl (using Quotes ): Expr [List [Nothing ]] = Expr (Nil )
Original file line number Diff line number Diff line change
1
+ class Person
2
+
3
+ def test = Wrapper (new Person ).emptyList
You can’t perform that action at this time.
0 commit comments