Skip to content

Commit db91ae6

Browse files
committed
Simplify Annotation API for type mapping
Keep only mapWith
1 parent 75ff6db commit db91ae6

File tree

2 files changed

+2
-10
lines changed

2 files changed

+2
-10
lines changed

compiler/src/dotty/tools/dotc/core/Annotations.scala

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,6 @@ object Annotations {
4747
/** The tree evaluation has finished. */
4848
def isEvaluated: Boolean = true
4949

50-
/** The annotation should be part of mappings?
51-
* Currently overridden only in ConcreteAnnotation, which simulates the previous behavior.
52-
*/
53-
def isMappable: Boolean = false
54-
5550
/** Normally, map type map over all tree nodes of this annotation, but can
5651
* be overridden. Returns EmptyAnnotation if type type map produces a range
5752
* type, since ranges cannot be types of trees.
@@ -83,7 +78,6 @@ object Annotations {
8378

8479
case class ConcreteAnnotation(t: Tree) extends Annotation {
8580
def tree(using Context): Tree = t
86-
override def isMappable = true
8781
override def argsText(printer: Printer): Text =
8882
def toTextArg(arg: Tree): Text = arg match
8983
case Typed(SeqLiteral(elems, _), _) => printer.toTextGlobal(elems, ", ")
@@ -143,6 +137,7 @@ object Annotations {
143137
if (tree eq this.tree) this else ConcreteBodyAnnotation(tree)
144138
override def arguments(using Context): List[Tree] = Nil
145139
override def ensureCompleted(using Context): Unit = ()
140+
override def mapWith(tm: TypeMap)(using Context) = this
146141
}
147142

148143
class ConcreteBodyAnnotation(body: Tree) extends BodyAnnotation {

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5439,10 +5439,7 @@ object Types {
54395439

54405440
case tp @ AnnotatedType(underlying, annot) =>
54415441
val underlying1 = this(underlying)
5442-
val annot1 =
5443-
if (underlying1 ne underlying) || annot.isMappable
5444-
then annot.mapWith(this)
5445-
else annot
5442+
val annot1 = annot.mapWith(this)
54465443
if annot1 eq EmptyAnnotation then underlying1
54475444
else derivedAnnotatedType(tp, underlying1, annot1)
54485445

0 commit comments

Comments
 (0)