@@ -845,15 +845,22 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
845
845
def applyOverloaded (receiver : Tree , method : TermName , args : List [Tree ], targs : List [Type ], expectedType : Type , isAnnotConstructor : Boolean = false )(implicit ctx : Context ): Tree = {
846
846
val typer = ctx.typer
847
847
val proto = new FunProtoTyped (args, expectedType, typer)
848
- val alts = receiver.tpe.member(method).alternatives.map(_.termRef)
849
-
850
- val alternatives = ctx.typer.resolveOverloaded(alts, proto, Nil )
851
- assert(alternatives.size == 1 ,
852
- i " multiple overloads available for $method on ${receiver.tpe.widenDealias} with targs: $targs, args: $args and expectedType: $expectedType. " +
853
- i " isAnnotConstructor = $isAnnotConstructor. \n " +
854
- i " alternatives: $alternatives" ) // this is parsed from bytecode tree. there's nothing user can do about it
855
-
856
- val selected = alternatives.head
848
+ val denot = receiver.tpe.member(method)
849
+ assert(denot.exists, i " no member $receiver . $method, members = ${receiver.tpe.decls}" )
850
+ val selected =
851
+ if (denot.isOverloaded) {
852
+ val allAlts = denot.alternatives.map(_.termRef)
853
+ val alternatives =
854
+ ctx.typer.resolveOverloaded(allAlts, proto, Nil )
855
+ assert(alternatives.size == 1 ,
856
+ i " ${if (alternatives.isEmpty) " no" else " multiple" } overloads available for " +
857
+ i " $method on ${receiver.tpe.widenDealias} with targs: $targs, args: $args and expectedType: $expectedType. " +
858
+ i " isAnnotConstructor = $isAnnotConstructor. \n " +
859
+ i " all alternatives: ${allAlts.map(_.symbol.showDcl).mkString(" , " )}\n " +
860
+ i " matching alternatives: ${alternatives.map(_.symbol.showDcl).mkString(" , " )}. " ) // this is parsed from bytecode tree. there's nothing user can do about it
861
+ alternatives.head
862
+ }
863
+ else denot.asSingleDenotation.termRef
857
864
val fun = receiver
858
865
.select(TermRef .withSig(receiver.tpe, selected.termSymbol.asTerm))
859
866
.appliedToTypes(targs)
0 commit comments