Skip to content

Commit 9683136

Browse files
authored
Merge pull request #8447 from dotty-staging/fix-#6651
Fix #6561: Avoid double bounds instantiation
2 parents 3937029 + 3c40802 commit 9683136

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

compiler/src/dotty/tools/dotc/typer/Checking.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,11 @@ object Checking {
8484
val orderedArgs = if (hasNamedArg(args)) tparams.map(argNamed) else args
8585
val bounds = tparams.map(_.paramInfoAsSeenFrom(tree.tpe).bounds)
8686
def instantiate(bound: Type, args: List[Type]) =
87-
HKTypeLambda.fromParams(tparams, bound).appliedTo(args)
87+
tparams match
88+
case LambdaParam(lam, _) :: _ =>
89+
HKTypeLambda.fromParams(tparams, bound).appliedTo(args)
90+
case _ =>
91+
bound // paramInfoAsSeenFrom already took care of instantiation in this case
8892
if (boundsCheck) checkBounds(orderedArgs, bounds, instantiate, tree.tpe)
8993

9094
def checkWildcardApply(tp: Type): Unit = tp match {

tests/pos/i6561.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
trait Foo[V]
2+
class Inv[A](a: A)
3+
4+
trait Bar[K <: Foo[V], V] {
5+
// ERROR: Type argument Foo[Inv[V]] does not conform to upper bound Foo[Inv[Inv[V]]]
6+
def test(): Bar[Foo[Inv[V]], Inv[V]]
7+
}

0 commit comments

Comments
 (0)