From c9c4281159225c6a55bac7990a98c2805de6ef47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=8BAndrzej=20Ressel?= Date: Thu, 11 May 2023 23:37:05 +0200 Subject: [PATCH 1/3] Fix aliased type support in ImplicitRunInfo --- compiler/src/dotty/tools/dotc/typer/Implicits.scala | 2 ++ 1 file changed, 2 insertions(+) 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 From 027981ea658b8a9781a813a97d904db1bb83a9bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=8BAndrzej=20Ressel?= Date: Thu, 11 May 2023 23:39:44 +0200 Subject: [PATCH 2/3] Add test --- tests/neg/i17305.scala | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 tests/neg/i17305.scala diff --git a/tests/neg/i17305.scala b/tests/neg/i17305.scala new file mode 100644 index 000000000000..8cee6d8cc97d --- /dev/null +++ b/tests/neg/i17305.scala @@ -0,0 +1,37 @@ +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 = () + +// This should be Unit or generic, but let compiler figure it out +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 + } +} \ No newline at end of file From ae4007e6a41800c55665b0826a218e07c40f79ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=8BAndrzej=20Ressel?= Date: Thu, 11 May 2023 23:46:28 +0200 Subject: [PATCH 3/3] Fix comment --- tests/neg/i17305.scala | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/neg/i17305.scala b/tests/neg/i17305.scala index 8cee6d8cc97d..f233abf9362e 100644 --- a/tests/neg/i17305.scala +++ b/tests/neg/i17305.scala @@ -17,7 +17,6 @@ def entryPoint(): Unit = { private def myAssert[A4](a: A4)(assertion: Assertion[A4]): Unit = () -// This should be Unit or generic, but let compiler figure it out private def someAssertion(i: Int): Assertion[Int] = ??? trait HideAInOut[-A] { @@ -34,4 +33,4 @@ object HideAInOut { type Out = GivenA def get(left: GivenA): Out = left } -} \ No newline at end of file +}