From f0d57b028e16278a1698a3453c7e491bb170ad6a Mon Sep 17 00:00:00 2001 From: Som Snytt Date: Fri, 30 May 2025 18:33:15 -0700 Subject: [PATCH] Take the high bound in extension check --- compiler/src/dotty/tools/dotc/typer/RefChecks.scala | 6 +++--- tests/warn/i23293.scala | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 tests/warn/i23293.scala diff --git a/compiler/src/dotty/tools/dotc/typer/RefChecks.scala b/compiler/src/dotty/tools/dotc/typer/RefChecks.scala index c500b6cc60bb..8608e4a1dd1e 100644 --- a/compiler/src/dotty/tools/dotc/typer/RefChecks.scala +++ b/compiler/src/dotty/tools/dotc/typer/RefChecks.scala @@ -1118,8 +1118,8 @@ object RefChecks { * This check is suppressed if the method is an override. (Because the type of the receiver * may be narrower in the override.) * - * If the extension method is nilary, it is always hidden by a member of the same name. - * (Either the member is nilary, or the reference is taken as the eta-expansion of the member.) + * If the extension method is nullary (has no param lists), it is always hidden by a member of the same name. + * (Either the member is nullary, or the reference is taken as the eta-expansion of the member.) * * This check is in lieu of a more expensive use-site check that an application failed to use an extension. * That check would account for accessibility and opacity. As a limitation, this check considers @@ -1161,7 +1161,7 @@ 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.hiBound val member = target.nonPrivateMember(sym.name) .filterWithPredicate: member => member.symbol.isPublic && memberHidesMethod(member) diff --git a/tests/warn/i23293.scala b/tests/warn/i23293.scala new file mode 100644 index 000000000000..10e1a7865c6b --- /dev/null +++ b/tests/warn/i23293.scala @@ -0,0 +1,4 @@ + +trait SelectByName[Field <: String & Singleton, Rec <: Tuple]: + type Out + extension (r: Rec) def apply[F <: Field]: Out // warn not crash