diff --git a/compiler/src/dotty/tools/dotc/typer/Implicits.scala b/compiler/src/dotty/tools/dotc/typer/Implicits.scala index f303bfbc5e19..f48963ea04e3 100644 --- a/compiler/src/dotty/tools/dotc/typer/Implicits.scala +++ b/compiler/src/dotty/tools/dotc/typer/Implicits.scala @@ -610,6 +610,8 @@ trait ImplicitRunInfo: else partSeen += t t.dealias match + case dealias if t ne dealias => + traverse(wildApprox(dealias)) case t: TypeRef => if isAnchor(t.symbol) then parts += t diff --git a/tests/neg/i17305.scala b/tests/neg/i17305.scala new file mode 100644 index 000000000000..f233abf9362e --- /dev/null +++ b/tests/neg/i17305.scala @@ -0,0 +1,36 @@ +trait Wrapper[A1] { + def use(a: A1 => Unit): Unit +} + +trait Assertion[A2] {} + +def hideTypeInOut[A3]( + c1: A3 +)(using + hider: HideAInOut[A3] +): Wrapper[hider.Out] = ??? + +def entryPoint(): Unit = { + hideTypeInOut(1L) + .use((pair) => myAssert(pair)(someAssertion(2))) // error Assertion[Int] instead of Assertion[Long] +} + +private def myAssert[A4](a: A4)(assertion: Assertion[A4]): Unit = () + +private def someAssertion(i: Int): Assertion[Int] = ??? + +trait HideAInOut[-A] { + type Out + def get(left: A): Out +} + +object HideAInOut { + + type Out[HideA, HideB] = HideAInOut[HideA] { type Out = HideB } + + given [GivenA]: HideAInOut.Out[GivenA, GivenA] = + new HideAInOut[GivenA] { + type Out = GivenA + def get(left: GivenA): Out = left + } +}