@@ -1062,22 +1062,21 @@ object RefChecks {
10621062 * that are either both opaque types or both not.
10631063 */
10641064 def checkExtensionMethods (sym : Symbol )(using Context ): Unit =
1065- if sym.is(Extension ) && ! sym.nextOverriddenSymbol.exists then
1065+ if sym.is(Extension ) then
10661066 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 )
10691068 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
10721072 def hidden =
10731073 target.nonPrivateMember(sym.name)
1074- .filterWithPredicate:
1075- member =>
1074+ .filterWithPredicate: member =>
10761075 member.symbol.isPublic && {
10771076 val memberIsImplicit = member.info.hasImplicitParams
10781077 val paramTps =
10791078 if memberIsImplicit then methTp.stripPoly.firstParamTypes
1080- else methTp.firstExplicitParamTypes
1079+ else methTp.explicit.firstParamTypes
10811080
10821081 paramTps.isEmpty || memberIsImplicit && ! methTp.hasImplicitParams || {
10831082 val memberParamTps = member.info.stripPoly.firstParamTypes
@@ -1089,7 +1088,15 @@ object RefChecks {
10891088 }
10901089 }
10911090 .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
10931100 then report.warning(ExtensionNullifiedByMember (sym, target.typeSymbol), sym.srcPos)
10941101 end checkExtensionMethods
10951102
0 commit comments