Skip to content

Commit aeba19d

Browse files
committed
Rename MaybeType to TypeOrBounds
1 parent 9f9b64a commit aeba19d

File tree

8 files changed

+45
-45
lines changed

8 files changed

+45
-45
lines changed

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ object TastyImpl extends scala.tasty.Tasty {
186186
def typeDefClassTag: ClassTag[TypeDef] = implicitly[ClassTag[TypeDef]]
187187

188188
val TypeDef: TypeDefExtractor = new TypeDefExtractor {
189-
def unapply(x: TypeDef)(implicit ctx: Context): Option[(String, MaybeTypeTree /* TypeTree | TypeBoundsTree */)] = x match {
189+
def unapply(x: TypeDef)(implicit ctx: Context): Option[(String, TypeOrBoundsTree /* TypeTree | TypeBoundsTree */)] = x match {
190190
case x: tpd.TypeDef @unchecked if !x.symbol.isClass => Some((x.name.toString, x.rhs))
191191
case _ => None
192192
}
@@ -446,11 +446,11 @@ object TastyImpl extends scala.tasty.Tasty {
446446
}
447447
}
448448

449-
// ----- MaybeTypeTree ------------------------------------------------
449+
// ----- TypeOrBoundsTree ------------------------------------------------
450450

451-
type MaybeTypeTree = tpd.Tree
451+
type TypeOrBoundsTree = tpd.Tree
452452

453-
implicit def MaybeTypeTreeDeco(x: MaybeTypeTree): AbstractMaybeTypeTree = new AbstractMaybeTypeTree {
453+
implicit def TypeOrBoundsTreeDeco(x: TypeOrBoundsTree): AbstractTypeOrBoundsTree = new AbstractTypeOrBoundsTree {
454454
def tpe(implicit ctx: Context): Type = x.tpe.stripTypeVar
455455
}
456456

@@ -552,7 +552,7 @@ object TastyImpl extends scala.tasty.Tasty {
552552

553553
// ===== Types ====================================================
554554

555-
type MaybeType = Types.Type
555+
type TypeOrBounds = Types.Type
556556

557557
// ----- Types ----------------------------------------------------
558558

@@ -568,7 +568,7 @@ object TastyImpl extends scala.tasty.Tasty {
568568
}
569569

570570
val SymRef: SymRefExtractor = new SymRefExtractor {
571-
def unapply(x: Type)(implicit ctx: Context): Option[(Definition, MaybeType /* Type | NoPrefix */)] = x match {
571+
def unapply(x: Type)(implicit ctx: Context): Option[(Definition, TypeOrBounds /* Type | NoPrefix */)] = x match {
572572
case tp: Types.NamedType =>
573573
tp.designator match {
574574
case sym: Symbol => Some((FromSymbol.definition(sym), tp.prefix))
@@ -579,7 +579,7 @@ object TastyImpl extends scala.tasty.Tasty {
579579
}
580580

581581
val NameRef: NameRefExtractor = new NameRefExtractor {
582-
def unapply(x: Type)(implicit ctx: Context): Option[(String, MaybeType /* Type | NoPrefix */)] = x match {
582+
def unapply(x: Type)(implicit ctx: Context): Option[(String, TypeOrBounds /* Type | NoPrefix */)] = x match {
583583
case tp: Types.NamedType =>
584584
tp.designator match {
585585
case name: Names.Name => Some(name.toString, tp.prefix)
@@ -597,14 +597,14 @@ object TastyImpl extends scala.tasty.Tasty {
597597
}
598598

599599
val Refinement: RefinementExtractor = new RefinementExtractor {
600-
def unapply(x: Type)(implicit ctx: Context): Option[(Type, String, MaybeType /* Type | TypeBounds */)] = x match {
600+
def unapply(x: Type)(implicit ctx: Context): Option[(Type, String, TypeOrBounds /* Type | TypeBounds */)] = x match {
601601
case Types.RefinedType(parent, name, info) => Some(parent, name.toString, info)
602602
case _ => None
603603
}
604604
}
605605

606606
val AppliedType: AppliedTypeExtractor = new AppliedTypeExtractor {
607-
def unapply(x: Type)(implicit ctx: Context): Option[(Type, List[MaybeType /* Type | TypeBounds */])] = x match {
607+
def unapply(x: Type)(implicit ctx: Context): Option[(Type, List[TypeOrBounds /* Type | TypeBounds */])] = x match {
608608
case Types.AppliedType(tycon, args) => Some((tycon.stripTypeVar, args.map(_.stripTypeVar)))
609609
case _ => None
610610
}
@@ -639,10 +639,10 @@ object TastyImpl extends scala.tasty.Tasty {
639639
}
640640

641641
val ParamRef: ParamRefExtractor = new ParamRefExtractor {
642-
def unapply(x: Type)(implicit ctx: Context): Option[(LambdaType[MaybeType], Int)] = x match {
642+
def unapply(x: Type)(implicit ctx: Context): Option[(LambdaType[TypeOrBounds], Int)] = x match {
643643
case Types.TypeParamRef(binder, idx) =>
644644
Some((
645-
binder.asInstanceOf[LambdaType[MaybeType]], // Cast to tpd
645+
binder.asInstanceOf[LambdaType[TypeOrBounds]], // Cast to tpd
646646
idx))
647647
case _ => None
648648
}
@@ -675,7 +675,7 @@ object TastyImpl extends scala.tasty.Tasty {
675675

676676
// ----- Methodic Types -------------------------------------------
677677

678-
type LambdaType[ParamInfo <: MaybeType] = Types.LambdaType { type PInfo = ParamInfo }
678+
type LambdaType[ParamInfo <: TypeOrBounds] = Types.LambdaType { type PInfo = ParamInfo }
679679

680680
type MethodType = Types.MethodType
681681

library/src/scala/tasty/Tasty.scala

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ abstract class Tasty {
146146

147147
val TypeDef: TypeDefExtractor
148148
abstract class TypeDefExtractor {
149-
def unapply(x: TypeDef)(implicit ctx: Context): Option[(String, MaybeTypeTree /* TypeTree | TypeBoundsTree */)]
149+
def unapply(x: TypeDef)(implicit ctx: Context): Option[(String, TypeOrBoundsTree /* TypeTree | TypeBoundsTree */)]
150150
}
151151

152152
// PackageDef
@@ -332,17 +332,17 @@ abstract class Tasty {
332332

333333
// ----- TypeTrees ------------------------------------------------
334334

335-
type MaybeTypeTree
335+
type TypeOrBoundsTree
336336

337-
trait AbstractMaybeTypeTree {
338-
def tpe(implicit ctx: Context): MaybeType
337+
trait AbstractTypeOrBoundsTree {
338+
def tpe(implicit ctx: Context): TypeOrBounds
339339
}
340-
implicit def MaybeTypeTreeDeco(x: MaybeTypeTree): AbstractMaybeTypeTree
340+
implicit def TypeOrBoundsTreeDeco(x: TypeOrBoundsTree): AbstractTypeOrBoundsTree
341341

342342

343343
// ----- TypeTrees ------------------------------------------------
344344

345-
type TypeTree <: MaybeTypeTree
345+
type TypeTree <: TypeOrBoundsTree
346346

347347
trait AbstractTypeTree extends Typed with Positioned
348348
implicit def TypeTreeDeco(x: TypeTree): AbstractTypeTree
@@ -401,7 +401,7 @@ abstract class Tasty {
401401

402402
// ----- TypeBoundsTrees ------------------------------------------------
403403

404-
type TypeBoundsTree <: MaybeTypeTree
404+
type TypeBoundsTree <: TypeOrBoundsTree
405405

406406
trait AbstractTypeBoundsTree {
407407
def tpe: TypeBounds
@@ -417,15 +417,15 @@ abstract class Tasty {
417417

418418
// ===== Types ====================================================
419419

420-
type MaybeType
420+
type TypeOrBounds
421421

422422
trait Typed {
423423
def tpe(implicit ctx: Context): Type
424424
}
425425

426426
// ----- Types ----------------------------------------------------
427427

428-
type Type <: MaybeType
428+
type Type <: TypeOrBounds
429429

430430
implicit def typeClassTag: ClassTag[Type]
431431

@@ -436,12 +436,12 @@ abstract class Tasty {
436436

437437
val SymRef: SymRefExtractor
438438
abstract class SymRefExtractor {
439-
def unapply(x: Type)(implicit ctx: Context): Option[(Definition, MaybeType /* Type | NoPrefix */)]
439+
def unapply(x: Type)(implicit ctx: Context): Option[(Definition, TypeOrBounds /* Type | NoPrefix */)]
440440
}
441441

442442
val NameRef: NameRefExtractor
443443
abstract class NameRefExtractor {
444-
def unapply(x: Type)(implicit ctx: Context): Option[(String, MaybeType /* Type | NoPrefix */)]
444+
def unapply(x: Type)(implicit ctx: Context): Option[(String, TypeOrBounds /* Type | NoPrefix */)]
445445
}
446446

447447
val SuperType: SuperTypeExtractor
@@ -451,12 +451,12 @@ abstract class Tasty {
451451

452452
val Refinement: RefinementExtractor
453453
abstract class RefinementExtractor {
454-
def unapply(x: Type)(implicit ctx: Context): Option[(Type, String, MaybeType /* Type | TypeBounds */)]
454+
def unapply(x: Type)(implicit ctx: Context): Option[(Type, String, TypeOrBounds /* Type | TypeBounds */)]
455455
}
456456

457457
val AppliedType: AppliedTypeExtractor
458458
abstract class AppliedTypeExtractor {
459-
def unapply(x: Type)(implicit ctx: Context): Option[(Type, List[MaybeType /* Type | TypeBounds */])]
459+
def unapply(x: Type)(implicit ctx: Context): Option[(Type, List[TypeOrBounds /* Type | TypeBounds */])]
460460
}
461461

462462
val AnnotatedType: AnnotatedTypeExtractor
@@ -481,7 +481,7 @@ abstract class Tasty {
481481

482482
val ParamRef: ParamRefExtractor
483483
abstract class ParamRefExtractor {
484-
def unapply(x: Type)(implicit ctx: Context): Option[(LambdaType[MaybeType], Int)]
484+
def unapply(x: Type)(implicit ctx: Context): Option[(LambdaType[TypeOrBounds], Int)]
485485
}
486486

487487
val ThisType: ThisTypeExtractor
@@ -503,7 +503,7 @@ abstract class Tasty {
503503

504504
// ----- Methodic Types -------------------------------------------
505505

506-
type LambdaType[ParamInfo <: MaybeType] <: Type
506+
type LambdaType[ParamInfo <: TypeOrBounds] <: Type
507507

508508
type MethodType <: LambdaType[Type]
509509

@@ -540,7 +540,7 @@ abstract class Tasty {
540540

541541
// ----- TypeBounds -----------------------------------------------
542542

543-
type TypeBounds <: MaybeType
543+
type TypeBounds <: TypeOrBounds
544544

545545
implicit def typeBoundsClassTag: ClassTag[TypeBounds]
546546

@@ -551,7 +551,7 @@ abstract class Tasty {
551551

552552
// ----- NoPrefix -------------------------------------------------
553553

554-
type NoPrefix <: MaybeType
554+
type NoPrefix <: TypeOrBounds
555555

556556
implicit def noPrefixClassTag: ClassTag[NoPrefix]
557557

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ class TastyPrinter[T <: Tasty with Singleton](val tasty: T) {
1111
buff.toString()
1212
}
1313

14-
def stringOfTypeTree(tree: MaybeTypeTree)(implicit ctx: Context): String = {
14+
def stringOfTypeTree(tree: TypeOrBoundsTree)(implicit ctx: Context): String = {
1515
implicit val buff: StringBuilder = new StringBuilder
1616
visitTypeTree(tree)
1717
buff.toString()
1818
}
1919

20-
def stringOfType(tpe: MaybeType)(implicit ctx: Context): String = {
20+
def stringOfType(tpe: TypeOrBounds)(implicit ctx: Context): String = {
2121
implicit val buff: StringBuilder = new StringBuilder
2222
visitType(tpe)
2323
buff.toString()
@@ -290,7 +290,7 @@ class TastyPrinter[T <: Tasty with Singleton](val tasty: T) {
290290
}
291291
}
292292

293-
private def visitTypeTree(x: MaybeTypeTree)(implicit buff: StringBuilder, ctx: Context): Unit = {
293+
private def visitTypeTree(x: TypeOrBoundsTree)(implicit buff: StringBuilder, ctx: Context): Unit = {
294294
x match {
295295
case Synthetic() =>
296296
buff append "Synthetic()"
@@ -462,7 +462,7 @@ class TastyPrinter[T <: Tasty with Singleton](val tasty: T) {
462462
case StringConstant(value) => buff append "String(" append value append ")"
463463
}
464464

465-
private def visitType(x: MaybeType)(implicit buff: StringBuilder, ctx: Context): Unit = x match {
465+
private def visitType(x: TypeOrBounds)(implicit buff: StringBuilder, ctx: Context): Unit = x match {
466466
case ConstantType(value) =>
467467
buff append "ConstantType("
468468
visitConstant(value)
@@ -568,12 +568,12 @@ class TastyPrinter[T <: Tasty with Singleton](val tasty: T) {
568568
buff append "NoPrefix"
569569
}
570570

571-
private def visitTypes(list: List[MaybeType])(implicit buff: StringBuilder, ctx: Context): Unit = {
571+
private def visitTypes(list: List[TypeOrBounds])(implicit buff: StringBuilder, ctx: Context): Unit = {
572572
list match {
573573
case x0 :: xs =>
574574
buff append "List("
575575
visitType(x0)
576-
def visitNext(xs: List[MaybeType]): Unit = xs match {
576+
def visitNext(xs: List[TypeOrBounds]): Unit = xs match {
577577
case y :: ys =>
578578
buff append ", "
579579
visitType(y)

library/src/scala/tasty/util/TreeAccumulator.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ abstract class TreeAccumulator[X, T <: Tasty with Singleton](val tasty: T) {
77

88
// Ties the knot of the traversal: call `foldOver(x, tree))` to dive in the `tree` node.
99
def foldTree(x: X, tree: Tree)(implicit ctx: Context): X
10-
def foldTypeTree(x: X, tree: MaybeTypeTree)(implicit ctx: Context): X
10+
def foldTypeTree(x: X, tree: TypeOrBoundsTree)(implicit ctx: Context): X
1111
def foldCaseDef(x: X, tree: CaseDef)(implicit ctx: Context): X
1212
def foldPattern(x: X, tree: Pattern)(implicit ctx: Context): X
1313
def foldParent(x: X, tree: Parent)(implicit ctx: Context): X
1414

1515
def foldTrees(x: X, trees: Iterable[Tree])(implicit ctx: Context): X = (x /: trees)(foldTree)
16-
def foldTypeTrees(x: X, trees: Iterable[MaybeTypeTree])(implicit ctx: Context): X = (x /: trees)(foldTypeTree)
16+
def foldTypeTrees(x: X, trees: Iterable[TypeOrBoundsTree])(implicit ctx: Context): X = (x /: trees)(foldTypeTree)
1717
def foldCaseDefs(x: X, trees: Iterable[CaseDef])(implicit ctx: Context): X = (x /: trees)(foldCaseDef)
1818
def foldPatterns(x: X, trees: Iterable[Pattern])(implicit ctx: Context): X = (x /: trees)(foldPattern)
1919
def foldParents(x: X, trees: Iterable[Parent])(implicit ctx: Context): X = (x /: trees)(foldParent)
@@ -80,7 +80,7 @@ abstract class TreeAccumulator[X, T <: Tasty with Singleton](val tasty: T) {
8080
}
8181
}
8282

83-
def foldOverTypeTree(x: X, tree: MaybeTypeTree)(implicit ctx: Context): X = tree match {
83+
def foldOverTypeTree(x: X, tree: TypeOrBoundsTree)(implicit ctx: Context): X = tree match {
8484
case Synthetic() => x
8585
case TypeIdent(_) => x
8686
case TypeSelect(qualifier, _) => foldTree(x, qualifier)

library/src/scala/tasty/util/TreeTraverser.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@ abstract class TreeTraverser[T <: Tasty with Singleton](tasty0: T) extends TreeA
66
import tasty._
77

88
def traverseTree(tree: Tree)(implicit ctx: Context): Unit = traverseTreeChildren(tree)
9-
def traverseTypeTree(tree: MaybeTypeTree)(implicit ctx: Context): Unit = traverseTypeTreeChildren(tree)
9+
def traverseTypeTree(tree: TypeOrBoundsTree)(implicit ctx: Context): Unit = traverseTypeTreeChildren(tree)
1010
def traverseCaseDef(tree: CaseDef)(implicit ctx: Context): Unit = traverseCaseDefChildren(tree)
1111
def traversePattern(tree: Pattern)(implicit ctx: Context): Unit = traversePatternChildren(tree)
1212
def traverseParent(tree: Parent)(implicit ctx: Context): Unit = traverseParentChildren(tree)
1313

1414
def foldTree(x: Unit, tree: Tree)(implicit ctx: Context): Unit = traverseTree(tree)
15-
def foldTypeTree(x: Unit, tree: MaybeTypeTree)(implicit ctx: Context) = traverseTypeTree(tree)
15+
def foldTypeTree(x: Unit, tree: TypeOrBoundsTree)(implicit ctx: Context) = traverseTypeTree(tree)
1616
def foldCaseDef(x: Unit, tree: CaseDef)(implicit ctx: Context) = traverseCaseDef(tree)
1717
def foldPattern(x: Unit, tree: Pattern)(implicit ctx: Context) = traversePattern(tree)
1818
def foldParent(x: Unit, tree: Parent)(implicit ctx: Context) = traverseParent(tree)
1919

2020
protected def traverseTreeChildren(tree: Tree)(implicit ctx: Context): Unit = foldOverTree((), tree)
21-
protected def traverseTypeTreeChildren(tree: MaybeTypeTree)(implicit ctx: Context): Unit = foldOverTypeTree((), tree)
21+
protected def traverseTypeTreeChildren(tree: TypeOrBoundsTree)(implicit ctx: Context): Unit = foldOverTypeTree((), tree)
2222
protected def traverseCaseDefChildren(tree: CaseDef)(implicit ctx: Context): Unit = foldOverCaseDef((), tree)
2323
protected def traversePatternChildren(tree: Pattern)(implicit ctx: Context): Unit = foldOverPattern((), tree)
2424
protected def traverseParentChildren(tree: Parent)(implicit ctx: Context): Unit = foldOverParent((), tree)

tests/run/tasty-extractors-3/quoted_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ object Macros {
1717

1818
val buff = new StringBuilder
1919
val traverser = new TreeTraverser(u.tasty) {
20-
override def traverseTypeTree(tree: MaybeTypeTree)(implicit ctx: Context): Unit = {
20+
override def traverseTypeTree(tree: TypeOrBoundsTree)(implicit ctx: Context): Unit = {
2121
buff.append(printer.stringOfType(tree.tpe))
2222
buff.append("\n\n")
2323
traverseTypeTreeChildren(tree)

tests/run/tasty-indexed-map/quoted_1.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ object Index {
3131
import u._
3232
import u.tasty._
3333

34-
def name(tp: MaybeType): String = tp match {
34+
def name(tp: TypeOrBounds): String = tp match {
3535
case ConstantType(StringConstant(str)) => str
3636
}
3737

38-
def names(tp: MaybeType): List[String] = tp match {
38+
def names(tp: TypeOrBounds): List[String] = tp match {
3939
case AppliedType(_, x1 :: x2 :: Nil) => name(x1) :: names(x2)
4040
case _ => Nil
4141
}

tests/run/tasty-macro-assert/quoted_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ object Asserts {
2222

2323
val tree = cond.toTasty
2424

25-
def isOps(tpe: MaybeType): Boolean = tpe match {
25+
def isOps(tpe: TypeOrBounds): Boolean = tpe match {
2626
case SymRef(DefDef("Ops", _, _, _, _), _) => true // TODO check that the parent is Asserts
2727
case _ => false
2828
}

0 commit comments

Comments
 (0)