Skip to content

Commit f156786

Browse files
committed
wip
1 parent c1a5bec commit f156786

File tree

4 files changed

+198
-199
lines changed

4 files changed

+198
-199
lines changed

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

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -773,20 +773,20 @@ trait CompilerInterface {
773773
/** NoPrefix for a type selection */
774774
type NoPrefix <: TypeOrBounds
775775

776-
def matchNoPrefix(x: TypeOrBounds)(given ctx: Context): Option[NoPrefix]
776+
def isInstanceOfNoPrefix(given ctx: Context): IsInstanceOf[NoPrefix]
777777

778778
/** Type bounds */
779779
type TypeBounds <: TypeOrBounds
780780

781-
def matchTypeBounds(x: TypeOrBounds)(given ctx: Context): Option[TypeBounds]
781+
def isInstanceOfTypeBounds(given ctx: Context): IsInstanceOf[TypeBounds]
782782

783783
def TypeBounds_low(self: TypeBounds)(given ctx: Context): Type
784784
def TypeBounds_hi(self: TypeBounds)(given ctx: Context): Type
785785

786786
/** A type */
787787
type Type <: TypeOrBounds
788788

789-
def matchType(x: TypeOrBounds)(given ctx: Context): Option[Type]
789+
def isInstanceOfType(given ctx: Context): IsInstanceOf[Type]
790790

791791
def Type_apply(clazz: Class[_])(given ctx: Context): Type
792792

@@ -858,14 +858,14 @@ trait CompilerInterface {
858858
/** A singleton type representing a known constant value */
859859
type ConstantType <: Type
860860

861-
def matchConstantType(tpe: TypeOrBounds)(given ctx: Context): Option[ConstantType]
861+
def isInstanceOfConstantType(given ctx: Context): IsInstanceOf[ConstantType]
862862

863863
def ConstantType_constant(self: ConstantType)(given ctx: Context): Constant
864864

865865
/** Type of a reference to a term symbol */
866866
type TermRef <: Type
867867

868-
def matchTermRef(tpe: TypeOrBounds)(given ctx: Context): Option[TermRef]
868+
def isInstanceOfTermRef(given ctx: Context): IsInstanceOf[TermRef]
869869

870870
def TermRef_apply(qual: TypeOrBounds, name: String)(given ctx: Context): TermRef
871871

@@ -875,23 +875,23 @@ trait CompilerInterface {
875875
/** Type of a reference to a type symbol */
876876
type TypeRef <: Type
877877

878-
def matchTypeRef(tpe: TypeOrBounds)(given ctx: Context): Option[TypeRef]
878+
def isInstanceOfTypeRef(given ctx: Context): IsInstanceOf[TypeRef]
879879

880880
def TypeRef_qualifier(self: TypeRef)(given ctx: Context): TypeOrBounds
881881
def TypeRef_name(self: TypeRef)(given Context): String
882882

883883
/** Type of a `super` refernce */
884884
type SuperType <: Type
885885

886-
def matchSuperType(tpe: TypeOrBounds)(given ctx: Context): Option[SuperType]
886+
def isInstanceOfSuperType(given ctx: Context): IsInstanceOf[SuperType]
887887

888888
def SuperType_thistpe(self: SuperType)(given ctx: Context): Type
889889
def SuperType_supertpe(self: SuperType)(given ctx: Context): Type
890890

891891
/** A type with a type refinement `T { type U }` */
892892
type Refinement <: Type
893893

894-
def matchRefinement(tpe: TypeOrBounds)(given ctx: Context): Option[Refinement]
894+
def isInstanceOfRefinement(given ctx: Context): IsInstanceOf[Refinement]
895895

896896
def Refinement_parent(self: Refinement)(given ctx: Context): Type
897897
def Refinement_name(self: Refinement)(given ctx: Context): String
@@ -900,7 +900,7 @@ trait CompilerInterface {
900900
/** A higher kinded type applied to some types `T[U]` */
901901
type AppliedType <: Type
902902

903-
def matchAppliedType(tpe: TypeOrBounds)(given ctx: Context): Option[AppliedType]
903+
def isInstanceOfAppliedType(given ctx: Context): IsInstanceOf[AppliedType]
904904

905905
def AppliedType_tycon(self: AppliedType)(given ctx: Context): Type
906906
def AppliedType_args(self: AppliedType)(given ctx: Context): List[TypeOrBounds]
@@ -910,31 +910,31 @@ trait CompilerInterface {
910910
/** A type with an anottation `T @foo` */
911911
type AnnotatedType <: Type
912912

913-
def matchAnnotatedType(tpe: TypeOrBounds)(given ctx: Context): Option[AnnotatedType]
913+
def isInstanceOfAnnotatedType(given ctx: Context): IsInstanceOf[AnnotatedType]
914914

915915
def AnnotatedType_underlying(self: AnnotatedType)(given ctx: Context): Type
916916
def AnnotatedType_annot(self: AnnotatedType)(given ctx: Context): Term
917917

918918
/** Intersection type `T & U` */
919919
type AndType <: Type
920920

921-
def matchAndType(tpe: TypeOrBounds)(given ctx: Context): Option[AndType]
921+
def isInstanceOfAndType(given ctx: Context): IsInstanceOf[AndType]
922922

923923
def AndType_left(self: AndType)(given ctx: Context): Type
924924
def AndType_right(self: AndType)(given ctx: Context): Type
925925

926926
/** Union type `T | U` */
927927
type OrType <: Type
928928

929-
def matchOrType(tpe: TypeOrBounds)(given ctx: Context): Option[OrType]
929+
def isInstanceOfOrType(given ctx: Context): IsInstanceOf[OrType]
930930

931931
def OrType_left(self: OrType)(given ctx: Context): Type
932932
def OrType_right(self: OrType)(given ctx: Context): Type
933933

934934
/** Type match `T match { case U => ... }` */
935935
type MatchType <: Type
936936

937-
def matchMatchType(tpe: TypeOrBounds)(given ctx: Context): Option[MatchType]
937+
def isInstanceOfMatchType(given ctx: Context): IsInstanceOf[MatchType]
938938

939939
def MatchType_bound(self: MatchType)(given ctx: Context): Type
940940
def MatchType_scrutinee(self: MatchType)(given ctx: Context): Type
@@ -943,36 +943,36 @@ trait CompilerInterface {
943943
/** Type of a by by name parameter */
944944
type ByNameType <: Type
945945

946-
def matchByNameType(tpe: TypeOrBounds)(given ctx: Context): Option[ByNameType]
946+
def isInstanceOfByNameType(given ctx: Context): IsInstanceOf[ByNameType]
947947

948948
def ByNameType_underlying(self: ByNameType)(given ctx: Context): Type
949949

950950
/** Type of a parameter reference */
951951
type ParamRef <: Type
952952

953-
def matchParamRef(tpe: TypeOrBounds)(given ctx: Context): Option[ParamRef]
953+
def isInstanceOfParamRef(given ctx: Context): IsInstanceOf[ParamRef]
954954

955955
def ParamRef_binder(self: ParamRef)(given ctx: Context): LambdaType[TypeOrBounds]
956956
def ParamRef_paramNum(self: ParamRef)(given ctx: Context): Int
957957

958958
/** Type of `this` */
959959
type ThisType <: Type
960960

961-
def matchThisType(tpe: TypeOrBounds)(given ctx: Context): Option[ThisType]
961+
def isInstanceOfThisType(given ctx: Context): IsInstanceOf[ThisType]
962962

963963
def ThisType_tref(self: ThisType)(given ctx: Context): Type
964964

965965
/** A type that is recursively defined `this` */
966966
type RecursiveThis <: Type
967967

968-
def matchRecursiveThis(tpe: TypeOrBounds)(given ctx: Context): Option[RecursiveThis]
968+
def isInstanceOfRecursiveThis(given ctx: Context): IsInstanceOf[RecursiveThis]
969969

970970
def RecursiveThis_binder(self: RecursiveThis)(given ctx: Context): RecursiveType
971971

972972
/** A type that is recursively defined */
973973
type RecursiveType <: Type
974974

975-
def matchRecursiveType(tpe: TypeOrBounds)(given ctx: Context): Option[RecursiveType]
975+
def isInstanceOfRecursiveType(given ctx: Context): IsInstanceOf[RecursiveType]
976976

977977
def RecursiveType_underlying(self: RecursiveType)(given ctx: Context): Type
978978

@@ -984,7 +984,7 @@ trait CompilerInterface {
984984
/** Type of the definition of a method taking a single list of parameters. It's return type may be a MethodType. */
985985
type MethodType <: LambdaType[Type]
986986

987-
def matchMethodType(tpe: TypeOrBounds)(given ctx: Context): Option[MethodType]
987+
def isInstanceOfMethodType(given ctx: Context): IsInstanceOf[MethodType]
988988

989989
def MethodType_isErased(self: MethodType): Boolean
990990
def MethodType_isImplicit(self: MethodType): Boolean
@@ -995,7 +995,7 @@ trait CompilerInterface {
995995
/** Type of the definition of a method taking a list of type parameters. It's return type may be a MethodType. */
996996
type PolyType <: LambdaType[TypeBounds]
997997

998-
def matchPolyType(tpe: TypeOrBounds)(given ctx: Context): Option[PolyType]
998+
def isInstanceOfPolyType(given ctx: Context): IsInstanceOf[PolyType]
999999

10001000
def PolyType_paramNames(self: PolyType)(given ctx: Context): List[String]
10011001
def PolyType_paramBounds(self: PolyType)(given ctx: Context): List[TypeBounds]
@@ -1004,7 +1004,7 @@ trait CompilerInterface {
10041004
/** Type of the definition of a type lambda taking a list of type parameters. It's return type may be a TypeLambda. */
10051005
type TypeLambda <: LambdaType[TypeBounds]
10061006

1007-
def matchTypeLambda(tpe: TypeOrBounds)(given ctx: Context): Option[TypeLambda]
1007+
def isInstanceOfTypeLambda(given ctx: Context): IsInstanceOf[TypeLambda]
10081008

10091009
def TypeLambda_paramNames(self: TypeLambda)(given ctx: Context): List[String]
10101010
def TypeLambda_paramBounds(self: TypeLambda)(given ctx: Context): List[TypeBounds]
@@ -1023,20 +1023,20 @@ trait CompilerInterface {
10231023

10241024
type SimpleSelector <: ImportSelector
10251025

1026-
def matchSimpleSelector(self: ImportSelector)(given ctx: Context): Option[SimpleSelector]
1026+
def isInstanceOfSimpleSelector(given ctx: Context): IsInstanceOf[SimpleSelector]
10271027

10281028
def SimpleSelector_selection(self: SimpleSelector)(given ctx: Context): Id
10291029

10301030
type RenameSelector <: ImportSelector
10311031

1032-
def matchRenameSelector(self: ImportSelector)(given ctx: Context): Option[RenameSelector]
1032+
def isInstanceOfRenameSelector(given ctx: Context): IsInstanceOf[RenameSelector]
10331033

10341034
def RenameSelector_from(self: RenameSelector)(given ctx: Context): Id
10351035
def RenameSelector_to(self: RenameSelector)(given ctx: Context): Id
10361036

10371037
type OmitSelector <: ImportSelector
10381038

1039-
def matchOmitSelector(self: ImportSelector)(given ctx: Context): Option[OmitSelector]
1039+
def isInstanceOfOmitSelector(given ctx: Context): IsInstanceOf[OmitSelector]
10401040

10411041
def SimpleSelector_omitted(self: OmitSelector)(given ctx: Context): Id
10421042

library/src/scala/tasty/reflect/ImportSelectorOps.scala

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ trait ImportSelectorOps extends Core {
88
internal.SimpleSelector_selection(self)
99
}
1010

11-
object SimpleSelector {
12-
def unapply(importSelector: ImportSelector)(given ctx: Context): Option[Id] =
13-
internal.matchSimpleSelector(importSelector).map(_.selection)
14-
}
11+
given (given Context): IsInstanceOf[SimpleSelector] = internal.isInstanceOfSimpleSelector
12+
13+
object SimpleSelector
14+
def unapply(x: SimpleSelector)(given ctx: Context): Option[Id] = Some(x.selection)
1515

1616
given (self: RenameSelector) {
1717
def from(given ctx: Context): Id =
@@ -21,19 +21,19 @@ trait ImportSelectorOps extends Core {
2121
internal.RenameSelector_to(self)
2222
}
2323

24-
object RenameSelector {
25-
def unapply(importSelector: ImportSelector)(given ctx: Context): Option[(Id, Id)] =
26-
internal.matchRenameSelector(importSelector).map(x => (x.from, x.to))
27-
}
24+
given (given Context): IsInstanceOf[RenameSelector] = internal.isInstanceOfRenameSelector
25+
26+
object RenameSelector
27+
def unapply(x: RenameSelector)(given ctx: Context): Option[(Id, Id)] = Some((x.from, x.to))
2828

2929
given (self: OmitSelector) {
3030
def omitted(given ctx: Context): Id =
3131
internal.SimpleSelector_omitted(self)
3232
}
3333

34-
object OmitSelector {
35-
def unapply(importSelector: ImportSelector)(given ctx: Context): Option[Id] =
36-
internal.matchOmitSelector(importSelector).map(_.omitted)
37-
}
34+
given (given Context): IsInstanceOf[OmitSelector] = internal.isInstanceOfOmitSelector
35+
36+
object OmitSelector
37+
def unapply(x: OmitSelector)(given ctx: Context): Option[Id] = Some(x.omitted)
3838

3939
}

0 commit comments

Comments
 (0)