@@ -1062,22 +1062,21 @@ object RefChecks {
1062
1062
* that are either both opaque types or both not.
1063
1063
*/
1064
1064
def checkExtensionMethods (sym : Symbol )(using Context ): Unit =
1065
- if sym.is(Extension ) && ! sym.nextOverriddenSymbol.exists then
1065
+ if sym.is(Extension ) then
1066
1066
extension (tp : Type )
1067
- def strippedResultType = Applications .stripImplicit(tp.stripPoly, wildcardOnly = true ).resultType
1068
- def firstExplicitParamTypes = Applications .stripImplicit(tp.stripPoly, wildcardOnly = true ).firstParamTypes
1067
+ def explicit = Applications .stripImplicit(tp.stripPoly, wildcardOnly = true )
1069
1068
def hasImplicitParams = tp.stripPoly match { case mt : MethodType => mt.isImplicitMethod case _ => false }
1070
- val target = sym.info.firstExplicitParamTypes.head // required for extension method, the putative receiver
1071
- val methTp = sym.info.strippedResultType // skip leading implicits and the "receiver" parameter
1069
+ val explicitInfo = sym.info.explicit // consider explicit value params
1070
+ val target = explicitInfo.firstParamTypes.head // required for extension method, the putative receiver
1071
+ val methTp = explicitInfo.resultType // skip leading implicits and the "receiver" parameter
1072
1072
def hidden =
1073
1073
target.nonPrivateMember(sym.name)
1074
- .filterWithPredicate:
1075
- member =>
1074
+ .filterWithPredicate: member =>
1076
1075
member.symbol.isPublic && {
1077
1076
val memberIsImplicit = member.info.hasImplicitParams
1078
1077
val paramTps =
1079
1078
if memberIsImplicit then methTp.stripPoly.firstParamTypes
1080
- else methTp.firstExplicitParamTypes
1079
+ else methTp.explicit.firstParamTypes
1081
1080
1082
1081
paramTps.isEmpty || memberIsImplicit && ! methTp.hasImplicitParams || {
1083
1082
val memberParamTps = member.info.stripPoly.firstParamTypes
@@ -1089,7 +1088,15 @@ object RefChecks {
1089
1088
}
1090
1089
}
1091
1090
.exists
1092
- if ! target.typeSymbol.isOpaqueAlias && hidden
1091
+ if sym.is(HasDefaultParams ) then
1092
+ val getterDenot =
1093
+ val receiverName = explicitInfo.firstParamNames.head
1094
+ val num = sym.info.paramNamess.flatten.indexWhere(_ == receiverName)
1095
+ val getterName = DefaultGetterName (sym.name.toTermName, num = num)
1096
+ sym.owner.info.member(getterName)
1097
+ if getterDenot.exists
1098
+ then report.warning(ExtensionHasDefault (sym), getterDenot.symbol.srcPos)
1099
+ if ! target.typeSymbol.isOpaqueAlias && ! sym.nextOverriddenSymbol.exists && hidden
1093
1100
then report.warning(ExtensionNullifiedByMember (sym, target.typeSymbol), sym.srcPos)
1094
1101
end checkExtensionMethods
1095
1102
0 commit comments