Skip to content

Commit 6dbf71d

Browse files
committed
Allow for overloaded extensions in hasExtensionMethod
This does not yet fully solve the problem of overloaded extensions, since the identified overloaded alternatives will still be ambiguous if the first parameter list is the same. But at least we get a notice what extension method was tried.
1 parent b537220 commit 6dbf71d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import Trees.Untyped
1111
import Contexts._
1212
import Flags._
1313
import Symbols._
14+
import Denotations.Denotation
1415
import Types._
1516
import Decorators._
1617
import ErrorReporting._
@@ -1204,8 +1205,12 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
12041205
* result matching `resultType`?
12051206
*/
12061207
def hasExtensionMethod(tp: Type, name: TermName, argType: Type, resultType: Type)(implicit ctx: Context) = {
1207-
val mbr = tp.memberBasedOnFlags(name, required = ExtensionMethod)
1208-
mbr.exists && isApplicable(tp.select(name, mbr), argType :: Nil, resultType)
1208+
def qualifies(mbr: Denotation) =
1209+
mbr.exists && isApplicable(tp.select(name, mbr), argType :: Nil, resultType)
1210+
tp.memberBasedOnFlags(name, required = ExtensionMethod) match {
1211+
case mbr: SingleDenotation => qualifies(mbr)
1212+
case mbr => mbr.hasAltWith(qualifies(_))
1213+
}
12091214
}
12101215

12111216
/** Compare owner inheritance level.

0 commit comments

Comments
 (0)