Skip to content

Commit f127535

Browse files
committed
WIP Move module methods implementations to kernel
1 parent 2740485 commit f127535

23 files changed

+1047
-1134
lines changed

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

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,4 @@ import dotty.tools.dotc.ast.tpd
44

55
trait CaseDefOpsImpl extends scala.tasty.reflect.CaseDefOps with CoreImpl with Helpers {
66

7-
object CaseDef extends CaseDefModule {
8-
def apply(pattern: Pattern, guard: Option[Term], body: Term)(implicit ctx: Context): CaseDef =
9-
tpd.CaseDef(pattern, guard.getOrElse(tpd.EmptyTree), body)
10-
11-
def copy(original: CaseDef)(pattern: Pattern, guard: Option[Term], body: Term)(implicit ctx: Context): CaseDef =
12-
tpd.cpy.CaseDef(original)(pattern, guard.getOrElse(tpd.EmptyTree), body)
13-
14-
def unapply(x: CaseDef): Some[(Pattern, Option[Term], Term)] = Some(x.pat, optional(x.guard), x.body)
15-
}
16-
17-
object TypeCaseDef extends TypeCaseDefModule {
18-
def apply(pattern: TypeTree, body: TypeTree)(implicit ctx: Context): TypeCaseDef =
19-
tpd.CaseDef(pattern, tpd.EmptyTree, body)
20-
21-
def copy(original: TypeCaseDef)(pattern: TypeTree, body: TypeTree)(implicit ctx: Context): TypeCaseDef =
22-
tpd.cpy.CaseDef(original)(pattern, tpd.EmptyTree, body)
23-
24-
def unapply(x: TypeCaseDef): Some[(TypeTree, TypeTree)] = Some((x.pat, x.body))
25-
}
267
}

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

Lines changed: 0 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -5,105 +5,4 @@ import dotty.tools.dotc.core.Constants
55

66
trait ConstantOpsImpl extends scala.tasty.reflect.ConstantOps with CoreImpl {
77

8-
object Constant extends ConstantModule {
9-
10-
object Unit extends UnitModule {
11-
def apply(): Constant = Constants.Constant(())
12-
def unapply(x: Constant): Boolean = x.tag == Constants.UnitTag
13-
}
14-
15-
object Null extends NullModule {
16-
def apply(): Constant = Constants.Constant(null)
17-
def unapply(x: Constant): Boolean = x.tag == Constants.NullTag
18-
}
19-
20-
object Boolean extends BooleanModule {
21-
def apply(x: Boolean): Constant = Constants.Constant(x)
22-
def unapply(x: Constant): Option[Boolean] = x match {
23-
case x: Constants.Constant if x.tag == Constants.BooleanTag => Some(x.booleanValue)
24-
case _ => None
25-
}
26-
}
27-
28-
object Byte extends ByteModule {
29-
def apply(x: Byte): Constant = Constants.Constant(x)
30-
def unapply(x: Constant): Option[Byte] = x match {
31-
case x: Constants.Constant if x.tag == Constants.ByteTag => Some(x.byteValue)
32-
case _ => None
33-
}
34-
}
35-
36-
object Short extends ShortModule {
37-
def apply(x: Short): Constant = Constants.Constant(x)
38-
def unapply(x: Constant): Option[Short] = x match {
39-
case x: Constants.Constant if x.tag == Constants.ShortTag => Some(x.shortValue)
40-
case _ => None
41-
}
42-
}
43-
44-
object Char extends CharModule {
45-
def apply(x: Char): Constant = Constants.Constant(x)
46-
def unapply(x: Constant): Option[Char] = x match {
47-
case x: Constants.Constant if x.tag == Constants.CharTag => Some(x.charValue)
48-
case _ => None
49-
}
50-
}
51-
52-
object Int extends IntModule {
53-
def apply(x: Int): Constant = Constants.Constant(x)
54-
def unapply(x: Constant): Option[Int] = x match {
55-
case x: Constants.Constant if x.tag == Constants.IntTag => Some(x.intValue)
56-
case _ => None
57-
}
58-
}
59-
60-
object Long extends LongModule {
61-
def apply(x: Long): Constant = Constants.Constant(x)
62-
def unapply(x: Constant): Option[Long] = x match {
63-
case x: Constants.Constant if x.tag == Constants.LongTag => Some(x.longValue)
64-
case _ => None
65-
}
66-
}
67-
68-
object Float extends FloatModule {
69-
def apply(x: Float): Constant = Constants.Constant(x)
70-
def unapply(x: Constant): Option[Float] = x match {
71-
case x: Constants.Constant if x.tag == Constants.FloatTag => Some(x.floatValue)
72-
case _ => None
73-
}
74-
}
75-
76-
object Double extends DoubleModule {
77-
def apply(x: Double): Constant = Constants.Constant(x)
78-
def unapply(x: Constant): Option[Double] = x match {
79-
case x: Constants.Constant if x.tag == Constants.DoubleTag => Some(x.doubleValue)
80-
case _ => None
81-
}
82-
}
83-
84-
object String extends StringModule {
85-
def apply(x: String): Constant = Constants.Constant(x)
86-
def unapply(x: Constant): Option[String] = x match {
87-
case x: Constants.Constant if x.tag == Constants.StringTag => Some(x.stringValue)
88-
case _ => None
89-
}
90-
}
91-
92-
object ClassTag extends ClassTagModule {
93-
def apply[T](implicit x: scala.reflect.ClassTag[T]): Constant = Constants.Constant(x)
94-
def unapply(x: Constant): Option[Type] = x match {
95-
case x: Constants.Constant if x.tag == Constants.ClazzTag => Some(x.typeValue)
96-
case _ => None
97-
}
98-
}
99-
100-
object Symbol extends SymbolModule {
101-
def apply(x: scala.Symbol): Constant = Constants.Constant(x)
102-
def unapply(x: Constant): Option[scala.Symbol] = x match {
103-
case x: Constants.Constant if x.tag == Constants.ScalaSymbolTag => Some(x.scalaSymbolValue)
104-
case _ => None
105-
}
106-
}
107-
}
108-
1098
}

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,4 @@ import dotty.tools.dotc.core.Decorators._
44

55
trait IdOpsImpl extends scala.tasty.reflect.IdOps with CoreImpl {
66

7-
object Id extends IdModule {
8-
def unapply(id: Id): Option[String] = Some(id.name.toString)
9-
}
10-
117
}

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

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,4 @@ import dotty.tools.dotc.core.Decorators._
66

77
trait ImportSelectorOpsImpl extends scala.tasty.reflect.ImportSelectorOps with CoreImpl {
88

9-
object SimpleSelector extends SimpleSelectorModule {
10-
def unapply(x: ImportSelector)(implicit ctx: Context): Option[Id] = x match {
11-
case x: untpd.Ident => Some(x)
12-
case _ => None
13-
}
14-
}
15-
16-
object RenameSelector extends RenameSelectorModule {
17-
def unapply(x: ImportSelector)(implicit ctx: Context): Option[(Id, Id)] = x match {
18-
case Trees.Thicket((id1: untpd.Ident) :: (id2: untpd.Ident) :: Nil) if id2.name != nme.WILDCARD => Some(id1, id2)
19-
case _ => None
20-
}
21-
}
22-
23-
object OmitSelector extends OmitSelectorModule {
24-
def unapply(x: ImportSelector)(implicit ctx: Context): Option[Id] = x match {
25-
case Trees.Thicket((id: untpd.Ident) :: Trees.Ident(nme.WILDCARD) :: Nil) => Some(id)
26-
case _ => None
27-
}
28-
}
29-
309
}

0 commit comments

Comments
 (0)