Skip to content

Commit 2166cc2

Browse files
committed
Split NameRef into TermName and TypeName
1 parent aeba19d commit 2166cc2

File tree

4 files changed

+28
-8
lines changed

4 files changed

+28
-8
lines changed

compiler/src/dotty/tools/dotc/tasty/TastyImpl.scala

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -578,11 +578,22 @@ object TastyImpl extends scala.tasty.Tasty {
578578
}
579579
}
580580

581-
val NameRef: NameRefExtractor = new NameRefExtractor {
581+
val TermRef: TermRefExtractor = new TermRefExtractor {
582582
def unapply(x: Type)(implicit ctx: Context): Option[(String, TypeOrBounds /* Type | NoPrefix */)] = x match {
583583
case tp: Types.NamedType =>
584584
tp.designator match {
585-
case name: Names.Name => Some(name.toString, tp.prefix)
585+
case name: Names.TermName => Some(name.toString, tp.prefix)
586+
case _ => None
587+
}
588+
case _ => None
589+
}
590+
}
591+
592+
val TypeRef: TypeRefExtractor = new TypeRefExtractor {
593+
def unapply(x: Type)(implicit ctx: Context): Option[(String, TypeOrBounds /* Type | NoPrefix */)] = x match {
594+
case tp: Types.NamedType =>
595+
tp.designator match {
596+
case name: Names.TypeName => Some(name.toString, tp.prefix)
586597
case _ => None
587598
}
588599
case _ => None

library/src/scala/tasty/Tasty.scala

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,8 +439,13 @@ abstract class Tasty {
439439
def unapply(x: Type)(implicit ctx: Context): Option[(Definition, TypeOrBounds /* Type | NoPrefix */)]
440440
}
441441

442-
val NameRef: NameRefExtractor
443-
abstract class NameRefExtractor {
442+
val TermRef: TermRefExtractor
443+
abstract class TermRefExtractor {
444+
def unapply(x: Type)(implicit ctx: Context): Option[(String, TypeOrBounds /* Type | NoPrefix */)]
445+
}
446+
447+
val TypeRef: TypeRefExtractor
448+
abstract class TypeRefExtractor {
444449
def unapply(x: Type)(implicit ctx: Context): Option[(String, TypeOrBounds /* Type | NoPrefix */)]
445450
}
446451

library/src/scala/tasty/util/TastyPrinter.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,8 +481,12 @@ class TastyPrinter[T <: Tasty with Singleton](val tasty: T) {
481481
buff append ", "
482482
visitType(qual)
483483
buff append ")"
484-
case NameRef(name, qual) =>
485-
buff append "NameRef(" append name append ", "
484+
case TermRef(name, qual) =>
485+
buff append "TermRef(" append name append ", "
486+
visitType(qual)
487+
buff append ")"
488+
case TypeRef(name, qual) =>
489+
buff append "TypeRef(" append name append ", "
486490
visitType(qual)
487491
buff append ")"
488492
case Refinement(parent, name, info) =>

tests/pos/tasty/definitions.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ object definitions {
122122

123123
case class ConstantType(value: Constant) extends Type
124124
case class SymRef(sym: Definition, qualifier: Type | NoPrefix = NoPrefix) extends Type
125-
case class TypeNameRef(name: String, qualifier: Type | NoPrefix = NoPrefix) extends Type // NoPrefix means: select from _root_
126-
case class TermNameRef(name: String, qualifier: Type | NoPrefix = NoPrefix) extends Type // NoPrefix means: select from _root_
125+
case class TypeRef(name: String, qualifier: Type | NoPrefix = NoPrefix) extends Type // NoPrefix means: select from _root_
126+
case class TermRef(name: String, qualifier: Type | NoPrefix = NoPrefix) extends Type // NoPrefix means: select from _root_
127127
case class SuperType(thistp: Type, underlying: Type) extends Type
128128
case class Refinement(underlying: Type, name: String, tpe: Type | TypeBounds) extends Type
129129
case class AppliedType(tycon: Type, args: List[Type | TypeBounds]) extends Type

0 commit comments

Comments
 (0)