Skip to content

Commit 2740485

Browse files
committed
Move PatternAPI to kernel
1 parent 5bb86ab commit 2740485

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,11 @@ class KernelImpl(val rootContext: core.Contexts.Context, val rootPosition: util.
238238
//
239239

240240
type Pattern = tpd.Tree
241+
242+
def Pattern_pos(self: Pattern)(implicit ctx: Context): Position = self.sourcePos
243+
def Pattern_tpe(self: Pattern)(implicit ctx: Context): Type = self.tpe.stripTypeVar
244+
def Pattern_symbol(self: Pattern)(implicit ctx: Context): Symbol = self.symbol
245+
241246
type Value = tpd.Tree
242247

243248
def Pattern_Value_value(self: Value)(implicit ctx: Context): Term = self

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@ import dotty.tools.dotc.core.StdNames.nme
77

88
trait PatternOpsImpl extends scala.tasty.reflect.PatternOps with RootPositionImpl {
99

10-
def PatternDeco(pattern: Pattern): PatternAPI = new PatternAPI {
11-
def pos(implicit ctx: Context): Position = pattern.sourcePos
12-
def tpe(implicit ctx: Context): Type = pattern.tpe.stripTypeVar
13-
def symbol(implicit ctx: Context): Symbol = pattern.symbol
14-
}
15-
1610
object Pattern extends PatternModule {
1711

1812
object IsValue extends IsValueModule {

library/src/scala/tasty/reflect/Kernel.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,10 @@ trait Kernel {
376376
/** Pattern tree of the pattern part of a CaseDef */
377377
type Pattern <: AnyRef
378378

379+
def Pattern_pos(self: Pattern)(implicit ctx: Context): Position
380+
def Pattern_tpe(self: Pattern)(implicit ctx: Context): Type
381+
def Pattern_symbol(self: Pattern)(implicit ctx: Context): Symbol
382+
379383
/** Pattern representing a value. This includes `1`, ```x``` and `_` */
380384
type Value <: Pattern
381385

library/src/scala/tasty/reflect/PatternOps.scala

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,14 @@ trait PatternOps extends Core {
2626
def tpt(implicit ctx: Context): TypeTree = kernel.Pattern_TypeTest_tpt(typeTest)
2727
}
2828

29-
trait PatternAPI {
29+
implicit class PatternAPI(self: Pattern) {
3030
/** Position in the source code */
31-
def pos(implicit ctx: Context): Position
31+
def pos(implicit ctx: Context): Position = kernel.Pattern_pos(self)
3232

33-
def tpe(implicit ctx: Context): Type
33+
def tpe(implicit ctx: Context): Type = kernel.Pattern_tpe(self)
3434

35-
def symbol(implicit ctx: Context): Symbol
35+
def symbol(implicit ctx: Context): Symbol = kernel.Pattern_symbol(self)
3636
}
37-
implicit def PatternDeco(pattern: Pattern): PatternAPI
3837

3938
val Pattern: PatternModule
4039
abstract class PatternModule {

0 commit comments

Comments
 (0)