@@ -1163,22 +1163,20 @@ object RefChecks {
11631163 * that are either both opaque types or both not.
11641164 */
11651165 def checkExtensionMethods (sym : Symbol )(using Context ): Unit =
1166- if sym.is(Extension ) && ! sym.nextOverriddenSymbol.exists then
1166+ if sym.is(Extension ) then
11671167 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 )
11701169 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
11731172 def hidden =
11741173 target.nonPrivateMember(sym.name)
1175- .filterWithPredicate:
1176- member =>
1174+ .filterWithPredicate: member =>
11771175 member.symbol.isPublic && {
11781176 val memberIsImplicit = member.info.hasImplicitParams
11791177 val paramTps =
11801178 if memberIsImplicit then methTp.stripPoly.firstParamTypes
1181- else methTp.firstExplicitParamTypes
1179+ else methTp.explicit.firstParamTypes
11821180
11831181 paramTps.isEmpty || memberIsImplicit && ! methTp.hasImplicitParams || {
11841182 val memberParamTps = member.info.stripPoly.firstParamTypes
@@ -1190,7 +1188,13 @@ object RefChecks {
11901188 }
11911189 }
11921190 .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
11941198 then report.warning(ExtensionNullifiedByMember (sym, target.typeSymbol), sym.srcPos)
11951199 end checkExtensionMethods
11961200
0 commit comments