Skip to content

Commit 13da159

Browse files
authored
Merge pull request #7004 from milessabin/topic/applied-type-ctor
Add constructor for AppliedType
2 parents de43ee1 + 2198030 commit 13da159

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,6 +1230,8 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend
12301230
def AppliedType_tycon(self: AppliedType) given Context: Type = self.tycon
12311231
def AppliedType_args(self: AppliedType) given Context: List[TypeOrBounds] = self.args
12321232

1233+
def AppliedType_apply(tycon: Type, args: List[TypeOrBounds]) given Context: AppliedType = Types.AppliedType(tycon, args)
1234+
12331235
type AnnotatedType = Types.AnnotatedType
12341236

12351237
def matchAnnotatedType(tpe: TypeOrBounds) given Context: Option[AnnotatedType] = tpe match {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -978,6 +978,8 @@ trait CompilerInterface {
978978
def AppliedType_tycon(self: AppliedType) given (ctx: Context): Type
979979
def AppliedType_args(self: AppliedType) given (ctx: Context): List[TypeOrBounds]
980980

981+
def AppliedType_apply(tycon: Type, args: List[TypeOrBounds]) given (ctx: Context) : AppliedType
982+
981983
/** A type with an anottation `T @foo` */
982984
type AnnotatedType <: Type
983985

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ trait TypeOrBoundsOps extends Core {
142142
}
143143

144144
object AppliedType {
145+
def apply(tycon: Type, args: List[TypeOrBounds]) given (ctx: Context) : AppliedType =
146+
internal.AppliedType_apply(tycon, args)
145147
def unapply(typeOrBounds: TypeOrBounds) given (ctx: Context): Option[(Type, List[TypeOrBounds /* Type | TypeBounds */])] =
146148
internal.matchAppliedType(typeOrBounds).map(x => (x.tycon, x.args))
147149
}

0 commit comments

Comments
 (0)