Skip to content

Commit ca98cff

Browse files
committed
Add typeRef and termRef to Reflection
1 parent 68d5d68 commit ca98cff

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

compiler/src/dotty/tools/dotc/quoted/reflect/ReflectionCompilerInterface.scala

+3
Original file line numberDiff line numberDiff line change
@@ -1843,6 +1843,9 @@ class ReflectionCompilerInterface(val rootContext: Context) extends CompilerInte
18431843

18441844
def Symbol_noSymbol(using Context): Symbol = core.Symbols.NoSymbol
18451845

1846+
def Symbol_typeRef(self: Symbol)(using Context): TypeRef = self.typeRef
1847+
1848+
def Symbol_termRef(self: Symbol)(using Context): TermRef = self.termRef
18461849

18471850
///////////
18481851
// FLAGS //

library/src-bootstrapped/scala/quoted/util/ExprMap.scala

+1-5
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,7 @@ trait ExprMap {
6464
val tp = tpt.tpe match
6565
// TODO improve code
6666
case AppliedType(TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "<repeated>"), List(tp0: Type)) =>
67-
// TODO rewrite without using quotes
68-
type T
69-
val qtp: quoted.Type[T] = tp0.seal.asInstanceOf[quoted.Type[T]]
70-
given qtp.type = qtp
71-
'[Seq[T]].unseal.tpe
67+
Symbol.requiredClass("scala.collection.immutable.Seq").typeRef.appliedTo(tp0)
7268
case tp => tp
7369
Typed.copy(tree)(transformTerm(expr, tp), transformTypeTree(tpt))
7470
case tree: NamedArg =>

library/src/scala/internal/tasty/CompilerInterface.scala

+5
Original file line numberDiff line numberDiff line change
@@ -997,6 +997,11 @@ trait CompilerInterface extends scala.tasty.reflect.Types {
997997
/** Case class or case object children of a sealed trait */
998998
def Symbol_children(self: Symbol)(using ctx: Context): List[Symbol]
999999

1000+
/** Type referene to the symbol */
1001+
def Symbol_typeRef(self: Symbol)(using Context): TypeRef
1002+
1003+
/** Term referene to the symbol */
1004+
def Symbol_termRef(self: Symbol)(using Context): TermRef
10001005

10011006
///////////
10021007
// FLAGS //

library/src/scala/tasty/Reflection.scala

+8
Original file line numberDiff line numberDiff line change
@@ -2122,6 +2122,14 @@ trait Reflection extends reflect.Types { reflectSelf: CompilerInterface =>
21222122
def companionModule(using ctx: Context): Symbol =
21232123
reflectSelf.Symbol_companionModule(sym)
21242124

2125+
/** Type referene to the symbol */
2126+
def typeRef(using Context): TypeRef =
2127+
reflectSelf.Symbol_typeRef(sym)
2128+
2129+
/** Term referene to the symbol */
2130+
def termRef(using Context): TermRef =
2131+
reflectSelf.Symbol_termRef(sym)
2132+
21252133
/** Shows the tree as extractors */
21262134
def showExtractors(using ctx: Context): String =
21272135
new ExtractorsPrinter[reflectSelf.type](reflectSelf).showSymbol(sym)

0 commit comments

Comments
 (0)