Skip to content

Commit c5f8a6d

Browse files
committed
Don't strip annotations on class parents
In particular, this preserves @uncheckedVariance for the variance checker.
1 parent 7acd75d commit c5f8a6d

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

compiler/src/dotty/tools/dotc/typer/Checking.scala

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -483,16 +483,17 @@ object Checking {
483483
}
484484
tp1
485485
case tp: ClassInfo =>
486+
def transformedParent(tp: Type): Type = tp match {
487+
case ref: TypeRef => ref
488+
case ref: AppliedType => ref
489+
case AnnotatedType(parent, annot) =>
490+
AnnotatedType(transformedParent(parent), annot)
491+
case _ => defn.ObjectType // can happen if class files are missing
492+
}
486493
tp.derivedClassInfo(
487494
prefix = apply(tp.prefix),
488495
classParents =
489-
tp.parents.map { p =>
490-
apply(p).stripAnnots match {
491-
case ref: TypeRef => ref
492-
case ref: AppliedType => ref
493-
case _ => defn.ObjectType // can happen if class files are missing
494-
}
495-
}
496+
tp.parents.map { p => transformedParent(apply(p)) }
496497
)
497498
case _ =>
498499
mapOver(tp)

compiler/src/dotty/tools/dotc/typer/Namer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,7 @@ class Namer { typer: Typer =>
888888
* (4) If the class is sealed, it is defined in the same compilation unit as the current class
889889
*/
890890
def checkedParentType(parent: untpd.Tree): Type = {
891-
val ptype = parentType(parent)(ctx.superCallContext).dealias
891+
val ptype = parentType(parent)(ctx.superCallContext).dealiasKeepAnnots
892892
if (cls.isRefinementClass) ptype
893893
else {
894894
val pt = checkClassType(ptype, parent.pos,

0 commit comments

Comments
 (0)