Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Harden type comparer in presence of kind errors #12667

Merged
merged 1 commit into from
Jun 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/TypeComparer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 14 additions & 0 deletions tests/neg/i12664.scala
Original file line number Diff line number Diff line change
@@ -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) = ???
}