Skip to content

Take the high bound in extension check #23294

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions compiler/src/dotty/tools/dotc/typer/RefChecks.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions tests/warn/i23293.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

trait SelectByName[Field <: String & Singleton, Rec <: Tuple]:
type Out
extension (r: Rec) def apply[F <: Field]: Out // warn not crash
Loading