Skip to content

Commit 9efa6f7

Browse files
committed
Fix #6127: Fix followAlias
FollowAlias would return the bounds of a constraint type variable instead of the variable itself. This meant that constrain result in adapt would almost always return true for an expected type that was a type variable instead of adding a constraint for it.
1 parent b40b519 commit 9efa6f7

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2553,10 +2553,12 @@ class Typer extends Namer
25532553
inst(lo)
25542554
case tp: TypeParamRef =>
25552555
constraint.typeVarOfParam(tp).orElse(tp)
2556-
case _ => tp
2556+
case _ =>
2557+
NoType
25572558
}
25582559
tp match {
2559-
case tp: TypeVar if constraint.contains(tp) => inst(constraint.entry(tp.origin))
2560+
case tp: TypeVar if constraint.contains(tp) =>
2561+
inst(constraint.entry(tp.origin)).orElse(tp)
25602562
case _ => tp
25612563
}
25622564
}

tests/pos/i6127.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
class Foo[+FT](x: FT) {
2+
def fooArray: Foo[Array[String]] = new Foo(Array.empty)
3+
val y: Array[String] = Array.empty
4+
}

0 commit comments

Comments
 (0)