From 8e14a348cdbf056e23584e7440b51eb7c48c6155 Mon Sep 17 00:00:00 2001 From: Matt Bovel Date: Wed, 21 May 2025 14:01:19 +0000 Subject: [PATCH] Only keep denotation for methods in IntegrateMap --- .../src/dotty/tools/dotc/core/Types.scala | 2 +- tests/pos/i23217.scala | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 tests/pos/i23217.scala diff --git a/compiler/src/dotty/tools/dotc/core/Types.scala b/compiler/src/dotty/tools/dotc/core/Types.scala index c2c508dc27ea..6c537d0519e3 100644 --- a/compiler/src/dotty/tools/dotc/core/Types.scala +++ b/compiler/src/dotty/tools/dotc/core/Types.scala @@ -3862,7 +3862,7 @@ object Types extends TypeUtils { if tp.prefix eq pre then tp else pre match - case ref: ParamRef if (ref.binder eq self) && tp.symbol.exists => + case ref: ParamRef if (ref.binder eq self) && tp.symbol.exists && tp.symbol.is(Method) => NamedType(pre, tp.name, tp.denot.asSeenFrom(pre)) case _ => tp.derivedSelect(pre) diff --git a/tests/pos/i23217.scala b/tests/pos/i23217.scala new file mode 100644 index 000000000000..cf3427a2649e --- /dev/null +++ b/tests/pos/i23217.scala @@ -0,0 +1,20 @@ +trait HasA[T]: + type A = T + +object Test1: + def foo1(h: HasA[?])(a: h.A): Unit = {} + + def foo2(h1: HasA[?])(a1: h1.A): Unit = + foo1(h1)(a1) + + def foo3(h1: HasA[?], a1: h1.A): Unit = + foo1(h1)(a1) + +object Test2: + def bar1(h: HasA[?], a: h.A): Unit = {} + + def bar2(h1: HasA[?], a1: h1.A): Unit = + bar1(h1, a1) + + def foo3(h1: HasA[?])(a1: h1.A): Unit = + bar2(h1, a1)