From 8d3668111024ac2d17f65de280404134703fbb97 Mon Sep 17 00:00:00 2001 From: Som Snytt Date: Tue, 5 Aug 2025 07:48:45 -0700 Subject: [PATCH 1/2] test --- tests/pos/i23666.scala | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 tests/pos/i23666.scala diff --git a/tests/pos/i23666.scala b/tests/pos/i23666.scala new file mode 100644 index 000000000000..197008b1776c --- /dev/null +++ b/tests/pos/i23666.scala @@ -0,0 +1,14 @@ + +type Tuple = scala.Tuple +type Any = scala.Any + +infix type =:= [A, B] = A => B + +object `=:=` : + given [A] => A =:= A = a => a + +extension [T <: Tuple] (tuple: T) + + def reverse[A, B](using ev: T =:= (A, B)): (B, A) = + val ab = ev(tuple) + (ab._2, ab._1) From 36dba5875159c94273001715dc53d46fc31539c5 Mon Sep 17 00:00:00 2001 From: Som Snytt Date: Tue, 5 Aug 2025 12:44:43 -0700 Subject: [PATCH 2/2] Defend against AliasingBounds --- compiler/src/dotty/tools/dotc/typer/RefChecks.scala | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/compiler/src/dotty/tools/dotc/typer/RefChecks.scala b/compiler/src/dotty/tools/dotc/typer/RefChecks.scala index a79408b756ee..f1e6c1638463 100644 --- a/compiler/src/dotty/tools/dotc/typer/RefChecks.scala +++ b/compiler/src/dotty/tools/dotc/typer/RefChecks.scala @@ -1166,7 +1166,9 @@ object RefChecks { def targetOfHiddenExtension: Symbol = val target = val target0 = explicitInfo.firstParamTypes.head // required for extension method, the putative receiver - target0.dealiasKeepOpaques.typeSymbol.info + target0.dealiasKeepOpaques.typeSymbol.info match + case tb: AliasingBounds => tb.alias + case tp => tp val member = target.nonPrivateMember(sym.name) .filterWithPredicate: member => member.symbol.isPublic && memberHidesMethod(member)