Skip to content

Commit

Permalink
Merge pull request #9405 from joroKr21/overload-kind
Browse files Browse the repository at this point in the history
Do a kind-check in inferPolyAlternatives
  • Loading branch information
lrytz committed Dec 23, 2020
2 parents 6d45b03 + 9edc75a commit 912b786
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
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)
}

0 comments on commit 912b786

Please sign in to comment.