Skip to content

Commit b44002c

Browse files
committed
Add apply method for object Refinement in tasty reflect
1 parent e2998b9 commit b44002c

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,6 +1265,13 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend
12651265
case _ => None
12661266
}
12671267

1268+
def Refinement_apply(parent: Type, name: String, info: TypeOrBounds /* Type | TypeBounds */)(given ctx: Context): Refinement = {
1269+
// fixme: support type refinements (type vs term)
1270+
// examine info maybe (TypeOrBounds are used for refinements)
1271+
// check aliasing of refinement
1272+
Types.RefinedType(parent, name.toTermName, info)
1273+
}
1274+
12681275
def Refinement_parent(self: Refinement)(given Context): Type = self.parent
12691276
def Refinement_name(self: Refinement)(given Context): String = self.refinedName.toString
12701277
def Refinement_info(self: Refinement)(given Context): TypeOrBounds = self.refinedInfo

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -908,6 +908,8 @@ trait CompilerInterface {
908908

909909
def isInstanceOfRefinement(given ctx: Context): IsInstanceOf[Refinement]
910910

911+
def Refinement_apply(parent: Type, name: String, info: TypeOrBounds /* Type | TypeBounds */)(given ctx: Context): Refinement
912+
911913
def Refinement_parent(self: Refinement)(given ctx: Context): Type
912914
def Refinement_name(self: Refinement)(given ctx: Context): String
913915
def Refinement_info(self: Refinement)(given ctx: Context): TypeOrBounds

library/src/scala/tasty/reflect/TypeOrBoundsOps.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,9 @@ trait TypeOrBoundsOps extends Core {
167167
def unapply(x: Refinement)(given ctx: Context): Option[Refinement] = Some(x)
168168

169169
object Refinement {
170+
def apply(parent: Type, name: String, info: TypeOrBounds /* Type | TypeBounds */)(given ctx: Context): Refinement =
171+
internal.Refinement_apply(parent, name, info)
172+
170173
def unapply(x: Refinement)(given ctx: Context): Option[(Type, String, TypeOrBounds /* Type | TypeBounds */)] =
171174
Some((x.parent, x.name, x.info))
172175
}
@@ -184,7 +187,7 @@ trait TypeOrBoundsOps extends Core {
184187
def unapply(x: AppliedType)(given ctx: Context): Option[AppliedType] = Some(x)
185188

186189
object AppliedType {
187-
def apply(tycon: Type, args: List[TypeOrBounds])(given ctx: Context) : AppliedType =
190+
def apply(tycon: Type, args: List[TypeOrBounds])(given ctx: Context): AppliedType =
188191
internal.AppliedType_apply(tycon, args)
189192
def unapply(x: AppliedType)(given ctx: Context): Option[(Type, List[TypeOrBounds /* Type | TypeBounds */])] =
190193
Some((x.tycon, x.args))

0 commit comments

Comments
 (0)