Skip to content

Add constructor for AppliedType #7004

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1230,6 +1230,8 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend
def AppliedType_tycon(self: AppliedType) given Context: Type = self.tycon
def AppliedType_args(self: AppliedType) given Context: List[TypeOrBounds] = self.args

def AppliedType_apply(tycon: Type, args: List[TypeOrBounds]) given Context: AppliedType = Types.AppliedType(tycon, args)

type AnnotatedType = Types.AnnotatedType

def matchAnnotatedType(tpe: TypeOrBounds) given Context: Option[AnnotatedType] = tpe match {
Expand Down
2 changes: 2 additions & 0 deletions library/src/scala/tasty/reflect/CompilerInterface.scala
Original file line number Diff line number Diff line change
Expand Up @@ -978,6 +978,8 @@ trait CompilerInterface {
def AppliedType_tycon(self: AppliedType) given (ctx: Context): Type
def AppliedType_args(self: AppliedType) given (ctx: Context): List[TypeOrBounds]

def AppliedType_apply(tycon: Type, args: List[TypeOrBounds]) given (ctx: Context) : AppliedType

/** A type with an anottation `T @foo` */
type AnnotatedType <: Type

Expand Down
2 changes: 2 additions & 0 deletions library/src/scala/tasty/reflect/TypeOrBoundsOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ trait TypeOrBoundsOps extends Core {
}

object AppliedType {
def apply(tycon: Type, args: List[TypeOrBounds]) given (ctx: Context) : AppliedType =
internal.AppliedType_apply(tycon, args)
def unapply(typeOrBounds: TypeOrBounds) given (ctx: Context): Option[(Type, List[TypeOrBounds /* Type | TypeBounds */])] =
internal.matchAppliedType(typeOrBounds).map(x => (x.tycon, x.args))
}
Expand Down