Skip to content

Commit 9409d66

Browse files
committed
Rename constraint solving internal interface
These methods are only meant to exist for the quote patterns matcher
1 parent 7669c5a commit 9409d66

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,17 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend
5252
def Context_owner(self: Context): Symbol = self.owner
5353

5454

55-
def Context_GADT_setFreshGADTBounds(self: Context): Context =
55+
/////////////////
56+
// Constraints //
57+
/////////////////
58+
59+
def Constraints_init(self: Context): Context =
5660
self.fresh.setFreshGADTBounds.addMode(Mode.GadtConstraintInference)
5761

58-
def Context_GADT_addToConstraint(self: Context)(syms: List[Symbol]): Boolean =
62+
def Constraints_add(self: Context)(syms: List[Symbol]): Boolean =
5963
self.gadt.addToConstraint(syms)
6064

61-
def Context_GADT_approximation(self: Context)(sym: Symbol, fromBelow: Boolean): Type =
65+
def Constraints_approximation(self: Context)(sym: Symbol, fromBelow: Boolean): Type =
6266
self.gadt.approximation(sym, fromBelow)
6367

6468
////////////

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,14 @@ object Matcher {
147147
def termMatch(scrutineeTerm: Term, patternTerm: Term, hasTypeSplices: Boolean): Option[Tuple] = {
148148
given Env = Map.empty
149149
if (hasTypeSplices) {
150-
val ctx: Context = internal.Context_GADT_setFreshGADTBounds(rootContext)
150+
val ctx: Context = internal.Constraints_init(rootContext)
151151
given Context = ctx
152152
val matchings = scrutineeTerm =?= patternTerm
153153
// After matching and doing all subtype checks, we have to approximate all the type bindings
154154
// that we have found and seal them in a quoted.Type
155155
matchings.asOptionOfTuple.map { tup =>
156156
Tuple.fromArray(tup.toArray.map { // TODO improve performance
157-
case x: SymBinding => internal.Context_GADT_approximation(summon[Context])(x.sym, !x.fromAbove).seal
157+
case x: SymBinding => internal.Constraints_approximation(summon[Context])(x.sym, !x.fromAbove).seal
158158
case x => x
159159
})
160160
}
@@ -168,14 +168,14 @@ object Matcher {
168168
def typeTreeMatch(scrutineeTypeTree: TypeTree, patternTypeTree: TypeTree, hasTypeSplices: Boolean): Option[Tuple] = {
169169
given Env = Map.empty
170170
if (hasTypeSplices) {
171-
val ctx: Context = internal.Context_GADT_setFreshGADTBounds(rootContext)
171+
val ctx: Context = internal.Constraints_init(rootContext)
172172
given Context = ctx
173173
val matchings = scrutineeTypeTree =?= patternTypeTree
174174
// After matching and doing all subtype checks, we have to approximate all the type bindings
175175
// that we have found and seal them in a quoted.Type
176176
matchings.asOptionOfTuple.map { tup =>
177177
Tuple.fromArray(tup.toArray.map { // TODO improve performance
178-
case x: SymBinding => internal.Context_GADT_approximation(summon[Context])(x.sym, !x.fromAbove).seal
178+
case x: SymBinding => internal.Constraints_approximation(summon[Context])(x.sym, !x.fromAbove).seal
179179
case x => x
180180
})
181181
}
@@ -323,7 +323,7 @@ object Matcher {
323323
fn1 =?= fn2 &&& args1 =?= args2
324324

325325
case (Block(stats1, expr1), Block(binding :: stats2, expr2)) if isTypeBinding(binding) =>
326-
qctx.tasty.internal.Context_GADT_addToConstraint(summon[Context])(binding.symbol :: Nil)
326+
qctx.tasty.internal.Constraints_add(summon[Context])(binding.symbol :: Nil)
327327
matched(new SymBinding(binding.symbol, hasFromAboveAnnotation(binding.symbol))) &&& Block(stats1, expr1) =?= Block(stats2, expr2)
328328

329329
/* Match block */
@@ -340,7 +340,7 @@ object Matcher {
340340

341341
case (scrutinee, Block(typeBindings, expr2)) if typeBindings.forall(isTypeBinding) =>
342342
val bindingSymbols = typeBindings.map(_.symbol)
343-
qctx.tasty.internal.Context_GADT_addToConstraint(summon[Context])(bindingSymbols)
343+
qctx.tasty.internal.Constraints_add(summon[Context])(bindingSymbols)
344344
bindingSymbols.foldRight(scrutinee =?= expr2)((x, acc) => matched(new SymBinding(x, hasFromAboveAnnotation(x))) &&& acc)
345345

346346
/* Match if */

library/src/scala/tasty/reflect/CompilerInterface.scala

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,13 @@ trait CompilerInterface {
143143
/** Returns the owner of the context */
144144
def Context_owner(self: Context): Symbol
145145

146-
def Context_GADT_setFreshGADTBounds(self: Context): Context
147-
def Context_GADT_addToConstraint(self: Context)(syms: List[Symbol]): Boolean
148-
def Context_GADT_approximation(self: Context)(sym: Symbol, fromBelow: Boolean): Type
146+
/////////////////
147+
// Constraints //
148+
/////////////////
149149

150+
def Constraints_init(self: Context): Context
151+
def Constraints_add(self: Context)(syms: List[Symbol]): Boolean
152+
def Constraints_approximation(self: Context)(sym: Symbol, fromBelow: Boolean): Type
150153

151154
////////////
152155
// Source //

0 commit comments

Comments
 (0)