Skip to content

Commit f0d57b0

Browse files
committed
Take the high bound in extension check
1 parent 7c3ddc3 commit f0d57b0

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

compiler/src/dotty/tools/dotc/typer/RefChecks.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,8 +1118,8 @@ object RefChecks {
11181118
* This check is suppressed if the method is an override. (Because the type of the receiver
11191119
* may be narrower in the override.)
11201120
*
1121-
* If the extension method is nilary, it is always hidden by a member of the same name.
1122-
* (Either the member is nilary, or the reference is taken as the eta-expansion of the member.)
1121+
* If the extension method is nullary (has no param lists), it is always hidden by a member of the same name.
1122+
* (Either the member is nullary, or the reference is taken as the eta-expansion of the member.)
11231123
*
11241124
* This check is in lieu of a more expensive use-site check that an application failed to use an extension.
11251125
* That check would account for accessibility and opacity. As a limitation, this check considers
@@ -1161,7 +1161,7 @@ object RefChecks {
11611161
def targetOfHiddenExtension: Symbol =
11621162
val target =
11631163
val target0 = explicitInfo.firstParamTypes.head // required for extension method, the putative receiver
1164-
target0.dealiasKeepOpaques.typeSymbol.info
1164+
target0.dealiasKeepOpaques.typeSymbol.info.hiBound
11651165
val member = target.nonPrivateMember(sym.name)
11661166
.filterWithPredicate: member =>
11671167
member.symbol.isPublic && memberHidesMethod(member)

tests/warn/i23293.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
trait SelectByName[Field <: String & Singleton, Rec <: Tuple]:
3+
type Out
4+
extension (r: Rec) def apply[F <: Field]: Out // warn not crash

0 commit comments

Comments
 (0)