diff --git a/compiler/src/dotty/tools/dotc/tastyreflect/ReflectionCompilerInterface.scala b/compiler/src/dotty/tools/dotc/tastyreflect/ReflectionCompilerInterface.scala index ce41a2f6165d..5e15a22dc808 100644 --- a/compiler/src/dotty/tools/dotc/tastyreflect/ReflectionCompilerInterface.scala +++ b/compiler/src/dotty/tools/dotc/tastyreflect/ReflectionCompilerInterface.scala @@ -18,7 +18,7 @@ import dotty.tools.dotc.util.{SourceFile, SourcePosition, Spans} import scala.internal.quoted.Unpickler import scala.tasty.reflect.CompilerInterface -import scala.tasty.reflect.IsInstanceOf +import scala.tasty.reflect.TypeTest class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extends CompilerInterface { import tpd._ @@ -114,7 +114,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type PackageClause = tpd.PackageDef - def isInstanceOfPackageClause(using ctx: Context): IsInstanceOf[PackageClause] = new { + def PackageClause_TypeTest(using ctx: Context): TypeTest[Tree, PackageClause] = new { def runtimeClass: Class[?] = classOf[PackageClause] override def unapply(x: Any): Option[PackageClause] = x match case x: tpd.PackageDef @unchecked => Some(x) @@ -132,18 +132,18 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type Statement = tpd.Tree - def isInstanceOfStatement(using ctx: Context): IsInstanceOf[Statement] = new { + def Statement_TypeTest(using ctx: Context): TypeTest[Tree, Statement] = new { def runtimeClass: Class[?] = classOf[Statement] override def unapply(x: Any): Option[Statement] = x match case _: PatternTree @unchecked => None - case tree: Tree @unchecked if tree.isTerm => isInstanceOfTerm.unapply(tree) - case tree: Tree @unchecked => isInstanceOfDefinition.unapply(tree) + case tree: Tree @unchecked if tree.isTerm => Term_TypeTest.unapply(tree) + case tree: Tree @unchecked => Definition_TypeTest.unapply(tree) case _ => None } type Import = tpd.Import - def isInstanceOfImport(using ctx: Context): IsInstanceOf[Import] = new { + def Import_TypeTest(using ctx: Context): TypeTest[Tree, Import] = new { def runtimeClass: Class[?] = classOf[Import] override def unapply(x: Any): Option[Import] = x match case tree: tpd.Import @unchecked => Some(tree) @@ -162,7 +162,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type Definition = tpd.Tree - def isInstanceOfDefinition(using ctx: Context): IsInstanceOf[Definition] = new { + def Definition_TypeTest(using ctx: Context): TypeTest[Tree, Definition] = new { def runtimeClass: Class[?] = classOf[Definition] override def unapply(x: Any): Option[Definition] = x match case x: tpd.MemberDef @unchecked => Some(x) @@ -177,7 +177,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type PackageDef = PackageDefinition - def isInstanceOfPackageDef(using ctx: Context): IsInstanceOf[PackageDef] = new { + def PackageDef_TypeTest(using ctx: Context): TypeTest[Tree, PackageDef] = new { def runtimeClass: Class[?] = classOf[PackageDef] override def unapply(x: Any): Option[PackageDef] = x match case x: PackageDefinition @unchecked => Some(x) @@ -192,7 +192,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type ClassDef = tpd.TypeDef - def isInstanceOfClassDef(using ctx: Context): IsInstanceOf[ClassDef] = new { + def ClassDef_TypeTest(using ctx: Context): TypeTest[Tree, ClassDef] = new { def runtimeClass: Class[?] = classOf[ClassDef] override def unapply(x: Any): Option[ClassDef] = x match case x: tpd.TypeDef @unchecked if x.isClassDef => Some(x) @@ -213,7 +213,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type TypeDef = tpd.TypeDef - def isInstanceOfTypeDef(using ctx: Context): IsInstanceOf[TypeDef] = new { + def TypeDef_TypeTest(using ctx: Context): TypeTest[Tree, TypeDef] = new { def runtimeClass: Class[?] = classOf[TypeDef] override def unapply(x: Any): Option[TypeDef] = x match case x: tpd.TypeDef @unchecked if !x.isClassDef => Some(x) @@ -228,7 +228,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type DefDef = tpd.DefDef - def isInstanceOfDefDef(using ctx: Context): IsInstanceOf[DefDef] = new { + def DefDef_TypeTest(using ctx: Context): TypeTest[Tree, DefDef] = new { def runtimeClass: Class[?] = classOf[DefDef] override def unapply(x: Any): Option[DefDef] = x match case x: tpd.DefDef @unchecked => Some(x) @@ -248,7 +248,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type ValDef = tpd.ValDef - def isInstanceOfValDef(using ctx: Context): IsInstanceOf[ValDef] = new { + def ValDef_TypeTest(using ctx: Context): TypeTest[Tree, ValDef] = new { def runtimeClass: Class[?] = classOf[ValDef] override def unapply(x: Any): Option[ValDef] = x match case x: tpd.ValDef @unchecked => Some(x) @@ -266,10 +266,10 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type Term = tpd.Tree - def isInstanceOfTerm(using ctx: Context): IsInstanceOf[Term] = new { + def Term_TypeTest(using ctx: Context): TypeTest[Tree, Term] = new { def runtimeClass: Class[?] = classOf[Term] override def unapply(x: Any): Option[Term] = x match - case _ if isInstanceOfUnapply.unapply(x).isDefined => None + case _ if Unapply_TypeTest.unapply(x).isDefined => None case _: tpd.PatternTree @unchecked => None case x: tpd.SeqLiteral @unchecked => Some(x) case x: tpd.Tree @unchecked if x.isTerm => Some(x) @@ -299,7 +299,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type Ref = tpd.RefTree - def isInstanceOfRef(using ctx: Context): IsInstanceOf[Ref] = new { + def Ref_TypeTest(using ctx: Context): TypeTest[Tree, Ref] = new { def runtimeClass: Class[?] = classOf[Ref] override def unapply(x: Any): Option[Ref] = x match case x: tpd.RefTree @unchecked if x.isTerm => Some(x) @@ -316,7 +316,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type Ident = tpd.Ident - def isInstanceOfIdent(using ctx: Context): IsInstanceOf[Ident] = new { + def Ident_TypeTest(using ctx: Context): TypeTest[Tree, Ident] = new { def runtimeClass: Class[?] = classOf[Ident] override def unapply(x: Any): Option[Ident] = x match case x: tpd.Ident @unchecked if x.isTerm => Some(x) @@ -333,7 +333,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type Select = tpd.Select - def isInstanceOfSelect(using ctx: Context): IsInstanceOf[Select] = new { + def Select_TypeTest(using ctx: Context): TypeTest[Tree, Select] = new { def runtimeClass: Class[?] = classOf[Select] override def unapply(x: Any): Option[Select] = x match case x: tpd.Select @unchecked if x.isTerm => Some(x) @@ -364,7 +364,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type Literal = tpd.Literal - def isInstanceOfLiteral(using ctx: Context): IsInstanceOf[Literal] = new { + def Literal_TypeTest(using ctx: Context): TypeTest[Tree, Literal] = new { def runtimeClass: Class[?] = classOf[Literal] override def unapply(x: Any): Option[Literal] = x match case x: tpd.Literal @unchecked => Some(x) @@ -381,7 +381,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type This = tpd.This - def isInstanceOfThis(using ctx: Context): IsInstanceOf[This] = new { + def This_TypeTest(using ctx: Context): TypeTest[Tree, This] = new { def runtimeClass: Class[?] = classOf[This] override def unapply(x: Any): Option[This] = x match case x: tpd.This @unchecked => Some(x) @@ -398,7 +398,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type New = tpd.New - def isInstanceOfNew(using ctx: Context): IsInstanceOf[New] = new { + def New_TypeTest(using ctx: Context): TypeTest[Tree, New] = new { def runtimeClass: Class[?] = classOf[New] override def unapply(x: Any): Option[New] = x match case x: tpd.New @unchecked => Some(x) @@ -414,7 +414,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type NamedArg = tpd.NamedArg - def isInstanceOfNamedArg(using ctx: Context): IsInstanceOf[NamedArg] = new { + def NamedArg_TypeTest(using ctx: Context): TypeTest[Tree, NamedArg] = new { def runtimeClass: Class[?] = classOf[NamedArg] override def unapply(x: Any): Option[NamedArg] = x match case x: tpd.NamedArg @unchecked if x.name.isInstanceOf[core.Names.TermName] => Some(x) // TODO: Now, the name should alwas be a term name @@ -432,7 +432,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type Apply = tpd.Apply - def isInstanceOfApply(using ctx: Context): IsInstanceOf[Apply] = new { + def Apply_TypeTest(using ctx: Context): TypeTest[Tree, Apply] = new { def runtimeClass: Class[?] = classOf[Apply] override def unapply(x: Any): Option[Apply] = x match case x: tpd.Apply @unchecked => Some(x) @@ -451,7 +451,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type TypeApply = tpd.TypeApply - def isInstanceOfTypeApply(using ctx: Context): IsInstanceOf[TypeApply] = new { + def TypeApply_TypeTest(using ctx: Context): TypeTest[Tree, TypeApply] = new { def runtimeClass: Class[?] = classOf[TypeApply] override def unapply(x: Any): Option[TypeApply] = x match case x: tpd.TypeApply @unchecked => Some(x) @@ -469,7 +469,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type Super = tpd.Super - def isInstanceOfSuper(using ctx: Context): IsInstanceOf[Super] = new { + def Super_TypeTest(using ctx: Context): TypeTest[Tree, Super] = new { def runtimeClass: Class[?] = classOf[Super] override def unapply(x: Any): Option[Super] = x match case x: tpd.Super @unchecked => Some(x) @@ -487,7 +487,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type Typed = tpd.Typed - def isInstanceOfTyped(using ctx: Context): IsInstanceOf[Typed] = new { + def Typed_TypeTest(using ctx: Context): TypeTest[Tree, Typed] = new { def runtimeClass: Class[?] = classOf[Typed] override def unapply(x: Any): Option[Typed] = x match case x: tpd.Typed @unchecked => Some(x) @@ -505,7 +505,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type Assign = tpd.Assign - def isInstanceOfAssign(using ctx: Context): IsInstanceOf[Assign] = new { + def Assign_TypeTest(using ctx: Context): TypeTest[Tree, Assign] = new { def runtimeClass: Class[?] = classOf[Assign] override def unapply(x: Any): Option[Assign] = x match case x: tpd.Assign @unchecked => Some(x) @@ -523,7 +523,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type Block = tpd.Block - def isInstanceOfBlock(using ctx: Context): IsInstanceOf[Block] = new { + def Block_TypeTest(using ctx: Context): TypeTest[Tree, Block] = new { def runtimeClass: Class[?] = classOf[Block] override def unapply(x: Any): Option[Block] = x match @@ -575,7 +575,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type Inlined = tpd.Inlined - def isInstanceOfInlined(using ctx: Context): IsInstanceOf[Inlined] = new { + def Inlined_TypeTest(using ctx: Context): TypeTest[Tree, Inlined] = new { def runtimeClass: Class[?] = classOf[Inlined] override def unapply(x: Any): Option[Inlined] = x match case x: tpd.Inlined @unchecked => Some(x) @@ -594,7 +594,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type Closure = tpd.Closure - def isInstanceOfClosure(using ctx: Context): IsInstanceOf[Closure] = new { + def Closure_TypeTest(using ctx: Context): TypeTest[Tree, Closure] = new { def runtimeClass: Class[?] = classOf[Closure] override def unapply(x: Any): Option[Closure] = x match case x: tpd.Closure @unchecked => Some(x) @@ -615,7 +615,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type If = tpd.If - def isInstanceOfIf(using ctx: Context): IsInstanceOf[If] = new { + def If_TypeTest(using ctx: Context): TypeTest[Tree, If] = new { def runtimeClass: Class[?] = classOf[If] override def unapply(x: Any): Option[If] = x match case x: tpd.If @unchecked => Some(x) @@ -634,7 +634,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type Match = tpd.Match - def isInstanceOfMatch(using ctx: Context): IsInstanceOf[Match] = new { + def Match_TypeTest(using ctx: Context): TypeTest[Tree, Match] = new { def runtimeClass: Class[?] = classOf[Match] override def unapply(x: Any): Option[Match] = x match case x: tpd.Match @unchecked if !x.selector.isEmpty => Some(x) @@ -652,7 +652,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type GivenMatch = tpd.Match - def isInstanceOfGivenMatch(using ctx: Context): IsInstanceOf[GivenMatch] = new { + def GivenMatch_TypeTest(using ctx: Context): TypeTest[Tree, GivenMatch] = new { def runtimeClass: Class[?] = classOf[GivenMatch] override def unapply(x: Any): Option[GivenMatch] = x match case x: tpd.Match @unchecked if x.selector.isEmpty => Some(x) @@ -669,7 +669,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type Try = tpd.Try - def isInstanceOfTry(using ctx: Context): IsInstanceOf[Try] = new { + def Try_TypeTest(using ctx: Context): TypeTest[Tree, Try] = new { def runtimeClass: Class[?] = classOf[Try] override def unapply(x: Any): Option[Try] = x match case x: tpd.Try @unchecked => Some(x) @@ -688,7 +688,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type Return = tpd.Return - def isInstanceOfReturn(using ctx: Context): IsInstanceOf[Return] = new { + def Return_TypeTest(using ctx: Context): TypeTest[Tree, Return] = new { def runtimeClass: Class[?] = classOf[Return] override def unapply(x: Any): Option[Return] = x match case x: tpd.Return @unchecked => Some(x) @@ -705,7 +705,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type Repeated = tpd.SeqLiteral - def isInstanceOfRepeated(using ctx: Context): IsInstanceOf[Repeated] = new { + def Repeated_TypeTest(using ctx: Context): TypeTest[Tree, Repeated] = new { def runtimeClass: Class[?] = classOf[Repeated] override def unapply(x: Any): Option[Repeated] = x match case x: tpd.SeqLiteral @unchecked => Some(x) @@ -723,7 +723,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type SelectOuter = tpd.Select - def isInstanceOfSelectOuter(using ctx: Context): IsInstanceOf[SelectOuter] = new { + def SelectOuter_TypeTest(using ctx: Context): TypeTest[Tree, SelectOuter] = new { def runtimeClass: Class[?] = classOf[SelectOuter] override def unapply(x: Any): Option[SelectOuter] = x match case x: tpd.Select @unchecked => @@ -747,7 +747,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type While = tpd.WhileDo - def isInstanceOfWhile(using ctx: Context): IsInstanceOf[While] = new { + def While_TypeTest(using ctx: Context): TypeTest[Tree, While] = new { def runtimeClass: Class[?] = classOf[While] override def unapply(x: Any): Option[While] = x match case x: tpd.WhileDo @unchecked => Some(x) @@ -765,7 +765,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type TypeTree = tpd.Tree - def isInstanceOfTypeTree(using ctx: Context): IsInstanceOf[TypeTree] = new { + def TypeTree_TypeTest(using ctx: Context): TypeTest[Tree, TypeTree] = new { def runtimeClass: Class[?] = classOf[TypeTree] override def unapply(x: Any): Option[TypeTree] = x match case x: tpd.TypeBoundsTree @unchecked => None @@ -777,7 +777,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type Inferred = tpd.TypeTree - def isInstanceOfInferred(using ctx: Context): IsInstanceOf[Inferred] = new { + def Inferred_TypeTest(using ctx: Context): TypeTest[Tree, Inferred] = new { def runtimeClass: Class[?] = classOf[Inferred] override def unapply(x: Any): Option[Inferred] = x match case tpt: tpd.TypeTree @unchecked if !tpt.tpe.isInstanceOf[Types.TypeBounds] => Some(tpt) @@ -788,7 +788,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type TypeIdent = tpd.Ident - def isInstanceOfTypeIdent(using ctx: Context): IsInstanceOf[TypeIdent] = new { + def TypeIdent_TypeTest(using ctx: Context): TypeTest[Tree, TypeIdent] = new { def runtimeClass: Class[?] = classOf[TypeIdent] override def unapply(x: Any): Option[TypeIdent] = x match case tpt: tpd.Ident @unchecked if tpt.isType => Some(tpt) @@ -802,7 +802,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type TypeSelect = tpd.Select - def isInstanceOfTypeSelect(using ctx: Context): IsInstanceOf[TypeSelect] = new { + def TypeSelect_TypeTest(using ctx: Context): TypeTest[Tree, TypeSelect] = new { def runtimeClass: Class[?] = classOf[TypeSelect] override def unapply(x: Any): Option[TypeSelect] = x match case tpt: tpd.Select @unchecked if tpt.isType && tpt.qualifier.isTerm => Some(tpt) @@ -821,7 +821,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type Projection = tpd.Select - def isInstanceOfProjection(using ctx: Context): IsInstanceOf[Projection] = new { + def Projection_TypeTest(using ctx: Context): TypeTest[Tree, Projection] = new { def runtimeClass: Class[?] = classOf[Projection] override def unapply(x: Any): Option[Projection] = x match case tpt: tpd.Select @unchecked if tpt.isType && tpt.qualifier.isType => Some(tpt) @@ -836,7 +836,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type Singleton = tpd.SingletonTypeTree - def isInstanceOfSingleton(using ctx: Context): IsInstanceOf[Singleton] = new { + def Singleton_TypeTest(using ctx: Context): TypeTest[Tree, Singleton] = new { def runtimeClass: Class[?] = classOf[Singleton] override def unapply(x: Any): Option[Singleton] = x match case tpt: tpd.SingletonTypeTree @unchecked => Some(tpt) @@ -853,7 +853,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type Refined = tpd.RefinedTypeTree - def isInstanceOfRefined(using ctx: Context): IsInstanceOf[Refined] = new { + def Refined_TypeTest(using ctx: Context): TypeTest[Tree, Refined] = new { def runtimeClass: Class[?] = classOf[Refined] override def unapply(x: Any): Option[Refined] = x match case tpt: tpd.RefinedTypeTree @unchecked => Some(tpt) @@ -868,7 +868,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type Applied = tpd.AppliedTypeTree - def isInstanceOfApplied(using ctx: Context): IsInstanceOf[Applied] = new { + def Applied_TypeTest(using ctx: Context): TypeTest[Tree, Applied] = new { def runtimeClass: Class[?] = classOf[Applied] override def unapply(x: Any): Option[Applied] = x match case tpt: tpd.AppliedTypeTree @unchecked => Some(tpt) @@ -886,7 +886,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type Annotated = tpd.Annotated - def isInstanceOfAnnotated(using ctx: Context): IsInstanceOf[Annotated] = new { + def Annotated_TypeTest(using ctx: Context): TypeTest[Tree, Annotated] = new { def runtimeClass: Class[?] = classOf[Annotated] override def unapply(x: Any): Option[Annotated] = x match case tpt: tpd.Annotated @unchecked => Some(tpt) @@ -904,7 +904,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type MatchTypeTree = tpd.MatchTypeTree - def isInstanceOfMatchTypeTree(using ctx: Context): IsInstanceOf[MatchTypeTree] = new { + def MatchTypeTree_TypeTest(using ctx: Context): TypeTest[Tree, MatchTypeTree] = new { def runtimeClass: Class[?] = classOf[MatchTypeTree] override def unapply(x: Any): Option[MatchTypeTree] = x match case tpt: tpd.MatchTypeTree @unchecked => Some(tpt) @@ -923,7 +923,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type ByName = tpd.ByNameTypeTree - def isInstanceOfByName(using ctx: Context): IsInstanceOf[ByName] = new { + def ByName_TypeTest(using ctx: Context): TypeTest[Tree, ByName] = new { def runtimeClass: Class[?] = classOf[ByName] override def unapply(x: Any): Option[ByName] = x match case tpt: tpd.ByNameTypeTree @unchecked => Some(tpt) @@ -940,7 +940,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type LambdaTypeTree = tpd.LambdaTypeTree - def isInstanceOfLambdaTypeTree(using ctx: Context): IsInstanceOf[LambdaTypeTree] = new { + def LambdaTypeTree_TypeTest(using ctx: Context): TypeTest[Tree, LambdaTypeTree] = new { def runtimeClass: Class[?] = classOf[LambdaTypeTree] override def unapply(x: Any): Option[LambdaTypeTree] = x match case tpt: tpd.LambdaTypeTree @unchecked => Some(tpt) @@ -958,7 +958,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type TypeBind = tpd.Bind - def isInstanceOfTypeBind(using ctx: Context): IsInstanceOf[TypeBind] = new { + def TypeBind_TypeTest(using ctx: Context): TypeTest[Tree, TypeBind] = new { def runtimeClass: Class[?] = classOf[TypeBind] override def unapply(x: Any): Option[TypeBind] = x match case tpt: tpd.Bind @unchecked if tpt.name.isTypeName => Some(tpt) @@ -973,7 +973,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type TypeBlock = tpd.Block - def isInstanceOfTypeBlock(using ctx: Context): IsInstanceOf[TypeBlock] = new { + def TypeBlock_TypeTest(using ctx: Context): TypeTest[Tree, TypeBlock] = new { def runtimeClass: Class[?] = classOf[TypeBlock] override def unapply(x: Any): Option[TypeBlock] = x match case tpt: tpd.Block @unchecked => Some(tpt) @@ -991,7 +991,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type TypeBoundsTree = tpd.TypeBoundsTree - def isInstanceOfTypeBoundsTree(using ctx: Context): IsInstanceOf[TypeBoundsTree] = new { + def TypeBoundsTree_TypeTest(using ctx: Context): TypeTest[Tree, TypeBoundsTree] = new { def runtimeClass: Class[?] = classOf[TypeBoundsTree] override def unapply(x: Any): Option[TypeBoundsTree] = x match case x: tpd.TypeBoundsTree @unchecked => Some(x) @@ -1011,7 +1011,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type WildcardTypeTree = tpd.Ident - def isInstanceOfWildcardTypeTree(using ctx: Context): IsInstanceOf[WildcardTypeTree] = new { + def WildcardTypeTree_TypeTest(using ctx: Context): TypeTest[Tree, WildcardTypeTree] = new { def runtimeClass: Class[?] = classOf[WildcardTypeTree] override def unapply(x: Any): Option[WildcardTypeTree] = x match case x: tpd.Ident @unchecked if x.name == nme.WILDCARD => Some(x) @@ -1022,7 +1022,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type CaseDef = tpd.CaseDef - def isInstanceOfCaseDef(using ctx: Context): IsInstanceOf[CaseDef] = new { + def CaseDef_TypeTest(using ctx: Context): TypeTest[Tree, CaseDef] = new { def runtimeClass: Class[?] = classOf[CaseDef] override def unapply(x: Any): Option[CaseDef] = x match case tree: tpd.CaseDef @unchecked if tree.body.isTerm => Some(tree) @@ -1041,7 +1041,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type TypeCaseDef = tpd.CaseDef - def isInstanceOfTypeCaseDef(using ctx: Context): IsInstanceOf[TypeCaseDef] = new { + def TypeCaseDef_TypeTest(using ctx: Context): TypeTest[Tree, TypeCaseDef] = new { def runtimeClass: Class[?] = classOf[TypeCaseDef] override def unapply(x: Any): Option[TypeCaseDef] = x match case tree: tpd.CaseDef @unchecked if tree.body.isType => Some(tree) @@ -1059,7 +1059,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type Bind = tpd.Bind - def isInstanceOfBind(using ctx: Context): IsInstanceOf[Bind] = new { + def Bind_TypeTest(using ctx: Context): TypeTest[Tree, Bind] = new { def runtimeClass: Class[?] = classOf[Bind] override def unapply(x: Any): Option[Bind] = x match case x: tpd.Bind @unchecked if x.name.isTermName => Some(x) @@ -1078,7 +1078,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type Unapply = tpd.UnApply - def isInstanceOfUnapply(using ctx: Context): IsInstanceOf[Unapply] = new { + def Unapply_TypeTest(using ctx: Context): TypeTest[Tree, Unapply] = new { def runtimeClass: Class[?] = classOf[Unapply] override def unapply(x: Any): Option[Unapply] = x match case pattern: tpd.UnApply @unchecked => Some(pattern) @@ -1100,7 +1100,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type Alternatives = tpd.Alternative - def isInstanceOfAlternatives(using ctx: Context): IsInstanceOf[Alternatives] = new { + def Alternatives_TypeTest(using ctx: Context): TypeTest[Tree, Alternatives] = new { def runtimeClass: Class[?] = classOf[Alternatives] override def unapply(x: Any): Option[Alternatives] = x match case x: tpd.Alternative @unchecked => Some(x) @@ -1124,7 +1124,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type NoPrefix = Types.NoPrefix.type - def isInstanceOfNoPrefix(using ctx: Context): IsInstanceOf[NoPrefix] = new { + def NoPrefix_TypeTest(using ctx: Context): TypeTest[TypeOrBounds, NoPrefix] = new { def runtimeClass: Class[?] = classOf[Types.NoPrefix.type] override def unapply(x: Any): Option[NoPrefix] = if (x == Types.NoPrefix) Some(Types.NoPrefix) else None @@ -1132,7 +1132,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type TypeBounds = Types.TypeBounds - def isInstanceOfTypeBounds(using ctx: Context): IsInstanceOf[TypeBounds] = new { + def TypeBounds_TypeTest(using ctx: Context): TypeTest[TypeOrBounds, TypeBounds] = new { def runtimeClass: Class[?] = classOf[TypeBounds] override def unapply(x: Any): Option[TypeBounds] = x match case x: Types.TypeBounds => Some(x) @@ -1147,7 +1147,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type Type = Types.Type - def isInstanceOfType(using ctx: Context): IsInstanceOf[Type] = new { + def Type_TypeTest(using ctx: Context): TypeTest[TypeOrBounds, Type] = new { def runtimeClass: Class[?] = classOf[Type] override def unapply(x: Any): Option[Type] = x match case x: TypeBounds => None @@ -1226,7 +1226,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type ConstantType = Types.ConstantType - def isInstanceOfConstantType(using ctx: Context): IsInstanceOf[ConstantType] = new { + def ConstantType_TypeTest(using ctx: Context): TypeTest[TypeOrBounds, ConstantType] = new { def runtimeClass: Class[?] = classOf[ConstantType] override def unapply(x: Any): Option[ConstantType] = x match case tpe: Types.ConstantType => Some(tpe) @@ -1240,7 +1240,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type TermRef = Types.NamedType - def isInstanceOfTermRef(using ctx: Context): IsInstanceOf[TermRef] = new { + def TermRef_TypeTest(using ctx: Context): TypeTest[TypeOrBounds, TermRef] = new { def runtimeClass: Class[?] = classOf[TermRef] override def unapply(x: Any): Option[TermRef] = x match case tp: Types.TermRef => Some(tp) @@ -1256,7 +1256,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type TypeRef = Types.NamedType - def isInstanceOfTypeRef(using ctx: Context): IsInstanceOf[TypeRef] = new { + def TypeRef_TypeTest(using ctx: Context): TypeTest[TypeOrBounds, TypeRef] = new { def runtimeClass: Class[?] = classOf[TypeRef] override def unapply(x: Any): Option[TypeRef] = x match case tp: Types.TypeRef => Some(tp) @@ -1273,7 +1273,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type NamedTermRef = Types.NamedType - def isInstanceOfNamedTermRef(using ctx: Context): IsInstanceOf[NamedTermRef] = new { + def NamedTermRef_TypeTest(using ctx: Context): TypeTest[TypeOrBounds, NamedTermRef] = new { def runtimeClass: Class[?] = classOf[NamedTermRef] override def unapply(x: Any): Option[NamedTermRef] = x match case tpe: Types.NamedType => @@ -1289,7 +1289,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type SuperType = Types.SuperType - def isInstanceOfSuperType(using ctx: Context): IsInstanceOf[SuperType] = new { + def SuperType_TypeTest(using ctx: Context): TypeTest[TypeOrBounds, SuperType] = new { def runtimeClass: Class[?] = classOf[SuperType] override def unapply(x: Any): Option[SuperType] = x match case tpe: Types.SuperType => Some(tpe) @@ -1304,7 +1304,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type Refinement = Types.RefinedType - def isInstanceOfRefinement(using ctx: Context): IsInstanceOf[Refinement] = new { + def Refinement_TypeTest(using ctx: Context): TypeTest[TypeOrBounds, Refinement] = new { def runtimeClass: Class[?] = classOf[Refinement] override def unapply(x: Any): Option[Refinement] = x match case tpe: Types.RefinedType => Some(tpe) @@ -1325,7 +1325,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type AppliedType = Types.AppliedType - def isInstanceOfAppliedType(using ctx: Context): IsInstanceOf[AppliedType] = new { + def AppliedType_TypeTest(using ctx: Context): TypeTest[TypeOrBounds, AppliedType] = new { def runtimeClass: Class[?] = classOf[AppliedType] override def unapply(x: Any): Option[AppliedType] = x match case tpe: Types.AppliedType => Some(tpe) @@ -1339,7 +1339,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type AnnotatedType = Types.AnnotatedType - def isInstanceOfAnnotatedType(using ctx: Context): IsInstanceOf[AnnotatedType] = new { + def AnnotatedType_TypeTest(using ctx: Context): TypeTest[TypeOrBounds, AnnotatedType] = new { def runtimeClass: Class[?] = classOf[AnnotatedType] override def unapply(x: Any): Option[AnnotatedType] = x match case tpe: Types.AnnotatedType => Some(tpe) @@ -1354,7 +1354,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type AndType = Types.AndType - def isInstanceOfAndType(using ctx: Context): IsInstanceOf[AndType] = new { + def AndType_TypeTest(using ctx: Context): TypeTest[TypeOrBounds, AndType] = new { def runtimeClass: Class[?] = classOf[AndType] override def unapply(x: Any): Option[AndType] = x match case tpe: Types.AndType => Some(tpe) @@ -1369,7 +1369,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type OrType = Types.OrType - def isInstanceOfOrType(using ctx: Context): IsInstanceOf[OrType] = new { + def OrType_TypeTest(using ctx: Context): TypeTest[TypeOrBounds, OrType] = new { def runtimeClass: Class[?] = classOf[OrType] override def unapply(x: Any): Option[OrType] = x match case tpe: Types.OrType => Some(tpe) @@ -1384,7 +1384,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type MatchType = Types.MatchType - def isInstanceOfMatchType(using ctx: Context): IsInstanceOf[MatchType] = new { + def MatchType_TypeTest(using ctx: Context): TypeTest[TypeOrBounds, MatchType] = new { def runtimeClass: Class[?] = classOf[MatchType] override def unapply(x: Any): Option[MatchType] = x match case tpe: Types.MatchType => Some(tpe) @@ -1400,7 +1400,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type ByNameType = Types.ExprType - def isInstanceOfByNameType(using ctx: Context): IsInstanceOf[ByNameType] = new { + def ByNameType_TypeTest(using ctx: Context): TypeTest[TypeOrBounds, ByNameType] = new { def runtimeClass: Class[?] = classOf[ByNameType] override def unapply(x: Any): Option[ByNameType] = x match case tpe: Types.ExprType => Some(tpe) @@ -1413,7 +1413,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type ParamRef = Types.ParamRef - def isInstanceOfParamRef(using ctx: Context): IsInstanceOf[ParamRef] = new { + def ParamRef_TypeTest(using ctx: Context): TypeTest[TypeOrBounds, ParamRef] = new { def runtimeClass: Class[?] = classOf[ParamRef] override def unapply(x: Any): Option[ParamRef] = x match case tpe: Types.TypeParamRef => Some(tpe) @@ -1427,7 +1427,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type ThisType = Types.ThisType - def isInstanceOfThisType(using ctx: Context): IsInstanceOf[ThisType] = new { + def ThisType_TypeTest(using ctx: Context): TypeTest[TypeOrBounds, ThisType] = new { def runtimeClass: Class[?] = classOf[ThisType] override def unapply(x: Any): Option[ThisType] = x match case tpe: Types.ThisType => Some(tpe) @@ -1438,7 +1438,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type RecursiveThis = Types.RecThis - def isInstanceOfRecursiveThis(using ctx: Context): IsInstanceOf[RecursiveThis] = new { + def RecursiveThis_TypeTest(using ctx: Context): TypeTest[TypeOrBounds, RecursiveThis] = new { def runtimeClass: Class[?] = classOf[RecursiveThis] override def unapply(x: Any): Option[RecursiveThis] = x match case tpe: Types.RecThis => Some(tpe) @@ -1449,7 +1449,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type RecursiveType = Types.RecType - def isInstanceOfRecursiveType(using ctx: Context): IsInstanceOf[RecursiveType] = new { + def RecursiveType_TypeTest(using ctx: Context): TypeTest[TypeOrBounds, RecursiveType] = new { def runtimeClass: Class[?] = classOf[RecursiveType] override def unapply(x: Any): Option[RecursiveType] = x match case tpe: Types.RecType => Some(tpe) @@ -1467,7 +1467,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type MethodType = Types.MethodType - def isInstanceOfMethodType(using ctx: Context): IsInstanceOf[MethodType] = new { + def MethodType_TypeTest(using ctx: Context): TypeTest[TypeOrBounds, MethodType] = new { def runtimeClass: Class[?] = classOf[MethodType] override def unapply(x: Any): Option[MethodType] = x match case tpe: Types.MethodType => Some(tpe) @@ -1486,7 +1486,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type PolyType = Types.PolyType - def isInstanceOfPolyType(using ctx: Context): IsInstanceOf[PolyType] = new { + def PolyType_TypeTest(using ctx: Context): TypeTest[TypeOrBounds, PolyType] = new { def runtimeClass: Class[?] = classOf[PolyType] override def unapply(x: Any): Option[PolyType] = x match case tpe: Types.PolyType => Some(tpe) @@ -1503,7 +1503,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type TypeLambda = Types.TypeLambda - def isInstanceOfTypeLambda(using ctx: Context): IsInstanceOf[TypeLambda] = new { + def TypeLambda_TypeTest(using ctx: Context): TypeTest[TypeOrBounds, TypeLambda] = new { def runtimeClass: Class[?] = classOf[TypeLambda] override def unapply(x: Any): Option[TypeLambda] = x match case tpe: Types.TypeLambda => Some(tpe) @@ -1528,7 +1528,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type SimpleSelector = untpd.ImportSelector - def isInstanceOfSimpleSelector(using ctx: Context): IsInstanceOf[SimpleSelector] = new { + def SimpleSelector_TypeTest(using ctx: Context): TypeTest[ImportSelector, SimpleSelector] = new { def runtimeClass: Class[?] = classOf[SimpleSelector] override def unapply(x: Any): Option[SimpleSelector] = x match case x: untpd.ImportSelector if x.renamed.isEmpty => Some(x) @@ -1539,7 +1539,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type RenameSelector = untpd.ImportSelector - def isInstanceOfRenameSelector(using ctx: Context): IsInstanceOf[RenameSelector] = new { + def RenameSelector_TypeTest(using ctx: Context): TypeTest[ImportSelector, RenameSelector] = new { def runtimeClass: Class[?] = classOf[RenameSelector] override def unapply(x: Any): Option[RenameSelector] = x match case x: untpd.ImportSelector if !x.renamed.isEmpty => Some(x) @@ -1553,7 +1553,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend type OmitSelector = untpd.ImportSelector - def isInstanceOfOmitSelector(using ctx: Context): IsInstanceOf[OmitSelector] = new { + def OmitSelector_TypeTest(using ctx: Context): TypeTest[ImportSelector, OmitSelector] = new { def runtimeClass: Class[?] = classOf[OmitSelector] override def unapply(x: Any): Option[OmitSelector] = x match { case self: untpd.ImportSelector => @@ -2006,7 +2006,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend ctx.typer.inferImplicitArg(tpe, rootPosition.span) type ImplicitSearchSuccess = Tree - def isInstanceOfImplicitSearchSuccess(using ctx: Context): IsInstanceOf[ImplicitSearchSuccess] = new { + def ImplicitSearchSuccess_TypeTest(using ctx: Context): TypeTest[ImplicitSearchResult, ImplicitSearchSuccess] = new { def runtimeClass: Class[?] = classOf[ImplicitSearchSuccess] override def unapply(x: Any): Option[ImplicitSearchSuccess] = x match case x: Tree @unchecked => @@ -2018,7 +2018,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend def ImplicitSearchSuccess_tree(self: ImplicitSearchSuccess)(using ctx: Context): Term = self type ImplicitSearchFailure = Tree - def isInstanceOfImplicitSearchFailure(using ctx: Context): IsInstanceOf[ImplicitSearchFailure] = new { + def ImplicitSearchFailure_TypeTest(using ctx: Context): TypeTest[ImplicitSearchResult, ImplicitSearchFailure] = new { def runtimeClass: Class[?] = classOf[ImplicitSearchFailure] override def unapply(x: Any): Option[ImplicitSearchFailure] = x match case x: Tree @unchecked => @@ -2031,7 +2031,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend self.tpe.asInstanceOf[SearchFailureType].explanation type DivergingImplicit = Tree - def isInstanceOfDivergingImplicit(using ctx: Context): IsInstanceOf[DivergingImplicit] = new { + def DivergingImplicit_TypeTest(using ctx: Context): TypeTest[ImplicitSearchResult, DivergingImplicit] = new { def runtimeClass: Class[?] = classOf[DivergingImplicit] override def unapply(x: Any): Option[DivergingImplicit] = x match case x: Tree @unchecked => @@ -2042,7 +2042,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend } type NoMatchingImplicits = Tree - def isInstanceOfNoMatchingImplicits(using ctx: Context): IsInstanceOf[NoMatchingImplicits] = new { + def NoMatchingImplicits_TypeTest(using ctx: Context): TypeTest[ImplicitSearchResult, NoMatchingImplicits] = new { def runtimeClass: Class[?] = classOf[NoMatchingImplicits] override def unapply(x: Any): Option[NoMatchingImplicits] = x match case x: Tree @unchecked => @@ -2053,7 +2053,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend } type AmbiguousImplicits = Tree - def isInstanceOfAmbiguousImplicits(using ctx: Context): IsInstanceOf[AmbiguousImplicits] = new { + def AmbiguousImplicits_TypeTest(using ctx: Context): TypeTest[ImplicitSearchResult, AmbiguousImplicits] = new { def runtimeClass: Class[?] = classOf[AmbiguousImplicits] override def unapply(x: Any): Option[AmbiguousImplicits] = x match case x: Tree @unchecked => diff --git a/library/src/scala/tasty/Reflection.scala b/library/src/scala/tasty/Reflection.scala index 25a498ce779a..c0cab7c25aad 100644 --- a/library/src/scala/tasty/Reflection.scala +++ b/library/src/scala/tasty/Reflection.scala @@ -483,7 +483,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => new SourceCodePrinter[self.type](self)(syntaxHighlight).showTree(tree) } - given (using ctx: Context) as IsInstanceOf[PackageClause] = internal.isInstanceOfPackageClause + given (using ctx: Context) as TypeTest[Tree, PackageClause] = internal.PackageClause_TypeTest object PackageClause { def apply(pid: Ref, stats: List[Tree])(using ctx: Context): PackageClause = @@ -499,7 +499,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def stats(using ctx: Context): List[Tree] = internal.PackageClause_stats(self) } - given (using ctx: Context) as IsInstanceOf[Import] = internal.isInstanceOfImport + given (using ctx: Context) as TypeTest[Tree, Import] = internal.Import_TypeTest object Import { def apply(expr: Term, selectors: List[ImportSelector])(using ctx: Context): Import = @@ -516,11 +516,11 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => internal.Import_selectors(self) } - given (using ctx: Context) as IsInstanceOf[Statement] = internal.isInstanceOfStatement + given (using ctx: Context) as TypeTest[Tree, Statement] = internal.Statement_TypeTest // ----- Definitions ---------------------------------------------- - given (using ctx: Context) as IsInstanceOf[Definition] = internal.isInstanceOfDefinition + given (using ctx: Context) as TypeTest[Tree, Definition] = internal.Definition_TypeTest extension DefinitionOps on (self: Definition) { def name(using ctx: Context): String = internal.Definition_name(self) @@ -528,7 +528,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => // ClassDef - given (using ctx: Context) as IsInstanceOf[ClassDef] = internal.isInstanceOfClassDef + given (using ctx: Context) as TypeTest[Tree, ClassDef] = internal.ClassDef_TypeTest object ClassDef { // TODO def apply(name: String, constr: DefDef, parents: List[TermOrTypeTree], selfOpt: Option[ValDef], body: List[Statement])(using ctx: Context): ClassDef @@ -548,7 +548,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => // DefDef - given (using ctx: Context) as IsInstanceOf[DefDef] = internal.isInstanceOfDefDef + given (using ctx: Context) as TypeTest[Tree, DefDef] = internal.DefDef_TypeTest object DefDef { def apply(symbol: Symbol, rhsFn: List[Type] => List[List[Term]] => Option[Term])(using ctx: Context): DefDef = @@ -568,7 +568,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => // ValDef - given (using ctx: Context) as IsInstanceOf[ValDef] = internal.isInstanceOfValDef + given (using ctx: Context) as TypeTest[Tree, ValDef] = internal.ValDef_TypeTest object ValDef { def apply(symbol: Symbol, rhs: Option[Term])(using ctx: Context): ValDef = @@ -586,7 +586,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => // TypeDef - given (using ctx: Context) as IsInstanceOf[TypeDef] = internal.isInstanceOfTypeDef + given (using ctx: Context) as TypeTest[Tree, TypeDef] = internal.TypeDef_TypeTest object TypeDef { def apply(symbol: Symbol)(using ctx: Context): TypeDef = @@ -603,7 +603,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => // PackageDef - given (using ctx: Context) as IsInstanceOf[PackageDef] = internal.isInstanceOfPackageDef + given (using ctx: Context) as TypeTest[Tree, PackageDef] = internal.PackageDef_TypeTest extension PackageDefOps on (self: PackageDef) { def owner(using ctx: Context): PackageDef = internal.PackageDef_owner(self) @@ -680,9 +680,9 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def select(sym: Symbol)(using ctx: Context): Select = Select(self, sym) } - given (using ctx: Context) as IsInstanceOf[Term] = internal.isInstanceOfTerm + given (using ctx: Context) as TypeTest[Tree, Term] = internal.Term_TypeTest - given (using ctx: Context) as IsInstanceOf[Ref] = internal.isInstanceOfRef + given (using ctx: Context) as TypeTest[Tree, Ref] = internal.Ref_TypeTest object Ref { @@ -708,7 +708,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => internal.Ref_apply(sym) } - given (using ctx: Context) as IsInstanceOf[Ident] = internal.isInstanceOfIdent + given (using ctx: Context) as TypeTest[Tree, Ident] = internal.Ident_TypeTest extension IdentOps on (self: Ident) { def name(using ctx: Context): String = internal.Ident_name(self) @@ -727,7 +727,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => Some(tree.name) } - given (using ctx: Context) as IsInstanceOf[Select] = internal.isInstanceOfSelect + given (using ctx: Context) as TypeTest[Tree, Select] = internal.Select_TypeTest /** Scala term selection */ object Select { @@ -763,8 +763,8 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def signature(using ctx: Context): Option[Signature] = internal.Select_signature(self) } - given (using ctx: Context) as IsInstanceOf[Literal] = - internal.isInstanceOfLiteral + given (using ctx: Context) as TypeTest[Tree, Literal] = + internal.Literal_TypeTest /** Scala literal constant */ object Literal { @@ -785,7 +785,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def constant(using ctx: Context): Constant = internal.Literal_constant(self) } - given (using ctx: Context) as IsInstanceOf[This] = internal.isInstanceOfThis + given (using ctx: Context) as TypeTest[Tree, This] = internal.This_TypeTest /** Scala `this` or `this[id]` */ object This { @@ -806,7 +806,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def id(using ctx: Context): Option[Id] = internal.This_id(self) } - given (using ctx: Context) as IsInstanceOf[New] = internal.isInstanceOfNew + given (using ctx: Context) as TypeTest[Tree, New] = internal.New_TypeTest /** Scala `new` */ object New { @@ -826,7 +826,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def tpt(using ctx: Context): TypeTree = internal.New_tpt(self) } - given (using ctx: Context) as IsInstanceOf[NamedArg] = internal.isInstanceOfNamedArg + given (using ctx: Context) as TypeTest[Tree, NamedArg] = internal.NamedArg_TypeTest /** Scala named argument `x = y` in argument position */ object NamedArg { @@ -849,7 +849,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def value(using ctx: Context): Term = internal.NamedArg_value(self) } - given (using ctx: Context) as IsInstanceOf[Apply] = internal.isInstanceOfApply + given (using ctx: Context) as TypeTest[Tree, Apply] = internal.Apply_TypeTest /** Scala parameter application */ object Apply { @@ -871,7 +871,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def args(using ctx: Context): List[Term] = internal.Apply_args(self) } - given (using ctx: Context) as IsInstanceOf[TypeApply] = internal.isInstanceOfTypeApply + given (using ctx: Context) as TypeTest[Tree, TypeApply] = internal.TypeApply_TypeTest /** Scala type parameter application */ object TypeApply { @@ -894,7 +894,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def args(using ctx: Context): List[TypeTree] = internal.TypeApply_args(self) } - given (using ctx: Context) as IsInstanceOf[Super] = internal.isInstanceOfSuper + given (using ctx: Context) as TypeTest[Tree, Super] = internal.Super_TypeTest /** Scala `x.super` or `x.super[id]` */ @@ -917,7 +917,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def id(using ctx: Context): Option[Id] = internal.Super_id(self) } - given (using ctx: Context) as IsInstanceOf[Typed] = internal.isInstanceOfTyped + given (using ctx: Context) as TypeTest[Tree, Typed] = internal.Typed_TypeTest /** Scala ascription `x: T` */ object Typed { @@ -940,7 +940,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def tpt(using ctx: Context): TypeTree = internal.Typed_tpt(self) } - given (using ctx: Context) as IsInstanceOf[Assign] = internal.isInstanceOfAssign + given (using ctx: Context) as TypeTest[Tree, Assign] = internal.Assign_TypeTest /** Scala assign `x = y` */ object Assign { @@ -962,7 +962,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def rhs(using ctx: Context): Term = internal.Assign_rhs(self) } - given (using ctx: Context) as IsInstanceOf[Block] = internal.isInstanceOfBlock + given (using ctx: Context) as TypeTest[Tree, Block] = internal.Block_TypeTest /** Scala code block `{ stat0; ...; statN; expr }` term */ @@ -985,7 +985,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def expr(using ctx: Context): Term = internal.Block_expr(self) } - given (using ctx: Context) as IsInstanceOf[Closure] = internal.isInstanceOfClosure + given (using ctx: Context) as TypeTest[Tree, Closure] = internal.Closure_TypeTest object Closure { @@ -1030,7 +1030,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => } - given (using ctx: Context) as IsInstanceOf[If] = internal.isInstanceOfIf + given (using ctx: Context) as TypeTest[Tree, If] = internal.If_TypeTest /** Scala `if`/`else` term */ object If { @@ -1054,7 +1054,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def elsep(using ctx: Context): Term = internal.If_elsep(self) } - given (using ctx: Context) as IsInstanceOf[Match] = internal.isInstanceOfMatch + given (using ctx: Context) as TypeTest[Tree, Match] = internal.Match_TypeTest /** Scala `match` term */ object Match { @@ -1077,7 +1077,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def cases(using ctx: Context): List[CaseDef] = internal.Match_cases(self) } - given (using ctx: Context) as IsInstanceOf[GivenMatch] = internal.isInstanceOfGivenMatch + given (using ctx: Context) as TypeTest[Tree, GivenMatch] = internal.GivenMatch_TypeTest /** Scala implicit `match` term */ @@ -1099,7 +1099,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def cases(using ctx: Context): List[CaseDef] = internal.GivenMatch_cases(self) } - given (using ctx: Context) as IsInstanceOf[Try] = internal.isInstanceOfTry + given (using ctx: Context) as TypeTest[Tree, Try] = internal.Try_TypeTest /** Scala `try`/`catch`/`finally` term */ object Try { @@ -1123,7 +1123,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def finalizer(using ctx: Context): Option[Term] = internal.Try_finalizer(self) } - given (using ctx: Context) as IsInstanceOf[Return] = internal.isInstanceOfReturn + given (using ctx: Context) as TypeTest[Tree, Return] = internal.Return_TypeTest /** Scala local `return` */ object Return { @@ -1144,7 +1144,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def expr(using ctx: Context): Term = internal.Return_expr(self) } - given (using ctx: Context) as IsInstanceOf[Repeated] = internal.isInstanceOfRepeated + given (using ctx: Context) as TypeTest[Tree, Repeated] = internal.Repeated_TypeTest object Repeated { @@ -1164,7 +1164,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def elemtpt(using ctx: Context): TypeTree = internal.Repeated_elemtpt(self) } - given (using ctx: Context) as IsInstanceOf[Inlined] = internal.isInstanceOfInlined + given (using ctx: Context) as TypeTest[Tree, Inlined] = internal.Inlined_TypeTest object Inlined { @@ -1185,7 +1185,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def body(using ctx: Context): Term = internal.Inlined_body(self) } - given (using ctx: Context) as IsInstanceOf[SelectOuter] = internal.isInstanceOfSelectOuter + given (using ctx: Context) as TypeTest[Tree, SelectOuter] = internal.SelectOuter_TypeTest object SelectOuter { @@ -1205,7 +1205,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def level(using ctx: Context): Int = internal.SelectOuter_level(self) } - given (using ctx: Context) as IsInstanceOf[While] = internal.isInstanceOfWhile + given (using ctx: Context) as TypeTest[Tree, While] = internal.While_TypeTest object While { @@ -1234,10 +1234,10 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def tpe(using ctx: Context): Type = internal.TypeTree_tpe(self) } - given (using ctx: Context) as IsInstanceOf[TypeTree] = - internal.isInstanceOfTypeTree + given (using ctx: Context) as TypeTest[Tree, TypeTree] = + internal.TypeTree_TypeTest - given (using ctx: Context) as IsInstanceOf[Inferred] = internal.isInstanceOfInferred + given (using ctx: Context) as TypeTest[Tree, Inferred] = internal.Inferred_TypeTest /** TypeTree containing an inferred type */ object Inferred { @@ -1247,7 +1247,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def unapply(x: Inferred)(using ctx: Context): Boolean = true } - given (using ctx: Context) as IsInstanceOf[TypeIdent] = internal.isInstanceOfTypeIdent + given (using ctx: Context) as TypeTest[Tree, TypeIdent] = internal.TypeIdent_TypeTest extension TypeIdentOps on (self: TypeIdent) { def name(using ctx: Context): String = internal.TypeIdent_name(self) @@ -1261,7 +1261,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def unapply(x: TypeIdent)(using ctx: Context): Option[String] = Some(x.name) } - given (using ctx: Context) as IsInstanceOf[TypeSelect] = internal.isInstanceOfTypeSelect + given (using ctx: Context) as TypeTest[Tree, TypeSelect] = internal.TypeSelect_TypeTest object TypeSelect { def apply(qualifier: Term, name: String)(using ctx: Context): TypeSelect = @@ -1277,7 +1277,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def name(using ctx: Context): String = internal.TypeSelect_name(self) } - given (using ctx: Context) as IsInstanceOf[Projection] = internal.isInstanceOfProjection + given (using ctx: Context) as TypeTest[Tree, Projection] = internal.Projection_TypeTest object Projection { // TODO def apply(qualifier: TypeTree, name: String)(using ctx: Context): Project @@ -1292,7 +1292,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def name(using ctx: Context): String = internal.Projection_name(self) } - given (using ctx: Context) as IsInstanceOf[Singleton] = internal.isInstanceOfSingleton + given (using ctx: Context) as TypeTest[Tree, Singleton] = internal.Singleton_TypeTest object Singleton { def apply(ref: Term)(using ctx: Context): Singleton = @@ -1307,7 +1307,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def ref(using ctx: Context): Term = internal.Singleton_ref(self) } - given (using ctx: Context) as IsInstanceOf[Refined] = internal.isInstanceOfRefined + given (using ctx: Context) as TypeTest[Tree, Refined] = internal.Refined_TypeTest object Refined { // TODO def apply(tpt: TypeTree, refinements: List[Definition])(using ctx: Context): Refined @@ -1322,7 +1322,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def refinements(using ctx: Context): List[Definition] = internal.Refined_refinements(self) } - given (using ctx: Context) as IsInstanceOf[Applied] = internal.isInstanceOfApplied + given (using ctx: Context) as TypeTest[Tree, Applied] = internal.Applied_TypeTest object Applied { def apply(tpt: TypeTree, args: List[Tree /*TypeTree | TypeBoundsTree*/])(using ctx: Context): Applied = @@ -1338,8 +1338,8 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def args(using ctx: Context): List[Tree /*TypeTree | TypeBoundsTree*/] = internal.Applied_args(self) } - given (using ctx: Context) as IsInstanceOf[Annotated] = - internal.isInstanceOfAnnotated + given (using ctx: Context) as TypeTest[Tree, Annotated] = + internal.Annotated_TypeTest object Annotated { def apply(arg: TypeTree, annotation: Term)(using ctx: Context): Annotated = @@ -1355,8 +1355,8 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def annotation(using ctx: Context): Term = internal.Annotated_annotation(self) } - given (using ctx: Context) as IsInstanceOf[MatchTypeTree] = - internal.isInstanceOfMatchTypeTree + given (using ctx: Context) as TypeTest[Tree, MatchTypeTree] = + internal.MatchTypeTree_TypeTest object MatchTypeTree { def apply(bound: Option[TypeTree], selector: TypeTree, cases: List[TypeCaseDef])(using ctx: Context): MatchTypeTree = @@ -1373,8 +1373,8 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def cases(using ctx: Context): List[TypeCaseDef] = internal.MatchTypeTree_cases(self) } - given (using ctx: Context) as IsInstanceOf[ByName] = - internal.isInstanceOfByName + given (using ctx: Context) as TypeTest[Tree, ByName] = + internal.ByName_TypeTest object ByName { def apply(result: TypeTree)(using ctx: Context): ByName = @@ -1389,7 +1389,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def result(using ctx: Context): TypeTree = internal.ByName_result(self) } - given (using ctx: Context) as IsInstanceOf[LambdaTypeTree] = internal.isInstanceOfLambdaTypeTree + given (using ctx: Context) as TypeTest[Tree, LambdaTypeTree] = internal.LambdaTypeTree_TypeTest object LambdaTypeTree { def apply(tparams: List[TypeDef], body: Tree /*TypeTree | TypeBoundsTree*/)(using ctx: Context): LambdaTypeTree = @@ -1405,7 +1405,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def body(using ctx: Context): Tree /*TypeTree | TypeBoundsTree*/ = internal.Lambdabody(self) } - given (using ctx: Context) as IsInstanceOf[TypeBind] = internal.isInstanceOfTypeBind + given (using ctx: Context) as TypeTest[Tree, TypeBind] = internal.TypeBind_TypeTest object TypeBind { // TODO def apply(name: String, tree: Tree)(using ctx: Context): TypeBind @@ -1420,7 +1420,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def body(using ctx: Context): Tree /*TypeTree | TypeBoundsTree*/ = internal.TypeBind_body(self) } - given (using ctx: Context) as IsInstanceOf[TypeBlock] = internal.isInstanceOfTypeBlock + given (using ctx: Context) as TypeTest[Tree, TypeBlock] = internal.TypeBlock_TypeTest object TypeBlock { def apply(aliases: List[TypeDef], tpt: TypeTree)(using ctx: Context): TypeBlock = @@ -1444,7 +1444,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def hi(using ctx: Context): TypeTree = internal.TypeBoundsTree_hi(self) } - given (using ctx: Context) as IsInstanceOf[TypeBoundsTree] = internal.isInstanceOfTypeBoundsTree + given (using ctx: Context) as TypeTest[Tree, TypeBoundsTree] = internal.TypeBoundsTree_TypeTest object TypeBoundsTree { def unapply(x: TypeBoundsTree)(using ctx: Context): Option[(TypeTree, TypeTree)] = @@ -1455,7 +1455,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def tpe(using ctx: Context): TypeOrBounds = internal.WildcardTypeTree_tpe(self) } - given (using ctx: Context) as IsInstanceOf[WildcardTypeTree] = internal.isInstanceOfWildcardTypeTree + given (using ctx: Context) as TypeTest[Tree, WildcardTypeTree] = internal.WildcardTypeTree_TypeTest object WildcardTypeTree { /** Matches a TypeBoundsTree containing wildcard type bounds */ @@ -1470,7 +1470,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def rhs(using ctx: Context): Term = internal.CaseDef_rhs(caseDef) } - given (using ctx: Context) as IsInstanceOf[CaseDef] = internal.isInstanceOfCaseDef + given (using ctx: Context) as TypeTest[Tree, CaseDef] = internal.CaseDef_TypeTest object CaseDef { def apply(pattern: Tree, guard: Option[Term], rhs: Term)(using ctx: Context): CaseDef = @@ -1488,8 +1488,8 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def rhs(using ctx: Context): TypeTree = internal.TypeCaseDef_rhs(caseDef) } - given (using ctx: Context) as IsInstanceOf[TypeCaseDef] = - internal.isInstanceOfTypeCaseDef + given (using ctx: Context) as TypeTest[Tree, TypeCaseDef] = + internal.TypeCaseDef_TypeTest object TypeCaseDef { def apply(pattern: TypeTree, rhs: TypeTree)(using ctx: Context): TypeCaseDef = @@ -1504,7 +1504,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => // ----- Patterns ------------------------------------------------ - given (using ctx: Context) as IsInstanceOf[Bind] = internal.isInstanceOfBind + given (using ctx: Context) as TypeTest[Tree, Bind] = internal.Bind_TypeTest object Bind { def apply(sym: Symbol, pattern: Tree)(using ctx: Context): Bind = @@ -1520,7 +1520,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def pattern(using ctx: Context): Tree = internal.Tree_Bind_pattern(bind) } - given (using ctx: Context) as IsInstanceOf[Unapply] = internal.isInstanceOfUnapply + given (using ctx: Context) as TypeTest[Tree, Unapply] = internal.Unapply_TypeTest object Unapply { // TODO def apply(fun: Term, implicits: List[Term], patterns: List[Tree])(using ctx: Context): Unapply @@ -1536,7 +1536,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def patterns(using ctx: Context): List[Tree] = internal.Tree_Unapply_patterns(unapply) } - given (using ctx: Context) as IsInstanceOf[Alternatives] = internal.isInstanceOfAlternatives + given (using ctx: Context) as TypeTest[Tree, Alternatives] = internal.Alternatives_TypeTest object Alternatives { def apply(patterns: List[Tree])(using ctx: Context): Alternatives = @@ -1561,7 +1561,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => internal.SimpleSelector_selection(self) } - given (using ctx: Context) as IsInstanceOf[SimpleSelector] = internal.isInstanceOfSimpleSelector + given (using ctx: Context) as TypeTest[ImportSelector, SimpleSelector] = internal.SimpleSelector_TypeTest object SimpleSelector: def unapply(x: SimpleSelector)(using ctx: Context): Option[Id] = Some(x.selection) @@ -1573,7 +1573,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def to(using ctx: Context): Id = internal.RenameSelector_to(self) - given (using ctx: Context) as IsInstanceOf[RenameSelector] = internal.isInstanceOfRenameSelector + given (using ctx: Context) as TypeTest[ImportSelector, RenameSelector] = internal.RenameSelector_TypeTest object RenameSelector: def unapply(x: RenameSelector)(using ctx: Context): Option[(Id, Id)] = Some((x.from, x.to)) @@ -1582,7 +1582,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def omitted(using ctx: Context): Id = internal.SimpleSelector_omitted(self) - given (using ctx: Context) as IsInstanceOf[OmitSelector] = internal.isInstanceOfOmitSelector + given (using ctx: Context) as TypeTest[ImportSelector, OmitSelector] = internal.OmitSelector_TypeTest object OmitSelector: def unapply(x: OmitSelector)(using ctx: Context): Option[Id] = Some(x.omitted) @@ -1700,14 +1700,14 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def select(sym: Symbol)(using ctx: Context): Type = internal.Type_select(self)(sym) } - given (using ctx: Context) as IsInstanceOf[Type] = internal.isInstanceOfType + given (using ctx: Context) as TypeTest[TypeOrBounds, Type] = internal.Type_TypeTest object Type { def apply(clazz: Class[_])(using ctx: Context): Type = internal.Type_apply(clazz) } - given (using ctx: Context) as IsInstanceOf[ConstantType] = internal.isInstanceOfConstantType + given (using ctx: Context) as TypeTest[TypeOrBounds, ConstantType] = internal.ConstantType_TypeTest object ConstantType { def apply(x : Constant)(using ctx: Context): ConstantType = internal.ConstantType_apply(x) @@ -1718,7 +1718,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def constant(using ctx: Context): Constant = internal.ConstantType_constant(self) } - given (using ctx: Context) as IsInstanceOf[TermRef] = internal.isInstanceOfTermRef + given (using ctx: Context) as TypeTest[TypeOrBounds, TermRef] = internal.TermRef_TypeTest object TermRef { def apply(qual: TypeOrBounds, name: String)(using ctx: Context): TermRef = @@ -1732,7 +1732,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def name(using ctx: Context): String = internal.TermRef_name(self) } - given (using ctx: Context) as IsInstanceOf[TypeRef] = internal.isInstanceOfTypeRef + given (using ctx: Context) as TypeTest[TypeOrBounds, TypeRef] = internal.TypeRef_TypeTest object TypeRef { def unapply(x: TypeRef)(using ctx: Context): Option[(TypeOrBounds /* Type | NoPrefix */, String)] = @@ -1746,7 +1746,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def translucentSuperType(using ctx: Context): Type = internal.TypeRef_translucentSuperType(self) } - given (using ctx: Context) as IsInstanceOf[SuperType] = internal.isInstanceOfSuperType + given (using ctx: Context) as TypeTest[TypeOrBounds, SuperType] = internal.SuperType_TypeTest object SuperType { def apply(thistpe: Type, supertpe: Type)(using ctx: Context): SuperType = @@ -1761,7 +1761,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def supertpe(using ctx: Context): Type = internal.SuperType_supertpe(self) } - given (using ctx: Context) as IsInstanceOf[Refinement] = internal.isInstanceOfRefinement + given (using ctx: Context) as TypeTest[TypeOrBounds, Refinement] = internal.Refinement_TypeTest object Refinement { def apply(parent: Type, name: String, info: TypeOrBounds /* Type | TypeBounds */)(using ctx: Context): Refinement = @@ -1777,7 +1777,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def info(using ctx: Context): TypeOrBounds = internal.Refinement_info(self) } - given (using ctx: Context) as IsInstanceOf[AppliedType] = internal.isInstanceOfAppliedType + given (using ctx: Context) as TypeTest[TypeOrBounds, AppliedType] = internal.AppliedType_TypeTest object AppliedType { def apply(tycon: Type, args: List[TypeOrBounds])(using ctx: Context): AppliedType = @@ -1791,7 +1791,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def args(using ctx: Context): List[TypeOrBounds /* Type | TypeBounds */] = internal.AppliedType_args(self) } - given (using ctx: Context) as IsInstanceOf[AnnotatedType] = internal.isInstanceOfAnnotatedType + given (using ctx: Context) as TypeTest[TypeOrBounds, AnnotatedType] = internal.AnnotatedType_TypeTest object AnnotatedType { def apply(underlying: Type, annot: Term)(using ctx: Context): AnnotatedType = @@ -1805,7 +1805,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def annot(using ctx: Context): Term = internal.AnnotatedType_annot(self) } - given (using ctx: Context) as IsInstanceOf[AndType] = internal.isInstanceOfAndType + given (using ctx: Context) as TypeTest[TypeOrBounds, AndType] = internal.AndType_TypeTest object AndType { def apply(lhs: Type, rhs: Type)(using ctx: Context): AndType = @@ -1819,7 +1819,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def right(using ctx: Context): Type = internal.AndType_right(self) } - given (using ctx: Context) as IsInstanceOf[OrType] = internal.isInstanceOfOrType + given (using ctx: Context) as TypeTest[TypeOrBounds, OrType] = internal.OrType_TypeTest object OrType { def apply(lhs: Type, rhs: Type)(using ctx: Context): OrType = internal.OrType_apply(lhs, rhs) @@ -1832,7 +1832,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def right(using ctx: Context): Type = internal.OrType_right(self) } - given (using ctx: Context) as IsInstanceOf[MatchType] = internal.isInstanceOfMatchType + given (using ctx: Context) as TypeTest[TypeOrBounds, MatchType] = internal.MatchType_TypeTest object MatchType { def apply(bound: Type, scrutinee: Type, cases: List[Type])(using ctx: Context): MatchType = @@ -1855,7 +1855,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => Type(classOf[MatchCase[_,_]]) } - given (using ctx: Context) as IsInstanceOf[ByNameType] = internal.isInstanceOfByNameType + given (using ctx: Context) as TypeTest[TypeOrBounds, ByNameType] = internal.ByNameType_TypeTest object ByNameType { def apply(underlying: Type)(using ctx: Context): Type = internal.ByNameType_apply(underlying) @@ -1866,7 +1866,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def underlying(using ctx: Context): Type = internal.ByNameType_underlying(self) } - given (using ctx: Context) as IsInstanceOf[ParamRef] = internal.isInstanceOfParamRef + given (using ctx: Context) as TypeTest[TypeOrBounds, ParamRef] = internal.ParamRef_TypeTest object ParamRef { def unapply(x: ParamRef)(using ctx: Context): Option[(LambdaType[TypeOrBounds], Int)] = @@ -1878,7 +1878,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def paramNum(using ctx: Context): Int = internal.ParamRef_paramNum(self) } - given (using ctx: Context) as IsInstanceOf[ThisType] = internal.isInstanceOfThisType + given (using ctx: Context) as TypeTest[TypeOrBounds, ThisType] = internal.ThisType_TypeTest object ThisType { def unapply(x: ThisType)(using ctx: Context): Option[Type] = Some(x.tref) @@ -1888,7 +1888,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def tref(using ctx: Context): Type = internal.ThisType_tref(self) } - given (using ctx: Context) as IsInstanceOf[RecursiveThis] = internal.isInstanceOfRecursiveThis + given (using ctx: Context) as TypeTest[TypeOrBounds, RecursiveThis] = internal.RecursiveThis_TypeTest object RecursiveThis { def unapply(x: RecursiveThis)(using ctx: Context): Option[RecursiveType] = Some(x.binder) @@ -1898,7 +1898,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def binder(using ctx: Context): RecursiveType = internal.RecursiveThis_binder(self) } - given (using ctx: Context) as IsInstanceOf[RecursiveType] = internal.isInstanceOfRecursiveType + given (using ctx: Context) as TypeTest[TypeOrBounds, RecursiveType] = internal.RecursiveType_TypeTest object RecursiveType { @@ -1922,7 +1922,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def recThis(using ctx: Context): RecursiveThis = internal.RecursiveThis_recThis(self) } - given (using ctx: Context) as IsInstanceOf[MethodType] = internal.isInstanceOfMethodType + given (using ctx: Context) as TypeTest[TypeOrBounds, MethodType] = internal.MethodType_TypeTest object MethodType { def apply(paramNames: List[String])(paramInfosExp: MethodType => List[Type], resultTypeExp: MethodType => Type): MethodType = @@ -1941,7 +1941,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def resType(using ctx: Context): Type = internal.MethodType_resType(self) } - given (using ctx: Context) as IsInstanceOf[PolyType] = internal.isInstanceOfPolyType + given (using ctx: Context) as TypeTest[TypeOrBounds, PolyType] = internal.PolyType_TypeTest object PolyType { def apply(paramNames: List[String])(paramBoundsExp: PolyType => List[TypeBounds], resultTypeExp: PolyType => Type)(using ctx: Context): PolyType = @@ -1957,7 +1957,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def resType(using ctx: Context): Type = internal.PolyType_resType(self) } - given (using ctx: Context) as IsInstanceOf[TypeLambda] = internal.isInstanceOfTypeLambda + given (using ctx: Context) as TypeTest[TypeOrBounds, TypeLambda] = internal.TypeLambda_TypeTest object TypeLambda { def apply(paramNames: List[String], boundsFn: TypeLambda => List[TypeBounds], bodyFn: TypeLambda => Type): TypeLambda = @@ -1975,7 +1975,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => // ----- TypeBounds ----------------------------------------------- - given (using ctx: Context) as IsInstanceOf[TypeBounds] = internal.isInstanceOfTypeBounds + given (using ctx: Context) as TypeTest[TypeOrBounds, TypeBounds] = internal.TypeBounds_TypeTest object TypeBounds { def apply(low: Type, hi: Type)(using ctx: Context): TypeBounds = @@ -1990,7 +1990,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => // ----- NoPrefix ------------------------------------------------- - given (using ctx: Context) as IsInstanceOf[NoPrefix] = internal.isInstanceOfNoPrefix + given (using ctx: Context) as TypeTest[TypeOrBounds, NoPrefix] = internal.NoPrefix_TypeTest object NoPrefix: def unapply(x: NoPrefix)(using ctx: Context): Boolean = true @@ -2067,23 +2067,23 @@ class Reflection(private[scala] val internal: CompilerInterface) { self => def searchImplicit(tpe: Type)(using ctx: Context): ImplicitSearchResult = internal.searchImplicit(tpe) - given (using ctx: Context) as IsInstanceOf[ImplicitSearchSuccess] = internal.isInstanceOfImplicitSearchSuccess + given (using ctx: Context) as TypeTest[ImplicitSearchResult, ImplicitSearchSuccess] = internal.ImplicitSearchSuccess_TypeTest extension successOps on (self: ImplicitSearchSuccess) { def tree(using ctx: Context): Term = internal.ImplicitSearchSuccess_tree(self) } - given (using ctx: Context) as IsInstanceOf[ImplicitSearchFailure] = internal.isInstanceOfImplicitSearchFailure + given (using ctx: Context) as TypeTest[ImplicitSearchResult, ImplicitSearchFailure] = internal.ImplicitSearchFailure_TypeTest extension failureOps on (self: ImplicitSearchFailure) { def explanation(using ctx: Context): String = internal.ImplicitSearchFailure_explanation(self) } - given (using ctx: Context) as IsInstanceOf[DivergingImplicit] = internal.isInstanceOfDivergingImplicit + given (using ctx: Context) as TypeTest[ImplicitSearchResult, DivergingImplicit] = internal.DivergingImplicit_TypeTest - given (using ctx: Context) as IsInstanceOf[NoMatchingImplicits] = internal.isInstanceOfNoMatchingImplicits + given (using ctx: Context) as TypeTest[ImplicitSearchResult, NoMatchingImplicits] = internal.NoMatchingImplicits_TypeTest - given (using ctx: Context) as IsInstanceOf[AmbiguousImplicits] = internal.isInstanceOfAmbiguousImplicits + given (using ctx: Context) as TypeTest[ImplicitSearchResult, AmbiguousImplicits] = internal.AmbiguousImplicits_TypeTest ///////////// diff --git a/library/src/scala/tasty/reflect/CompilerInterface.scala b/library/src/scala/tasty/reflect/CompilerInterface.scala index 354d317cf2b8..6f63d86b6948 100644 --- a/library/src/scala/tasty/reflect/CompilerInterface.scala +++ b/library/src/scala/tasty/reflect/CompilerInterface.scala @@ -215,7 +215,7 @@ trait CompilerInterface { /** Tree representing a pacakage clause in the source code */ type PackageClause <: Tree - def isInstanceOfPackageClause(using ctx: Context): IsInstanceOf[PackageClause] + def PackageClause_TypeTest(using ctx: Context): TypeTest[Tree, PackageClause] def PackageClause_pid(self: PackageClause)(using ctx: Context): Ref def PackageClause_stats(self: PackageClause)(using ctx: Context): List[Tree] @@ -227,12 +227,12 @@ trait CompilerInterface { /** Tree representing a statement in the source code */ type Statement <: Tree - def isInstanceOfStatement(using ctx: Context): IsInstanceOf[Statement] + def Statement_TypeTest(using ctx: Context): TypeTest[Tree, Statement] /** Tree representing an import in the source code */ type Import <: Statement - def isInstanceOfImport(using ctx: Context): IsInstanceOf[Import] + def Import_TypeTest(using ctx: Context): TypeTest[Tree, Import] def Import_implied(self: Import): Boolean def Import_expr(self: Import)(using ctx: Context): Term @@ -245,14 +245,14 @@ trait CompilerInterface { /** Tree representing a definition in the source code. It can be `PackageDef`, `ClassDef`, `TypeDef`, `DefDef` or `ValDef` */ type Definition <: Statement - def isInstanceOfDefinition(using ctx: Context): IsInstanceOf[Definition] + def Definition_TypeTest(using ctx: Context): TypeTest[Tree, Definition] def Definition_name(self: Definition)(using ctx: Context): String /** Tree representing a package definition. This includes definitions in all source files */ type PackageDef <: Definition - def isInstanceOfPackageDef(using ctx: Context): IsInstanceOf[PackageDef] + def PackageDef_TypeTest(using ctx: Context): TypeTest[Tree, PackageDef] def PackageDef_owner(self: PackageDef)(using ctx: Context): PackageDef def PackageDef_members(self: PackageDef)(using ctx: Context): List[Statement] @@ -260,7 +260,7 @@ trait CompilerInterface { /** Tree representing a class definition. This includes annonymus class definitions and the class of a module object */ type ClassDef <: Definition - def isInstanceOfClassDef(using ctx: Context): IsInstanceOf[ClassDef] + def ClassDef_TypeTest(using ctx: Context): TypeTest[Tree, ClassDef] def ClassDef_constructor(self: ClassDef)(using ctx: Context): DefDef def ClassDef_parents(self: ClassDef)(using ctx: Context): List[Tree/* Term | TypeTree */] @@ -273,7 +273,7 @@ trait CompilerInterface { /** Tree representing a type (parameter or member) definition in the source code */ type TypeDef <: Definition - def isInstanceOfTypeDef(using ctx: Context): IsInstanceOf[TypeDef] + def TypeDef_TypeTest(using ctx: Context): TypeTest[Tree, TypeDef] def TypeDef_rhs(self: TypeDef)(using ctx: Context): Tree /*TypeTree | TypeBoundsTree*/ @@ -283,7 +283,7 @@ trait CompilerInterface { /** Tree representing a method definition in the source code */ type DefDef <: Definition - def isInstanceOfDefDef(using ctx: Context): IsInstanceOf[DefDef] + def DefDef_TypeTest(using ctx: Context): TypeTest[Tree, DefDef] def DefDef_typeParams(self: DefDef)(using ctx: Context): List[TypeDef] def DefDef_paramss(self: DefDef)(using ctx: Context): List[List[ValDef]] @@ -296,7 +296,7 @@ trait CompilerInterface { /** Tree representing a value definition in the source code This inclues `val`, `lazy val`, `var`, `object` and parameter definitions. */ type ValDef <: Definition - def isInstanceOfValDef(using ctx: Context): IsInstanceOf[ValDef] + def ValDef_TypeTest(using ctx: Context): TypeTest[Tree, ValDef] def ValDef_tpt(self: ValDef)(using ctx: Context): TypeTree def ValDef_rhs(self: ValDef)(using ctx: Context): Option[Term] @@ -307,7 +307,7 @@ trait CompilerInterface { /** Tree representing an expression in the source code */ type Term <: Statement - def isInstanceOfTerm(using ctx: Context): IsInstanceOf[Term] + def Term_TypeTest(using ctx: Context): TypeTest[Tree, Term] def Term_tpe(self: Term)(using ctx: Context): Type def Term_underlyingArgument(self: Term)(using ctx: Context): Term @@ -317,7 +317,7 @@ trait CompilerInterface { /** Tree representing a reference to definition */ type Ref <: Term - def isInstanceOfRef(using ctx: Context): IsInstanceOf[Ref] + def Ref_TypeTest(using ctx: Context): TypeTest[Tree, Ref] /** A tree representing the same reference as the given type */ def Ref_term(tp: TermRef)(using ctx: Context): Ref @@ -327,7 +327,7 @@ trait CompilerInterface { /** Tree representing a reference to definition with a given name */ type Ident <: Ref - def isInstanceOfIdent(using ctx: Context): IsInstanceOf[Ident] + def Ident_TypeTest(using ctx: Context): TypeTest[Tree, Ident] def Ident_name(self: Ident)(using ctx: Context): String @@ -337,7 +337,7 @@ trait CompilerInterface { /** Tree representing a selection of definition with a given name on a given prefix */ type Select <: Ref - def isInstanceOfSelect(using ctx: Context): IsInstanceOf[Select] + def Select_TypeTest(using ctx: Context): TypeTest[Tree, Select] def Select_qualifier(self: Select)(using ctx: Context): Term def Select_name(self: Select)(using ctx: Context): String @@ -352,7 +352,7 @@ trait CompilerInterface { /** Tree representing a literal value in the source code */ type Literal <: Term - def isInstanceOfLiteral(using ctx: Context): IsInstanceOf[Literal] + def Literal_TypeTest(using ctx: Context): TypeTest[Tree, Literal] def Literal_constant(self: Literal)(using ctx: Context): Constant @@ -362,7 +362,7 @@ trait CompilerInterface { /** Tree representing `this` in the source code */ type This <: Term - def isInstanceOfThis(using ctx: Context): IsInstanceOf[This] + def This_TypeTest(using ctx: Context): TypeTest[Tree, This] def This_id(self: This)(using ctx: Context): Option[Id] @@ -372,7 +372,7 @@ trait CompilerInterface { /** Tree representing `new` in the source code */ type New <: Term - def isInstanceOfNew(using ctx: Context): IsInstanceOf[New] + def New_TypeTest(using ctx: Context): TypeTest[Tree, New] def New_tpt(self: New)(using ctx: Context): TypeTree @@ -382,7 +382,7 @@ trait CompilerInterface { /** Tree representing an argument passed with an explicit name. Such as `arg1 = x` in `foo(arg1 = x)` */ type NamedArg <: Term - def isInstanceOfNamedArg(using ctx: Context): IsInstanceOf[NamedArg] + def NamedArg_TypeTest(using ctx: Context): TypeTest[Tree, NamedArg] def NamedArg_name(self: NamedArg)(using ctx: Context): String def NamedArg_value(self: NamedArg)(using ctx: Context): Term @@ -393,7 +393,7 @@ trait CompilerInterface { /** Tree an application of arguments. It represents a single list of arguments, multiple argument lists will have nested `Apply`s */ type Apply <: Term - def isInstanceOfApply(using ctx: Context): IsInstanceOf[Apply] + def Apply_TypeTest(using ctx: Context): TypeTest[Tree, Apply] def Apply_fun(self: Apply)(using ctx: Context): Term def Apply_args(self: Apply)(using ctx: Context): List[Term] @@ -404,7 +404,7 @@ trait CompilerInterface { /** Tree an application of type arguments */ type TypeApply <: Term - def isInstanceOfTypeApply(using ctx: Context): IsInstanceOf[TypeApply] + def TypeApply_TypeTest(using ctx: Context): TypeTest[Tree, TypeApply] def TypeApply_fun(self: TypeApply)(using ctx: Context): Term def TypeApply_args(self: TypeApply)(using ctx: Context): List[TypeTree] @@ -415,7 +415,7 @@ trait CompilerInterface { /** Tree representing `super` in the source code */ type Super <: Term - def isInstanceOfSuper(using ctx: Context): IsInstanceOf[Super] + def Super_TypeTest(using ctx: Context): TypeTest[Tree, Super] def Super_qualifier(self: Super)(using ctx: Context): Term def Super_id(self: Super)(using ctx: Context): Option[Id] @@ -426,7 +426,7 @@ trait CompilerInterface { /** Tree representing a type ascription `x: T` in the source code */ type Typed <: Term - def isInstanceOfTyped(using ctx: Context): IsInstanceOf[Typed] + def Typed_TypeTest(using ctx: Context): TypeTest[Tree, Typed] def Typed_expr(self: Typed)(using ctx: Context): Term def Typed_tpt(self: Typed)(using ctx: Context): TypeTree @@ -437,7 +437,7 @@ trait CompilerInterface { /** Tree representing an assignment `x = y` in the source code */ type Assign <: Term - def isInstanceOfAssign(using ctx: Context): IsInstanceOf[Assign] + def Assign_TypeTest(using ctx: Context): TypeTest[Tree, Assign] def Assign_lhs(self: Assign)(using ctx: Context): Term def Assign_rhs(self: Assign)(using ctx: Context): Term @@ -448,7 +448,7 @@ trait CompilerInterface { /** Tree representing a block `{ ... }` in the source code */ type Block <: Term - def isInstanceOfBlock(using ctx: Context): IsInstanceOf[Block] + def Block_TypeTest(using ctx: Context): TypeTest[Tree, Block] def Block_statements(self: Block)(using ctx: Context): List[Statement] def Block_expr(self: Block)(using ctx: Context): Term @@ -467,7 +467,7 @@ trait CompilerInterface { */ type Closure <: Term - def isInstanceOfClosure(using ctx: Context): IsInstanceOf[Closure] + def Closure_TypeTest(using ctx: Context): TypeTest[Tree, Closure] def Closure_meth(self: Closure)(using ctx: Context): Term def Closure_tpeOpt(self: Closure)(using ctx: Context): Option[Type] @@ -480,7 +480,7 @@ trait CompilerInterface { /** Tree representing an if/then/else `if (...) ... else ...` in the source code */ type If <: Term - def isInstanceOfIf(using ctx: Context): IsInstanceOf[If] + def If_TypeTest(using ctx: Context): TypeTest[Tree, If] def If_cond(self: If)(using ctx: Context): Term def If_thenp(self: If)(using ctx: Context): Term @@ -492,7 +492,7 @@ trait CompilerInterface { /** Tree representing a pattern match `x match { ... }` in the source code */ type Match <: Term - def isInstanceOfMatch(using ctx: Context): IsInstanceOf[Match] + def Match_TypeTest(using ctx: Context): TypeTest[Tree, Match] def Match_scrutinee(self: Match)(using ctx: Context): Term def Match_cases(self: Match)(using ctx: Context): List[CaseDef] @@ -503,7 +503,7 @@ trait CompilerInterface { /** Tree representing a pattern match `given match { ... }` in the source code */ type GivenMatch <: Term - def isInstanceOfGivenMatch(using ctx: Context): IsInstanceOf[GivenMatch] + def GivenMatch_TypeTest(using ctx: Context): TypeTest[Tree, GivenMatch] def GivenMatch_cases(self: GivenMatch)(using ctx: Context): List[CaseDef] @@ -513,7 +513,7 @@ trait CompilerInterface { /** Tree representing a tyr catch `try x catch { ... } finally { ... }` in the source code */ type Try <: Term - def isInstanceOfTry(using ctx: Context): IsInstanceOf[Try] + def Try_TypeTest(using ctx: Context): TypeTest[Tree, Try] def Try_body(self: Try)(using ctx: Context): Term def Try_cases(self: Try)(using ctx: Context): List[CaseDef] @@ -525,7 +525,7 @@ trait CompilerInterface { /** Tree representing a `return` in the source code */ type Return <: Term - def isInstanceOfReturn(using ctx: Context): IsInstanceOf[Return] + def Return_TypeTest(using ctx: Context): TypeTest[Tree, Return] def Return_expr(self: Return)(using ctx: Context): Term @@ -535,7 +535,7 @@ trait CompilerInterface { /** Tree representing a variable argument list in the source code */ type Repeated <: Term - def isInstanceOfRepeated(using ctx: Context): IsInstanceOf[Repeated] + def Repeated_TypeTest(using ctx: Context): TypeTest[Tree, Repeated] def Repeated_elems(self: Repeated)(using ctx: Context): List[Term] def Repeated_elemtpt(self: Repeated)(using ctx: Context): TypeTree @@ -546,7 +546,7 @@ trait CompilerInterface { /** Tree representing the scope of an inlined tree */ type Inlined <: Term - def isInstanceOfInlined(using ctx: Context): IsInstanceOf[Inlined] + def Inlined_TypeTest(using ctx: Context): TypeTest[Tree, Inlined] def Inlined_call(self: Inlined)(using ctx: Context): Option[Tree/* Term | TypeTree */] def Inlined_bindings(self: Inlined)(using ctx: Context): List[Definition] @@ -558,7 +558,7 @@ trait CompilerInterface { /** Tree representing a selection of definition with a given name on a given prefix and number of nested scopes of inlined trees */ type SelectOuter <: Term - def isInstanceOfSelectOuter(using ctx: Context): IsInstanceOf[SelectOuter] + def SelectOuter_TypeTest(using ctx: Context): TypeTest[Tree, SelectOuter] def SelectOuter_qualifier(self: SelectOuter)(using ctx: Context): Term def SelectOuter_level(self: SelectOuter)(using ctx: Context): Int @@ -569,7 +569,7 @@ trait CompilerInterface { /** Tree representing a while loop */ type While <: Term - def isInstanceOfWhile(using ctx: Context): IsInstanceOf[While] + def While_TypeTest(using ctx: Context): TypeTest[Tree, While] def While_cond(self: While)(using ctx: Context): Term def While_body(self: While)(using ctx: Context): Term @@ -580,14 +580,14 @@ trait CompilerInterface { /** Type tree representing a type written in the source */ type TypeTree <: Tree - def isInstanceOfTypeTree(using ctx: Context): IsInstanceOf[TypeTree] + def TypeTree_TypeTest(using ctx: Context): TypeTest[Tree, TypeTree] def TypeTree_tpe(self: TypeTree)(using ctx: Context): Type /** Type tree representing an inferred type */ type Inferred <: TypeTree - def isInstanceOfInferred(using ctx: Context): IsInstanceOf[Inferred] + def Inferred_TypeTest(using ctx: Context): TypeTest[Tree, Inferred] def Inferred_apply(tpe: Type)(using ctx: Context): Inferred @@ -596,7 +596,7 @@ trait CompilerInterface { /** Type tree representing a reference to definition with a given name */ type TypeIdent <: TypeTree - def isInstanceOfTypeIdent(using ctx: Context): IsInstanceOf[TypeIdent] + def TypeIdent_TypeTest(using ctx: Context): TypeTest[Tree, TypeIdent] def TypeIdent_name(self: TypeIdent)(using ctx: Context): String @@ -605,7 +605,7 @@ trait CompilerInterface { /** Type tree representing a selection of definition with a given name on a given term prefix */ type TypeSelect <: TypeTree - def isInstanceOfTypeSelect(using ctx: Context): IsInstanceOf[TypeSelect] + def TypeSelect_TypeTest(using ctx: Context): TypeTest[Tree, TypeSelect] def TypeSelect_qualifier(self: TypeSelect)(using ctx: Context): Term def TypeSelect_name(self: TypeSelect)(using ctx: Context): String @@ -616,7 +616,7 @@ trait CompilerInterface { /** Type tree representing a selection of definition with a given name on a given type prefix */ type Projection <: TypeTree - def isInstanceOfProjection(using ctx: Context): IsInstanceOf[Projection] + def Projection_TypeTest(using ctx: Context): TypeTest[Tree, Projection] def Projection_qualifier(self: Projection)(using ctx: Context): TypeTree def Projection_name(self: Projection)(using ctx: Context): String @@ -626,7 +626,7 @@ trait CompilerInterface { /** Type tree representing a singleton type */ type Singleton <: TypeTree - def isInstanceOfSingleton(using ctx: Context): IsInstanceOf[Singleton] + def Singleton_TypeTest(using ctx: Context): TypeTest[Tree, Singleton] def Singleton_ref(self: Singleton)(using ctx: Context): Term @@ -636,7 +636,7 @@ trait CompilerInterface { /** Type tree representing a type refinement */ type Refined <: TypeTree - def isInstanceOfRefined(using ctx: Context): IsInstanceOf[Refined] + def Refined_TypeTest(using ctx: Context): TypeTest[Tree, Refined] def Refined_tpt(self: Refined)(using ctx: Context): TypeTree def Refined_refinements(self: Refined)(using ctx: Context): List[Definition] @@ -646,7 +646,7 @@ trait CompilerInterface { /** Type tree representing a type application */ type Applied <: TypeTree - def isInstanceOfApplied(using ctx: Context): IsInstanceOf[Applied] + def Applied_TypeTest(using ctx: Context): TypeTest[Tree, Applied] def Applied_tpt(self: Applied)(using ctx: Context): TypeTree def Applied_args(self: Applied)(using ctx: Context): List[Tree /*TypeTree | TypeBoundsTree*/] @@ -657,7 +657,7 @@ trait CompilerInterface { /** Type tree representing an annotated type */ type Annotated <: TypeTree - def isInstanceOfAnnotated(using ctx: Context): IsInstanceOf[Annotated] + def Annotated_TypeTest(using ctx: Context): TypeTest[Tree, Annotated] def Annotated_arg(self: Annotated)(using ctx: Context): TypeTree def Annotated_annotation(self: Annotated)(using ctx: Context): Term @@ -668,7 +668,7 @@ trait CompilerInterface { /** Type tree representing a type match */ type MatchTypeTree <: TypeTree - def isInstanceOfMatchTypeTree(using ctx: Context): IsInstanceOf[MatchTypeTree] + def MatchTypeTree_TypeTest(using ctx: Context): TypeTest[Tree, MatchTypeTree] def MatchTypeTree_bound(self: MatchTypeTree)(using ctx: Context): Option[TypeTree] def MatchTypeTree_selector(self: MatchTypeTree)(using ctx: Context): TypeTree @@ -682,7 +682,7 @@ trait CompilerInterface { def ByName_result(self: ByName)(using ctx: Context): TypeTree - def isInstanceOfByName(using ctx: Context): IsInstanceOf[ByName] + def ByName_TypeTest(using ctx: Context): TypeTest[Tree, ByName] def ByName_apply(result: TypeTree)(using ctx: Context): ByName def ByName_copy(original: Tree)(result: TypeTree)(using ctx: Context): ByName @@ -690,7 +690,7 @@ trait CompilerInterface { /** Type tree representing a lambda abstraction type */ type LambdaTypeTree <: TypeTree - def isInstanceOfLambdaTypeTree(using ctx: Context): IsInstanceOf[LambdaTypeTree] + def LambdaTypeTree_TypeTest(using ctx: Context): TypeTest[Tree, LambdaTypeTree] def Lambdatparams(self: LambdaTypeTree)(using ctx: Context): List[TypeDef] def Lambdabody(self: LambdaTypeTree)(using ctx: Context): Tree /*TypeTree | TypeBoundsTree*/ @@ -701,7 +701,7 @@ trait CompilerInterface { /** Type tree representing a type binding */ type TypeBind <: TypeTree - def isInstanceOfTypeBind(using ctx: Context): IsInstanceOf[TypeBind] + def TypeBind_TypeTest(using ctx: Context): TypeTest[Tree, TypeBind] def TypeBind_name(self: TypeBind)(using ctx: Context): String def TypeBind_body(self: TypeBind)(using ctx: Context): Tree /*TypeTree | TypeBoundsTree*/ @@ -711,7 +711,7 @@ trait CompilerInterface { /** Type tree within a block with aliases `{ type U1 = ... ; T[U1, U2] }` */ type TypeBlock <: TypeTree - def isInstanceOfTypeBlock(using ctx: Context): IsInstanceOf[TypeBlock] + def TypeBlock_TypeTest(using ctx: Context): TypeTest[Tree, TypeBlock] def TypeBlock_aliases(self: TypeBlock)(using ctx: Context): List[TypeDef] def TypeBlock_tpt(self: TypeBlock)(using ctx: Context): TypeTree @@ -722,7 +722,7 @@ trait CompilerInterface { /** Type tree representing a type bound written in the source */ type TypeBoundsTree <: Tree /*TypeTree | TypeBoundsTree*/ - def isInstanceOfTypeBoundsTree(using ctx: Context): IsInstanceOf[TypeBoundsTree] + def TypeBoundsTree_TypeTest(using ctx: Context): TypeTest[Tree, TypeBoundsTree] def TypeBoundsTree_tpe(self: TypeBoundsTree)(using ctx: Context): TypeBounds def TypeBoundsTree_low(self: TypeBoundsTree)(using ctx: Context): TypeTree @@ -734,14 +734,14 @@ trait CompilerInterface { */ type WildcardTypeTree <: Tree - def isInstanceOfWildcardTypeTree(using ctx: Context): IsInstanceOf[WildcardTypeTree] + def WildcardTypeTree_TypeTest(using ctx: Context): TypeTest[Tree, WildcardTypeTree] def WildcardTypeTree_tpe(self: WildcardTypeTree)(using ctx: Context): TypeOrBounds /** Branch of a pattern match or catch clause */ type CaseDef <: Tree - def isInstanceOfCaseDef(using ctx: Context): IsInstanceOf[CaseDef] + def CaseDef_TypeTest(using ctx: Context): TypeTest[Tree, CaseDef] def CaseDef_pattern(self: CaseDef)(using ctx: Context): Tree def CaseDef_guard(self: CaseDef)(using ctx: Context): Option[Term] @@ -753,7 +753,7 @@ trait CompilerInterface { /** Branch of a type pattern match */ type TypeCaseDef <: Tree - def isInstanceOfTypeCaseDef(using ctx: Context): IsInstanceOf[TypeCaseDef] + def TypeCaseDef_TypeTest(using ctx: Context): TypeTest[Tree, TypeCaseDef] def TypeCaseDef_pattern(self: TypeCaseDef)(using ctx: Context): TypeTree def TypeCaseDef_rhs(self: TypeCaseDef)(using ctx: Context): TypeTree @@ -768,7 +768,7 @@ trait CompilerInterface { /** Tree representing a binding pattern `_ @ _` */ type Bind <: Tree - def isInstanceOfBind(using ctx: Context): IsInstanceOf[Bind] + def Bind_TypeTest(using ctx: Context): TypeTest[Tree, Bind] def Tree_Bind_name(self: Bind)(using ctx: Context): String @@ -781,7 +781,7 @@ trait CompilerInterface { /** Tree representing an unapply pattern `Xyz(...)` */ type Unapply <: Tree - def isInstanceOfUnapply(using ctx: Context): IsInstanceOf[Unapply] + def Unapply_TypeTest(using ctx: Context): TypeTest[Tree, Unapply] def Tree_Unapply_fun(self: Unapply)(using ctx: Context): Term @@ -794,7 +794,7 @@ trait CompilerInterface { /** Tree representing pattern alternatives `X | Y | ...` */ type Alternatives <: Tree - def isInstanceOfAlternatives(using ctx: Context): IsInstanceOf[Alternatives] + def Alternatives_TypeTest(using ctx: Context): TypeTest[Tree, Alternatives] def Tree_Alternatives_patterns(self: Alternatives)(using ctx: Context): List[Tree] @@ -812,12 +812,12 @@ trait CompilerInterface { /** NoPrefix for a type selection */ type NoPrefix <: TypeOrBounds - def isInstanceOfNoPrefix(using ctx: Context): IsInstanceOf[NoPrefix] + def NoPrefix_TypeTest(using ctx: Context): TypeTest[Tree, NoPrefix] /** Type bounds */ type TypeBounds <: TypeOrBounds - def isInstanceOfTypeBounds(using ctx: Context): IsInstanceOf[TypeBounds] + def TypeBounds_TypeTest(using ctx: Context): TypeTest[TypeOrBounds, TypeBounds] def TypeBounds_apply(low: Type, hi: Type)(using ctx: Context): TypeBounds @@ -827,7 +827,7 @@ trait CompilerInterface { /** A type */ type Type <: TypeOrBounds - def isInstanceOfType(using ctx: Context): IsInstanceOf[Type] + def Type_TypeTest(using ctx: Context): TypeTest[TypeOrBounds, Type] def Type_apply(clazz: Class[_])(using ctx: Context): Type @@ -914,7 +914,7 @@ trait CompilerInterface { /** A singleton type representing a known constant value */ type ConstantType <: Type - def isInstanceOfConstantType(using ctx: Context): IsInstanceOf[ConstantType] + def ConstantType_TypeTest(using ctx: Context): TypeTest[TypeOrBounds, ConstantType] def ConstantType_apply(const : Constant)(using ctx : Context) : ConstantType @@ -923,7 +923,7 @@ trait CompilerInterface { /** Type of a reference to a term symbol */ type TermRef <: Type - def isInstanceOfTermRef(using ctx: Context): IsInstanceOf[TermRef] + def TermRef_TypeTest(using ctx: Context): TypeTest[TypeOrBounds, TermRef] def TermRef_apply(qual: TypeOrBounds, name: String)(using ctx: Context): TermRef @@ -933,7 +933,7 @@ trait CompilerInterface { /** Type of a reference to a type symbol */ type TypeRef <: Type - def isInstanceOfTypeRef(using ctx: Context): IsInstanceOf[TypeRef] + def TypeRef_TypeTest(using ctx: Context): TypeTest[TypeOrBounds, TypeRef] def TypeRef_qualifier(self: TypeRef)(using ctx: Context): TypeOrBounds def TypeRef_name(self: TypeRef)(using ctx: Context): String @@ -943,7 +943,7 @@ trait CompilerInterface { /** Type of a `super` reference */ type SuperType <: Type - def isInstanceOfSuperType(using ctx: Context): IsInstanceOf[SuperType] + def SuperType_TypeTest(using ctx: Context): TypeTest[TypeOrBounds, SuperType] def SuperType_apply(thistpe: Type, supertpe: Type)(using ctx: Context): SuperType @@ -953,7 +953,7 @@ trait CompilerInterface { /** A type with a type refinement `T { type U }` */ type Refinement <: Type - def isInstanceOfRefinement(using ctx: Context): IsInstanceOf[Refinement] + def Refinement_TypeTest(using ctx: Context): TypeTest[TypeOrBounds, Refinement] def Refinement_apply(parent: Type, name: String, info: TypeOrBounds /* Type | TypeBounds */)(using ctx: Context): Refinement @@ -964,7 +964,7 @@ trait CompilerInterface { /** A higher kinded type applied to some types `T[U]` */ type AppliedType <: Type - def isInstanceOfAppliedType(using ctx: Context): IsInstanceOf[AppliedType] + def AppliedType_TypeTest(using ctx: Context): TypeTest[TypeOrBounds, AppliedType] def AppliedType_tycon(self: AppliedType)(using ctx: Context): Type def AppliedType_args(self: AppliedType)(using ctx: Context): List[TypeOrBounds] @@ -974,7 +974,7 @@ trait CompilerInterface { /** A type with an anottation `T @foo` */ type AnnotatedType <: Type - def isInstanceOfAnnotatedType(using ctx: Context): IsInstanceOf[AnnotatedType] + def AnnotatedType_TypeTest(using ctx: Context): TypeTest[TypeOrBounds, AnnotatedType] def AnnotatedType_apply(underlying: Type, annot: Term)(using ctx: Context): AnnotatedType @@ -984,7 +984,7 @@ trait CompilerInterface { /** Intersection type `T & U` */ type AndType <: Type - def isInstanceOfAndType(using ctx: Context): IsInstanceOf[AndType] + def AndType_TypeTest(using ctx: Context): TypeTest[TypeOrBounds, AndType] def AndType_apply(lhs: Type, rhs: Type)(using ctx: Context): AndType @@ -994,7 +994,7 @@ trait CompilerInterface { /** Union type `T | U` */ type OrType <: Type - def isInstanceOfOrType(using ctx: Context): IsInstanceOf[OrType] + def OrType_TypeTest(using ctx: Context): TypeTest[TypeOrBounds, OrType] def OrType_apply(lhs : Type, rhs : Type)(using ctx : Context): OrType @@ -1004,7 +1004,7 @@ trait CompilerInterface { /** Type match `T match { case U => ... }` */ type MatchType <: Type - def isInstanceOfMatchType(using ctx: Context): IsInstanceOf[MatchType] + def MatchType_TypeTest(using ctx: Context): TypeTest[TypeOrBounds, MatchType] def MatchType_apply(bound: Type, scrutinee: Type, cases: List[Type])(using ctx: Context): MatchType @@ -1015,7 +1015,7 @@ trait CompilerInterface { /** Type of a by by name parameter */ type ByNameType <: Type - def isInstanceOfByNameType(using ctx: Context): IsInstanceOf[ByNameType] + def ByNameType_TypeTest(using ctx: Context): TypeTest[TypeOrBounds, ByNameType] def ByNameType_apply(underlying: Type)(using ctx: Context): Type @@ -1024,7 +1024,7 @@ trait CompilerInterface { /** Type of a parameter reference */ type ParamRef <: Type - def isInstanceOfParamRef(using ctx: Context): IsInstanceOf[ParamRef] + def ParamRef_TypeTest(using ctx: Context): TypeTest[TypeOrBounds, ParamRef] def ParamRef_binder(self: ParamRef)(using ctx: Context): LambdaType[TypeOrBounds] def ParamRef_paramNum(self: ParamRef)(using ctx: Context): Int @@ -1032,21 +1032,21 @@ trait CompilerInterface { /** Type of `this` */ type ThisType <: Type - def isInstanceOfThisType(using ctx: Context): IsInstanceOf[ThisType] + def ThisType_TypeTest(using ctx: Context): TypeTest[TypeOrBounds, ThisType] def ThisType_tref(self: ThisType)(using ctx: Context): Type /** A type that is recursively defined `this` */ type RecursiveThis <: Type - def isInstanceOfRecursiveThis(using ctx: Context): IsInstanceOf[RecursiveThis] + def RecursiveThis_TypeTest(using ctx: Context): TypeTest[TypeOrBounds, RecursiveThis] def RecursiveThis_binder(self: RecursiveThis)(using ctx: Context): RecursiveType /** A type that is recursively defined */ type RecursiveType <: Type - def isInstanceOfRecursiveType(using ctx: Context): IsInstanceOf[RecursiveType] + def RecursiveType_TypeTest(using ctx: Context): TypeTest[TypeOrBounds, RecursiveType] /** Create a RecType, normalizing its contents. This means: * @@ -1070,7 +1070,7 @@ trait CompilerInterface { /** Type of the definition of a method taking a single list of parameters. It's return type may be a MethodType. */ type MethodType <: LambdaType[Type] - def isInstanceOfMethodType(using ctx: Context): IsInstanceOf[MethodType] + def MethodType_TypeTest(using ctx: Context): TypeTest[TypeOrBounds, MethodType] def MethodType_apply(paramNames: List[String])(paramInfosExp: MethodType => List[Type], resultTypeExp: MethodType => Type): MethodType @@ -1084,7 +1084,7 @@ trait CompilerInterface { /** Type of the definition of a method taking a list of type parameters. It's return type may be a MethodType. */ type PolyType <: LambdaType[TypeBounds] - def isInstanceOfPolyType(using ctx: Context): IsInstanceOf[PolyType] + def PolyType_TypeTest(using ctx: Context): TypeTest[TypeOrBounds, PolyType] def PolyType_apply(paramNames: List[String])(paramBoundsExp: PolyType => List[TypeBounds], resultTypeExp: PolyType => Type)(using ctx: Context): PolyType @@ -1096,7 +1096,7 @@ trait CompilerInterface { /** Type of the definition of a type lambda taking a list of type parameters. It's return type may be a TypeLambda. */ type TypeLambda <: LambdaType[TypeBounds] - def isInstanceOfTypeLambda(using ctx: Context): IsInstanceOf[TypeLambda] + def TypeLambda_TypeTest(using ctx: Context): TypeTest[TypeOrBounds, TypeLambda] def TypeLambda_apply(paramNames: List[String], boundsFn: TypeLambda => List[TypeBounds], bodyFn: TypeLambda => Type): TypeLambda @@ -1119,20 +1119,20 @@ trait CompilerInterface { type SimpleSelector <: ImportSelector - def isInstanceOfSimpleSelector(using ctx: Context): IsInstanceOf[SimpleSelector] + def SimpleSelector_TypeTest(using ctx: Context): TypeTest[ImportSelector, SimpleSelector] def SimpleSelector_selection(self: SimpleSelector)(using ctx: Context): Id type RenameSelector <: ImportSelector - def isInstanceOfRenameSelector(using ctx: Context): IsInstanceOf[RenameSelector] + def RenameSelector_TypeTest(using ctx: Context): TypeTest[ImportSelector, RenameSelector] def RenameSelector_from(self: RenameSelector)(using ctx: Context): Id def RenameSelector_to(self: RenameSelector)(using ctx: Context): Id type OmitSelector <: ImportSelector - def isInstanceOfOmitSelector(using ctx: Context): IsInstanceOf[OmitSelector] + def OmitSelector_TypeTest(using ctx: Context): TypeTest[ImportSelector, OmitSelector] def SimpleSelector_omitted(self: OmitSelector)(using ctx: Context): Id @@ -1587,21 +1587,21 @@ trait CompilerInterface { type ImplicitSearchResult <: AnyRef type ImplicitSearchSuccess <: ImplicitSearchResult - def isInstanceOfImplicitSearchSuccess(using ctx: Context): IsInstanceOf[ImplicitSearchSuccess] + def ImplicitSearchSuccess_TypeTest(using ctx: Context): TypeTest[ImplicitSearchResult, ImplicitSearchSuccess] def ImplicitSearchSuccess_tree(self: ImplicitSearchSuccess)(using ctx: Context): Term type ImplicitSearchFailure <: ImplicitSearchResult - def isInstanceOfImplicitSearchFailure(using ctx: Context): IsInstanceOf[ImplicitSearchFailure] + def ImplicitSearchFailure_TypeTest(using ctx: Context): TypeTest[ImplicitSearchResult, ImplicitSearchFailure] def ImplicitSearchFailure_explanation(self: ImplicitSearchFailure)(using ctx: Context): String type DivergingImplicit <: ImplicitSearchFailure - def isInstanceOfDivergingImplicit(using ctx: Context): IsInstanceOf[DivergingImplicit] + def DivergingImplicit_TypeTest(using ctx: Context): TypeTest[ImplicitSearchResult, DivergingImplicit] type NoMatchingImplicits <: ImplicitSearchFailure - def isInstanceOfNoMatchingImplicits(using ctx: Context): IsInstanceOf[NoMatchingImplicits] + def NoMatchingImplicits_TypeTest(using ctx: Context): TypeTest[ImplicitSearchResult, NoMatchingImplicits] type AmbiguousImplicits <: ImplicitSearchFailure - def isInstanceOfAmbiguousImplicits(using ctx: Context): IsInstanceOf[AmbiguousImplicits] + def AmbiguousImplicits_TypeTest(using ctx: Context): TypeTest[ImplicitSearchResult, AmbiguousImplicits] /** Find an implicit of type `T` in the current scope given by `ctx`. * Return an `ImplicitSearchResult`. diff --git a/library/src/scala/tasty/reflect/IsInstanceOf.scala b/library/src/scala/tasty/reflect/IsInstanceOf.scala deleted file mode 100644 index ea1ca85e6f6e..000000000000 --- a/library/src/scala/tasty/reflect/IsInstanceOf.scala +++ /dev/null @@ -1,39 +0,0 @@ -package scala.tasty -package reflect -/* FIXME Using class tags to type tests abstract type members in unsound - - ``` - trait R { - type Nat - type Succ <: Nat - type Idx - given ClassTag[Nat] - given ClassTag[Succ] - given ClassTag[Idx] - def n: Nat - } - object RI extens R { - type Nat = Int - type Succ = Int - type Idx = Int - given ClassTag[Nat] = classOf[Integer] - given ClassTag[Succ] = new ClassTag[Integer] { - def runtimeClass = classOf[Integer] - def unapply(x: Any): Option[Succ] = x match - case n: Int if n > 0 => Some(n) - case _ => None - } - given ClassTag[Idx] = classOf[Integer] - def n: Nat = 4 - } - val r1: R = RI - val r2: R = RI - r1.n match { - case n: r2.Nat => // Should not match or should have an unchecked waring - case n: r1.Idx => // Should not match or should have an unchecked waring - case n: r1.Succ => // Should match only if r1.n is an r1.Succ under the constraints set in r1 - } - ``` -*/ -/** Place holder until we implement a ClassTag like abstraction that is sound for all type tests */ -type IsInstanceOf[T] = scala.reflect.ClassTag[T] diff --git a/library/src/scala/tasty/reflect/TypeTest.scala b/library/src/scala/tasty/reflect/TypeTest.scala new file mode 100644 index 000000000000..f93c7e952865 --- /dev/null +++ b/library/src/scala/tasty/reflect/TypeTest.scala @@ -0,0 +1,9 @@ +package scala.tasty +package reflect + +/** A type test that can check at runtime if an object of type T is also of type U. + * + * Place holder until we implement a ClassTag like abstraction that is sound for all type tests. + * See https://github.com/lampepfl/dotty/pull/7555 + */ +type TypeTest[T, U] = scala.reflect.ClassTag[U]