Skip to content

Commit 5cee25b

Browse files
committed
Fix crash on implicit search involving higher-kinded types
Previously, the test case crashed because it tried to create an AndType of `[X] =>> <?>` and `[X] =>> Any`, but AndTypes can only contain value types. Fixed by moving the AndType creation after having recursively simplified the bounds with `apply` which always produces a value type.
1 parent 8a4c442 commit 5cee25b

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -675,12 +675,11 @@ trait ImplicitRunInfo:
675675
WildcardType
676676
else
677677
seen.addEntry(t)
678-
apply(
679-
t.underlying match
680-
case TypeBounds(lo, hi) =>
681-
if defn.isBottomTypeAfterErasure(lo) then hi
682-
else AndType.make(lo, hi)
683-
case u => u)
678+
t.underlying match
679+
case TypeBounds(lo, hi) =>
680+
if defn.isBottomTypeAfterErasure(lo) then apply(hi)
681+
else AndType.make(apply(lo), apply(hi))
682+
case u => apply(u)
684683

685684
def apply(t: Type) = t.dealias match
686685
case t: TypeRef =>

tests/pos/liftToAnchors-hk.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
class Foo[F[_], F2[X] >: F[X]] {
2+
def foo[A](using F[A] <:< F2[A]): Unit = {}
3+
foo
4+
}

0 commit comments

Comments
 (0)