File tree Expand file tree Collapse file tree 5 files changed +38
-1
lines changed
compiler/src/dotty/tools/dotc/tastyreflect Expand file tree Collapse file tree 5 files changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -1215,6 +1215,9 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend
1215
1215
tpNoRefinement != self && defn.isNonRefinedFunction(tpNoRefinement)
1216
1216
}
1217
1217
1218
+ def Type_select (self : Type )(sym : Symbol )(using ctx : Context ): Type =
1219
+ self.select(sym)
1220
+
1218
1221
type ConstantType = Types .ConstantType
1219
1222
1220
1223
def isInstanceOfConstantType (using ctx : Context ): IsInstanceOf [ConstantType ] = new {
Original file line number Diff line number Diff line change @@ -1678,6 +1678,9 @@ class Reflection(private[scala] val internal: CompilerInterface) { self =>
1678
1678
* @see `isFunctionType`
1679
1679
*/
1680
1680
def isDependentFunctionType (using ctx : Context ): Boolean = internal.Type_isDependentFunctionType (self)
1681
+
1682
+ /** The type <this . sym>, reduced if possible */
1683
+ def select (sym : Symbol )(using ctx : Context ): Type = internal.Type_select (self)(sym)
1681
1684
}
1682
1685
1683
1686
given (using ctx : Context ) as IsInstanceOf [Type ] = internal.isInstanceOfType
Original file line number Diff line number Diff line change @@ -885,7 +885,6 @@ trait CompilerInterface {
885
885
*/
886
886
def Type_isFunctionType (self : Type )(using ctx : Context ): Boolean
887
887
888
-
889
888
/** Is this type an context function type?
890
889
*
891
890
* @see `Type_isFunctionType`
@@ -904,6 +903,9 @@ trait CompilerInterface {
904
903
*/
905
904
def Type_isDependentFunctionType (self : Type )(using ctx : Context ): Boolean
906
905
906
+ /** The type <this . sym>, reduced if possible */
907
+ def Type_select (self : Type )(sym : Symbol )(using ctx : Context ): Type
908
+
907
909
/** A singleton type representing a known constant value */
908
910
type ConstantType <: Type
909
911
Original file line number Diff line number Diff line change
1
+ case class Foo [A ](a : A )
2
+
3
+ object Test {
4
+
5
+ import scala .quoted ._
6
+
7
+ def impl [T ](t : T )(using qctx : QuoteContext , tt : Type [T ]): Expr [Any ] = {
8
+
9
+ import qctx .tasty ._
10
+ import util ._
11
+
12
+ val foo = typeOf[Foo [String ]]
13
+ val symbol = foo.typeSymbol.field(" a" )
14
+ val a = foo.select(symbol)
15
+ assert(a <:< defn.StringType )
16
+
17
+ ' {??? }
18
+ }
19
+
20
+
21
+ inline def apply [T ](inline t : T ) = $ { Test .impl(' t )}
22
+
23
+ }
Original file line number Diff line number Diff line change
1
+
2
+ object Run {
3
+ def test (): Unit = {
4
+ Test [Foo [String ]](Foo (" moo" ))
5
+ }
6
+ }
You can’t perform that action at this time.
0 commit comments