Skip to content

Commit b25d17c

Browse files
Merge pull request #6975 from dotty-staging/rename-tasty-kernel
Rename TASTy reflect Kernel to Internal
2 parents 61c81ba + 7c231cc commit b25d17c

24 files changed

+744
-744
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ import scala.quoted.show.SyntaxHighlight
99
object ReflectionImpl {
1010

1111
def apply(rootContext: Contexts.Context): scala.tasty.Reflection =
12-
new scala.tasty.Reflection(new KernelImpl(rootContext))
12+
new scala.tasty.Reflection(new ReflectionCompilerInterface(rootContext))
1313

1414
def showTree(tree: tpd.Tree)(implicit ctx: Contexts.Context): String = {
15-
val refl = new scala.tasty.Reflection(new KernelImpl(MacroExpansion.context(tree)))
15+
val refl = new scala.tasty.Reflection(new ReflectionCompilerInterface(MacroExpansion.context(tree)))
1616
val reflCtx = ctx.asInstanceOf[refl.Context]
1717
val reflTree = tree.asInstanceOf[refl.Tree]
1818
val syntaxHighlight =

compiler/src/dotty/tools/dotc/tastyreflect/KernelImpl.scala renamed to compiler/src/dotty/tools/dotc/tastyreflect/ReflectionInternal.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ import dotty.tools.dotc.parsing.Parsers.Parser
1616
import dotty.tools.dotc.typer.Implicits.{AmbiguousImplicits, DivergingImplicit, NoMatchingImplicits, SearchFailure, SearchFailureType}
1717
import dotty.tools.dotc.util.{SourceFile, SourcePosition, Spans}
1818

19-
import scala.tasty.reflect.Kernel
19+
import scala.tasty.reflect.CompilerInterface
2020

21-
class KernelImpl(val rootContext: core.Contexts.Context) extends Kernel {
21+
class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extends CompilerInterface {
2222
import tpd._
2323

2424
private implicit def ctx: core.Contexts.Context = rootContext

library/src-bootstrapped/scala/internal/quoted/Matcher.scala

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ object Matcher {
5151
def hasBindAnnotation(sym: Symbol) = sym.annots.exists(isBindAnnotation)
5252

5353
def isBindAnnotation(tree: Tree): Boolean = tree match {
54-
case New(tpt) => tpt.symbol == kernel.Definitions_InternalQuoted_patternBindHoleAnnot
55-
case annot => annot.symbol.owner == kernel.Definitions_InternalQuoted_patternBindHoleAnnot
54+
case New(tpt) => tpt.symbol == internal.Definitions_InternalQuoted_patternBindHoleAnnot
55+
case annot => annot.symbol.owner == internal.Definitions_InternalQuoted_patternBindHoleAnnot
5656
}
5757

5858
/** Check that all trees match with `mtch` and concatenate the results with && */
@@ -102,14 +102,14 @@ object Matcher {
102102

103103
// Match a scala.internal.Quoted.patternHole typed as a repeated argument and return the scrutinee tree
104104
case (IsTerm(scrutinee @ Typed(s, tpt1)), Typed(TypeApply(patternHole, tpt :: Nil), tpt2))
105-
if patternHole.symbol == kernel.Definitions_InternalQuoted_patternHole &&
105+
if patternHole.symbol == internal.Definitions_InternalQuoted_patternHole &&
106106
s.tpe <:< tpt.tpe &&
107107
tpt2.tpe.derivesFrom(definitions.RepeatedParamClass) =>
108108
matched(scrutinee.seal)
109109

110110
// Match a scala.internal.Quoted.patternHole and return the scrutinee tree
111111
case (IsTerm(scrutinee), TypeApply(patternHole, tpt :: Nil))
112-
if patternHole.symbol == kernel.Definitions_InternalQuoted_patternHole &&
112+
if patternHole.symbol == internal.Definitions_InternalQuoted_patternHole &&
113113
scrutinee.tpe <:< tpt.tpe =>
114114
matched(scrutinee.seal)
115115

@@ -142,7 +142,7 @@ object Matcher {
142142
fn1 =#= fn2 && args1 =##= args2
143143

144144
case (Block(stats1, expr1), Block(binding :: stats2, expr2)) if isTypeBinding(binding) =>
145-
qctx.tasty.kernel.Context_GADT_addToConstraint(the[Context])(binding.symbol :: Nil)
145+
qctx.tasty.internal.Context_GADT_addToConstraint(the[Context])(binding.symbol :: Nil)
146146
matched(new SymBinding(binding.symbol)) && Block(stats1, expr1) =#= Block(stats2, expr2)
147147

148148
case (Block(stat1 :: stats1, expr1), Block(stat2 :: stats2, expr2)) =>
@@ -152,7 +152,7 @@ object Matcher {
152152

153153
case (scrutinee, Block(typeBindings, expr2)) if typeBindings.forall(isTypeBinding) =>
154154
val bindingSymbols = typeBindings.map(_.symbol)
155-
qctx.tasty.kernel.Context_GADT_addToConstraint(the[Context])(bindingSymbols)
155+
qctx.tasty.internal.Context_GADT_addToConstraint(the[Context])(bindingSymbols)
156156
bindingSymbols.foldRight(scrutinee =#= expr2)((x, acc) => matched(new SymBinding(x)) && acc)
157157

158158
case (If(cond1, thenp1, elsep1), If(cond2, thenp2, elsep2)) =>
@@ -336,13 +336,13 @@ object Matcher {
336336

337337
val res = {
338338
if (hasTypeSplices) {
339-
implicit val ctx: Context = qctx.tasty.kernel.Context_GADT_setFreshGADTBounds(rootContext)
339+
implicit val ctx: Context = qctx.tasty.internal.Context_GADT_setFreshGADTBounds(rootContext)
340340
val matchings = scrutineeExpr.unseal.underlyingArgument =#= patternExpr.unseal.underlyingArgument
341341
// After matching and doing all subtype check, we have to aproximate all the type bindings
342342
// that we have found and seal them in a quoted.Type
343343
matchings.asOptionOfTuple.map { tup =>
344344
Tuple.fromArray(tup.toArray.map { // TODO improve performace
345-
case x: SymBinding => kernel.Context_GADT_approximation(the[Context])(x.sym, true).seal
345+
case x: SymBinding => internal.Context_GADT_approximation(the[Context])(x.sym, true).seal
346346
case x => x
347347
})
348348
}

library/src/scala/quoted/Expr.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ package quoted {
3939
/** Beta-reduces the function appication. Generates the an expression only containing the body of the function */
4040
def apply[G] given (tg: TupledFunction[G, TupleOfExpr[Args] => Expr[R]]): G = {
4141
import qctx.tasty._
42-
tg.untupled(args => qctx.tasty.kernel.betaReduce(f.unseal, args.toArray.toList.map(_.asInstanceOf[QuoteContext => Expr[_]](qctx).unseal)).seal.asInstanceOf[Expr[R]])
42+
tg.untupled(args => qctx.tasty.internal.betaReduce(f.unseal, args.toArray.toList.map(_.asInstanceOf[QuoteContext => Expr[_]](qctx).unseal)).seal.asInstanceOf[Expr[R]])
4343
}
4444
}
4545

4646
implicit class AsContextualFunction[F, Args <: Tuple, R](f: Expr[F]) given (tf: TupledFunction[F, given Args => R], qctx: QuoteContext) {
4747
/** Beta-reduces the function appication. Generates the an expression only containing the body of the function */
4848
def apply[G] given (tg: TupledFunction[G, TupleOfExpr[Args] => Expr[R]]): G = {
4949
import qctx.tasty._
50-
tg.untupled(args => qctx.tasty.kernel.betaReduce(f.unseal, args.toArray.toList.map(_.asInstanceOf[QuoteContext => Expr[_]](qctx).unseal)).seal.asInstanceOf[Expr[R]])
50+
tg.untupled(args => qctx.tasty.internal.betaReduce(f.unseal, args.toArray.toList.map(_.asInstanceOf[QuoteContext => Expr[_]](qctx).unseal)).seal.asInstanceOf[Expr[R]])
5151
}
5252
}
5353

library/src/scala/tasty/Reflection.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package scala.tasty
22

33
import scala.tasty.reflect._
44

5-
class Reflection(val kernel: Kernel)
5+
class Reflection(private[scala] val internal: CompilerInterface)
66
extends Core
77
with ConstantOps
88
with ContextOps
@@ -37,7 +37,7 @@ class Reflection(val kernel: Kernel)
3737
*
3838
* The code should be a sequence of expressions or statements that may appear in a block.
3939
*/
40-
def typeChecks(code: String)(implicit ctx: Context): Boolean = kernel.typeChecks(code)
40+
def typeChecks(code: String)(implicit ctx: Context): Boolean = internal.typeChecks(code)
4141
}
4242

4343
}

library/src/scala/tasty/reflect/CommentOps.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ trait CommentOps extends Core {
55
implicit class CommentAPI(self: Comment) {
66

77
/** Raw comment string */
8-
def raw: String = kernel.Comment_raw(self)
8+
def raw: String = internal.Comment_raw(self)
99

1010
/** Expanded comment string, if any */
11-
def expanded: Option[String] = kernel.Comment_expanded(self)
11+
def expanded: Option[String] = internal.Comment_expanded(self)
1212

1313
/** List of usecases and their corresponding trees, if any */
14-
def usecases: List[(String, Option[DefDef])] = kernel.Comment_usecases(self)
14+
def usecases: List[(String, Option[DefDef])] = internal.Comment_usecases(self)
1515

1616
}
1717

library/src/scala/tasty/reflect/ConstantOps.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,27 @@ package reflect
44
trait ConstantOps extends Core {
55

66
implicit class ConstantAPI(const: Constant) {
7-
def value: Any = kernel.Constant_value(const)
7+
def value: Any = internal.Constant_value(const)
88
}
99

1010
/** Module of Constant literals */
1111
object Constant {
1212

1313
def apply(x: Unit | Null | Int | Boolean | Byte | Short | Int | Long | Float | Double | Char | String | Type): Constant =
14-
kernel.Constant_apply(x)
14+
internal.Constant_apply(x)
1515

1616
def unapply(constant: Constant): Option[Unit | Null | Int | Boolean | Byte | Short | Int | Long | Float | Double | Char | String | Type] =
17-
kernel.matchConstant(constant)
17+
internal.matchConstant(constant)
1818

1919
/** Module of ClassTag literals */
2020
object ClassTag {
2121
/** scala.reflect.ClassTag literal */
2222
def apply[T] given (x: Type): Constant =
23-
kernel.Constant_ClassTag_apply(x)
23+
internal.Constant_ClassTag_apply(x)
2424

2525
/** Extractor for ClassTag literals */
2626
def unapply(constant: Constant): Option[Type] =
27-
kernel.matchConstant_ClassTag(constant)
27+
internal.matchConstant_ClassTag(constant)
2828
}
2929
}
3030
}

library/src/scala/tasty/reflect/ContextOps.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ trait ContextOps extends Core {
55

66
implicit class ContextAPI(self: Context) {
77
/** Returns the owner of the context */
8-
def owner: Symbol = kernel.Context_owner(self)
8+
def owner: Symbol = internal.Context_owner(self)
99

1010
/** Returns the source file being compiled. The path is relative to the current working directory. */
11-
def source: java.nio.file.Path = kernel.Context_source(self)
11+
def source: java.nio.file.Path = internal.Context_source(self)
1212

1313
}
1414

1515
/** Context of the macro expansion */
16-
implicit def rootContext: Context = kernel.rootContext
16+
implicit def rootContext: Context = internal.rootContext
1717

1818
}

0 commit comments

Comments
 (0)