Skip to content

Commit 41d262b

Browse files
authored
Merge pull request #12667 from dotty-staging/fix-12664
Harden type comparer in presence of kind errors
2 parents 09daa51 + ccd71bb commit 41d262b

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1422,7 +1422,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
14221422

14231423
def recurArgs(args1: List[Type], args2: List[Type], tparams2: List[ParamInfo]): Boolean =
14241424
if (args1.isEmpty) args2.isEmpty
1425-
else args2.nonEmpty && {
1425+
else args2.nonEmpty && tparams2.nonEmpty && {
14261426
val tparam = tparams2.head
14271427
val v = tparam.paramVarianceSign
14281428

tests/neg/i12664.scala

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
trait Step {
2+
type Self
3+
type Next[A]
4+
}
5+
6+
trait DynamicNextStep {
7+
type OneOf[Self, Next[_]]
8+
def apply(s: Step): OneOf[s.Self, s.Next]
9+
}
10+
11+
object X extends DynamicNextStep {
12+
override type OneOf[Self] = Self // error
13+
override def apply(s: Step) = ???
14+
}

0 commit comments

Comments
 (0)