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

Do a kind-check in inferPolyAlternatives #9405

Merged
merged 1 commit into from Dec 23, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/compiler/scala/tools/nsc/typechecker/Infer.scala
Expand Up @@ -1558,9 +1558,13 @@ trait Infer extends Checkable {
finish(sym setInfo tpe, tpe)
}
matchingLength.alternatives match {
case Nil => fail()
case Nil => fail()
case alt :: Nil => finish(alt, pre memberType alt)
case _ => checkWithinBounds(matchingLength filter (alt => isWithinBounds(pre, alt.owner, alt.typeParams, argtypes)))
case _ =>
checkWithinBounds(matchingLength.filter { alt =>
isWithinBounds(pre, alt.owner, alt.typeParams, argtypes) &&
kindsConform(alt.typeParams, argtypes, pre, alt.owner)
})
}
}
}
Expand Down
13 changes: 13 additions & 0 deletions test/files/pos/t12212.scala
@@ -0,0 +1,13 @@
object Test {
trait Low[X]
trait Lower[V, X] extends Low[X]
trait Res[V]
trait High[L[X] <: Low[X]]
trait HighRes[L[X] <: Lower[V, X], V] extends Res[V]
trait Mid[X, Y]

def m[L[X] <: Lower[V, X], V](high: High[L]): HighRes[L, V] = ???
def m[X, Y](mid: Mid[X, Y]): Res[Y] = ???
def ok[L[X] <: Lower[V, X], V](high :High[L]): HighRes[L, V] = m(high)
def wtf[L[X] <: Lower[V, X], V](high :High[L]): HighRes[L, V] = m[L, V](high)
}