File tree Expand file tree Collapse file tree 2 files changed +18
-5
lines changed
compiler/src/dotty/tools/dotc/core Expand file tree Collapse file tree 2 files changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -163,9 +163,13 @@ object TypeOps:
163
163
// with Nulls (which have no base classes). Under -Yexplicit-nulls, we take
164
164
// corrective steps, so no widening is wanted.
165
165
simplify(l, theMap) | simplify(r, theMap)
166
- case AnnotatedType (parent, annot)
167
- if annot.symbol == defn.UncheckedVarianceAnnot && ! ctx.mode.is(Mode .Type ) && ! theMap.isInstanceOf [SimplifyKeepUnchecked ] =>
168
- simplify(parent, theMap)
166
+ case tp @ AnnotatedType (parent, annot) =>
167
+ val parent1 = simplify(parent, theMap)
168
+ if annot.symbol == defn.UncheckedVarianceAnnot
169
+ && ! ctx.mode.is(Mode .Type )
170
+ && ! theMap.isInstanceOf [SimplifyKeepUnchecked ]
171
+ then parent1
172
+ else tp.derivedAnnotatedType(parent1, annot)
169
173
case _ : MatchType =>
170
174
val normed = tp.tryNormalize
171
175
if (normed.exists) normed else mapOver
Original file line number Diff line number Diff line change @@ -5566,8 +5566,17 @@ object Types {
5566
5566
5567
5567
case tp @ AnnotatedType (underlying, annot) =>
5568
5568
val underlying1 = this (underlying)
5569
- if (underlying1 eq underlying) tp
5570
- else derivedAnnotatedType(tp, underlying1, mapOver(annot))
5569
+ val annot1 =
5570
+ if underlying1 ne underlying then mapOver(annot)
5571
+ else annot match
5572
+ case ConcreteAnnotation (ann)
5573
+ if ann.existsSubTree { t =>
5574
+ val tpe = t.typeOpt
5575
+ tpe.exists && ! (this (tpe) =:= tpe)
5576
+ } => mapOver(annot)
5577
+ case _ => annot
5578
+ if (underlying1 eq underlying) && (annot eq annot1) then tp
5579
+ else derivedAnnotatedType(tp, underlying1, annot1)
5571
5580
5572
5581
case tp @ CapturingType (parent, refs) =>
5573
5582
derivedCapturingType(tp, this (parent), refs.flatMap(this (_).captureSet))
You can’t perform that action at this time.
0 commit comments