Skip to content

Commit 1762f23

Browse files
Merge pull request #6195 from dotty-staging/refactor-tasty-reflection-compiler-implementation
Implement `tasty.Reflection` in the library
2 parents 4705df2 + 88c973b commit 1762f23

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

compiler/src/dotty/tools/dotc/tastyreflect/ReflectionImpl.scala

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ object ReflectionImpl {
1010
apply(rootContext, SourcePosition(rootContext.source, Spans.NoSpan))
1111

1212
def apply(rootContext: Contexts.Context, rootPosition: SourcePosition): scala.tasty.Reflection =
13-
new ReflectionImpl(new KernelImpl(rootContext, rootPosition))
13+
new scala.tasty.Reflection(new KernelImpl(rootContext, rootPosition))
1414

1515
def showTree(tree: tpd.Tree)(implicit ctx: Contexts.Context): String = {
16-
val refl = new ReflectionImpl(new KernelImpl(ctx, tree.sourcePos))
17-
new refl.SourceCodePrinter().showTree(tree)
16+
val refl = new scala.tasty.Reflection(new KernelImpl(ctx, tree.sourcePos))
17+
val reflCtx = ctx.asInstanceOf[refl.Context]
18+
val reflTree = tree.asInstanceOf[refl.Tree]
19+
new refl.SourceCodePrinter().showTree(reflTree)(reflCtx)
1820
}
1921

20-
private class ReflectionImpl(val kernel: KernelImpl) extends scala.tasty.Reflection
21-
2222
}

library/src/scala/tasty/Reflection.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package scala.tasty
22

33
import scala.tasty.reflect._
44

5-
abstract class Reflection
5+
class Reflection(val kernel: Kernel)
66
extends Core
77
with ConstantOps
88
with ContextOps

0 commit comments

Comments
 (0)