@@ -1163,22 +1163,20 @@ object RefChecks {
1163
1163
* that are either both opaque types or both not.
1164
1164
*/
1165
1165
def checkExtensionMethods (sym : Symbol )(using Context ): Unit =
1166
- if sym.is(Extension ) && ! sym.nextOverriddenSymbol.exists then
1166
+ if sym.is(Extension ) then
1167
1167
extension (tp : Type )
1168
- def strippedResultType = Applications .stripImplicit(tp.stripPoly, wildcardOnly = true ).resultType
1169
- def firstExplicitParamTypes = Applications .stripImplicit(tp.stripPoly, wildcardOnly = true ).firstParamTypes
1168
+ def explicit = Applications .stripImplicit(tp.stripPoly, wildcardOnly = true )
1170
1169
def hasImplicitParams = tp.stripPoly match { case mt : MethodType => mt.isImplicitMethod case _ => false }
1171
- val target = sym.info.firstExplicitParamTypes .head // required for extension method, the putative receiver
1172
- val methTp = sym.info.strippedResultType // skip leading implicits and the "receiver" parameter
1170
+ val target = sym.info.explicit.firstParamTypes .head // required for extension method, the putative receiver
1171
+ val methTp = sym.info.explicit.resultType // skip leading implicits and the "receiver" parameter
1173
1172
def hidden =
1174
1173
target.nonPrivateMember(sym.name)
1175
- .filterWithPredicate:
1176
- member =>
1174
+ .filterWithPredicate: member =>
1177
1175
member.symbol.isPublic && {
1178
1176
val memberIsImplicit = member.info.hasImplicitParams
1179
1177
val paramTps =
1180
1178
if memberIsImplicit then methTp.stripPoly.firstParamTypes
1181
- else methTp.firstExplicitParamTypes
1179
+ else methTp.explicit.firstParamTypes
1182
1180
1183
1181
paramTps.isEmpty || memberIsImplicit && ! methTp.hasImplicitParams || {
1184
1182
val memberParamTps = member.info.stripPoly.firstParamTypes
@@ -1190,7 +1188,13 @@ object RefChecks {
1190
1188
}
1191
1189
}
1192
1190
.exists
1193
- if ! target.typeSymbol.isOpaqueAlias && hidden
1191
+ val receiverName = sym.info.explicit.firstParamNames.head
1192
+ val num = sym.info.paramNamess.flatten.indexWhere(_ == receiverName)
1193
+ val getterName = DefaultGetterName (sym.name.toTermName, num = num)
1194
+ val getterDenot = sym.owner.info.member(getterName)
1195
+ if getterDenot.exists
1196
+ then report.warning(ExtensionHasDefault (sym), getterDenot.symbol.srcPos)
1197
+ if ! target.typeSymbol.isOpaqueAlias && ! sym.nextOverriddenSymbol.exists && hidden
1194
1198
then report.warning(ExtensionNullifiedByMember (sym, target.typeSymbol), sym.srcPos)
1195
1199
end checkExtensionMethods
1196
1200
0 commit comments