diff --git a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala index 47f36255de81..7c7aba8a95b0 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala @@ -1422,7 +1422,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling def recurArgs(args1: List[Type], args2: List[Type], tparams2: List[ParamInfo]): Boolean = if (args1.isEmpty) args2.isEmpty - else args2.nonEmpty && { + else args2.nonEmpty && tparams2.nonEmpty && { val tparam = tparams2.head val v = tparam.paramVarianceSign diff --git a/tests/neg/i12664.scala b/tests/neg/i12664.scala new file mode 100644 index 000000000000..5e4b784475aa --- /dev/null +++ b/tests/neg/i12664.scala @@ -0,0 +1,14 @@ +trait Step { + type Self + type Next[A] +} + +trait DynamicNextStep { + type OneOf[Self, Next[_]] + def apply(s: Step): OneOf[s.Self, s.Next] +} + +object X extends DynamicNextStep { + override type OneOf[Self] = Self // error + override def apply(s: Step) = ??? +}