From 02533edc8c1e795f45b90c87bc1fbb6ad8004dab Mon Sep 17 00:00:00 2001 From: odersky Date: Thu, 18 Apr 2024 13:38:00 +0200 Subject: [PATCH] Fix overloaded default methods test in RefChecks It used `cls.info` instead of `cls.thisType`, which caused symbols accessible only through the self type of `cls` to be forgotten. Fixes #18555 --- .../src/dotty/tools/dotc/typer/RefChecks.scala | 2 +- tests/pos/i18555.scala | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 tests/pos/i18555.scala diff --git a/compiler/src/dotty/tools/dotc/typer/RefChecks.scala b/compiler/src/dotty/tools/dotc/typer/RefChecks.scala index 1397b05ec3b5..cdfd137e5661 100644 --- a/compiler/src/dotty/tools/dotc/typer/RefChecks.scala +++ b/compiler/src/dotty/tools/dotc/typer/RefChecks.scala @@ -52,7 +52,7 @@ object RefChecks { }} for (name <- defaultMethodNames) { - val methods = clazz.info.member(name).alternatives.map(_.symbol) + val methods = clazz.thisType.member(name).alternatives.map(_.symbol) val haveDefaults = methods.filter(_.hasDefaultParams) if (haveDefaults.length > 1) { val owners = haveDefaults map (_.owner) diff --git a/tests/pos/i18555.scala b/tests/pos/i18555.scala new file mode 100644 index 000000000000..84198409370e --- /dev/null +++ b/tests/pos/i18555.scala @@ -0,0 +1,14 @@ +trait GenericCollectionWithCommands { + self: PackSupport => + + def bar(foo: Int = 1): Any = ??? + def bar(writer: GenericCollectionWithCommands.this.pack.Writer[Any]): Any = ??? +} + +trait PackSupport { + val pack: SerializationPack +} + +trait SerializationPack { + type Writer[A] +} \ No newline at end of file