@@ -236,8 +236,8 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
236236 compareWild
237237 case tp2 : LazyRef =>
238238 ! tp2.evaluating && recur(tp1, tp2.ref)
239- case tp2 : AnnotatedType =>
240- recur(tp1, tp2.tpe) // todo: refine?
239+ case tp2 : AnnotatedType if ! tp2.isRefining =>
240+ recur(tp1, tp2.tpe)
241241 case tp2 : ThisType =>
242242 def compareThis = {
243243 val cls2 = tp2.cls
@@ -345,7 +345,7 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
345345 // because that would cause an assertionError. Return false instead.
346346 // See i859.scala for an example where we hit this case.
347347 ! tp1.evaluating && recur(tp1.ref, tp2)
348- case tp1 : AnnotatedType =>
348+ case tp1 : AnnotatedType if ! tp1.isRefining =>
349349 recur(tp1.tpe, tp2)
350350 case AndType (tp11, tp12) =>
351351 if (tp11.stripTypeVar eq tp12.stripTypeVar) recur(tp11, tp2)
@@ -567,6 +567,9 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
567567 false
568568 }
569569 compareTypeBounds
570+ case tp2 : AnnotatedType if tp2.isRefining =>
571+ (tp1.derivesAnnotWith(tp2.annot.sameAnnotation) || defn.isBottomType(tp1)) &&
572+ recur(tp1, tp2.tpe)
570573 case ClassInfo (pre2, cls2, _, _, _) =>
571574 def compareClassInfo = tp1 match {
572575 case ClassInfo (pre1, cls1, _, _, _) =>
@@ -661,6 +664,8 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
661664 case _ =>
662665 }
663666 either(recur(tp11, tp2), recur(tp12, tp2))
667+ case tp1 : AnnotatedType if tp1.isRefining =>
668+ isNewSubType(tp1.tpe)
664669 case JavaArrayType (elem1) =>
665670 def compareJavaArray = tp2 match {
666671 case JavaArrayType (elem2) => isSubType(elem1, elem2)
@@ -700,7 +705,7 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
700705 }
701706 case tycon1 : TypeVar =>
702707 isMatchingApply(tycon1.underlying)
703- case tycon1 : AnnotatedType =>
708+ case tycon1 : AnnotatedType if ! tycon1.isRefining =>
704709 isMatchingApply(tycon1.underlying)
705710 case _ =>
706711 false
@@ -811,7 +816,9 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
811816 fourthTry
812817 }
813818 }
814- case _ : TypeVar | _ : AnnotatedType =>
819+ case _ : TypeVar =>
820+ recur(tp1, tp2.superType)
821+ case tycon2 : AnnotatedType if ! tycon2.isRefining =>
815822 recur(tp1, tp2.superType)
816823 case tycon2 : AppliedType =>
817824 fallback(tycon2.lowerBound)
@@ -1546,7 +1553,7 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
15461553 }
15471554 case tp1 : TypeVar if tp1.isInstantiated =>
15481555 tp1.underlying & tp2
1549- case tp1 : AnnotatedType =>
1556+ case tp1 : AnnotatedType if ! tp1.isRefining =>
15501557 tp1.underlying & tp2
15511558 case _ =>
15521559 NoType
@@ -1565,7 +1572,7 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
15651572 ExprType (rt1 | tp2.widenExpr)
15661573 case tp1 : TypeVar if tp1.isInstantiated =>
15671574 tp1.underlying | tp2
1568- case tp1 : AnnotatedType =>
1575+ case tp1 : AnnotatedType if ! tp1.isRefining =>
15691576 tp1.underlying | tp2
15701577 case _ =>
15711578 NoType
0 commit comments