Skip to content

Remove NamedTermRef and NamedTypeRef #7001

New issue

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

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

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend

def Ident_name(self: Ident) given Context: String = self.name.show

def Ident_apply(tmref: NamedTermRef) given Context: Term =
def Ident_apply(tmref: TermRef) given Context: Term =
withDefaultPos(tpd.ref(tmref).asInstanceOf[Term])

def Ident_copy(original: Tree)(name: String) given Context: Ident =
Expand Down Expand Up @@ -1114,6 +1114,8 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend

def Type_typeSymbol(self: Type) given Context: Symbol = self.typeSymbol

def Type_termSymbol(self: Type) given Context: Symbol = self.termSymbol

def Type_isSingleton(self: Type) given Context: Boolean = self.isSingleton

def Type_memberType(self: Type)(member: Symbol) given Context: Type =
Expand Down Expand Up @@ -1148,46 +1150,27 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend
type TermRef = Types.NamedType

def matchTermRef(tpe: TypeOrBounds) given Context: Option[TermRef] = tpe match {
case tp: Types.NamedType =>
tp.designator match {
case sym: Symbol if sym.isTerm => Some(tp)
case _ => None
}
case tp: Types.TermRef => Some(tp)
case _ => None
}

def TermRef_apply(qual: TypeOrBounds, name: String) given Context: TermRef =
Types.TermRef(qual, name.toTermName)

def TermRef_qualifier(self: TermRef) given Context: TypeOrBounds = self.prefix

def matchTermRef_unapply(tpe: TypeOrBounds) given Context: Option[(Symbol, Type | NoPrefix)] = tpe match {
case tpe: Types.NamedType =>
tpe.designator match {
case sym: Symbol if sym.isTerm => Some((sym, tpe.prefix))
case _ => None
}
case _ => None
}
def TermRef_name(self: TermRef) given Context: String = self.name.toString

type TypeRef = Types.NamedType

def matchTypeRef(tpe: TypeOrBounds) given Context: Option[TypeRef] = tpe match {
case tp: Types.NamedType =>
tp.designator match {
case sym: Symbol if sym.isType => Some(tp)
case _ => None
}
case tp: Types.TypeRef => Some(tp)
case _ => None
}

def TypeRef_qualifier(self: TypeRef) given Context: TypeOrBounds = self.prefix

def matchTypeRef_unapply(tpe: TypeOrBounds) given Context: Option[(Symbol, Type | NoPrefix)] = tpe match {
case tpe: Types.NamedType =>
tpe.designator match {
case sym: Symbol if sym.isType => Some((sym, tpe.prefix))
case _ => None
}
case _ => None
}
def TypeRef_name(self: TypeRef) given Context: String = self.name.toString

type NamedTermRef = Types.NamedType

Expand All @@ -1203,23 +1186,6 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend
def NamedTermRef_name(self: NamedTermRef) given Context: String = self.name.toString
def NamedTermRef_qualifier(self: NamedTermRef) given Context: TypeOrBounds = self.prefix

def NamedTermRef_apply(qual: TypeOrBounds, name: String) given Context: NamedTermRef =
Types.TermRef(qual, name.toTermName)

type NamedTypeRef = Types.NamedType

def matchNamedTypeRef(tpe: TypeOrBounds) given Context: Option[NamedTypeRef] = tpe match {
case tpe: Types.NamedType =>
tpe.designator match {
case name: Names.TypeName => Some(tpe)
case _ => None
}
case _ => None
}

def NamedTypeRef_name(self: NamedTypeRef) given Context: String = self.name.toString
def NamedTypeRef_qualifier(self: NamedTypeRef) given Context: TypeOrBounds = self.prefix

type SuperType = Types.SuperType

def matchSuperType(tpe: TypeOrBounds) given Context: Option[SuperType] = tpe match {
Expand Down
32 changes: 7 additions & 25 deletions library/src/scala/tasty/reflect/CompilerInterface.scala
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ import scala.runtime.quoted.Unpickler
* +- Type -------+- ConstantType
* +- TermRef
* +- TypeRef
* +- NamedTermRef
* +- NamedTypeRef
* +- SuperType
* +- Refinement
* +- AppliedType
Expand Down Expand Up @@ -330,7 +328,7 @@ trait CompilerInterface {

def Ident_name(self: Ident) given (ctx: Context): String

def Ident_apply(tmref: NamedTermRef) given (ctx: Context): Term
def Ident_apply(tmref: TermRef) given (ctx: Context): Term
def Ident_copy(original: Tree)(name: String) given (ctx: Context): Ident

/** Tree representing a selection of definition with a given name on a given prefix */
Expand Down Expand Up @@ -878,10 +876,12 @@ trait CompilerInterface {
*/
def Type_dealias(self: Type) given (ctx: Context): Type

def Type_classSymbol(self: Type) given (ctx: Context): Option[ClassDefSymbol]
def Type_classSymbol(self: Type) given (ctx: Context): Option[ClassDefSymbol] // TODO remove Option and use NoSymbol

def Type_typeSymbol(self: Type) given (ctx: Context): Symbol

def Type_termSymbol(self: Type) given (ctx: Context): Symbol

def Type_isSingleton(self: Type) given (ctx: Context): Boolean

def Type_memberType(self: Type)(member: Symbol) given (ctx: Context): Type
Expand Down Expand Up @@ -931,36 +931,18 @@ trait CompilerInterface {

def matchTermRef(tpe: TypeOrBounds) given (ctx: Context): Option[TermRef]

def matchTermRef_unapply(tpe: TypeOrBounds) given (ctx: Context): Option[(Symbol, TypeOrBounds /* Type | NoPrefix */)]
def TermRef_apply(qual: TypeOrBounds, name: String) given (ctx: Context): TermRef

def TermRef_qualifier(self: TermRef) given (ctx: Context): TypeOrBounds
def TermRef_name(self: TermRef) given (ctx: Context): String

/** Type of a reference to a type symbol */
type TypeRef <: Type

def matchTypeRef(tpe: TypeOrBounds) given (ctx: Context): Option[TypeRef]

def matchTypeRef_unapply(tpe: TypeOrBounds) given (ctx: Context): Option[(Symbol, TypeOrBounds /* Type | NoPrefix */)]

def TypeRef_qualifier(self: TypeRef) given (ctx: Context): TypeOrBounds

/** Type of a reference to a term by it's name */
type NamedTermRef <: Type

def matchNamedTermRef(tpe: TypeOrBounds) given (ctx: Context): Option[NamedTermRef]

def NamedTermRef_name(self: NamedTermRef) given (ctx: Context): String
def NamedTermRef_qualifier(self: NamedTermRef) given (ctx: Context): TypeOrBounds

def NamedTermRef_apply(qual: TypeOrBounds, name: String) given (ctx: Context): NamedTermRef

/** Type of a reference to a type by it's name */
type NamedTypeRef <: Type

def matchNamedTypeRef(tpe: TypeOrBounds) given (ctx: Context): Option[NamedTypeRef]

def NamedTypeRef_name(self: NamedTypeRef) given (ctx: Context): String
def NamedTypeRef_qualifier(self: NamedTypeRef) given (ctx: Context): TypeOrBounds
def TypeRef_name(self: TypeRef) given Context: String

/** Type of a `super` refernce */
type SuperType <: Type
Expand Down
8 changes: 0 additions & 8 deletions library/src/scala/tasty/reflect/Core.scala
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ package scala.tasty.reflect
* +- Type -------+- ConstantType
* +- TermRef
* +- TypeRef
* +- NamedTermRef
* +- NamedTypeRef
* +- SuperType
* +- Refinement
* +- AppliedType
Expand Down Expand Up @@ -338,12 +336,6 @@ trait Core {
/** Type of a reference to a type symbol */
type TypeRef = internal.TypeRef

/** Type of a reference to a term */
type NamedTermRef = internal.NamedTermRef

/** Type of a reference to a type */
type NamedTypeRef = internal.NamedTypeRef

/** Type of a `super` refernce */
type SuperType = internal.SuperType

Expand Down
Loading