Skip to content

Commit dc319c5

Browse files
committed
Make sure type parameters correspond to type args in applyOveroaded
tpd.applyOverloaded should not do type parameter inference; therefore it has to make sure all eligible alternatives have the same number of type parameters as there are type arguments.
1 parent fc79397 commit dc319c5

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/dotty/tools/dotc/ast/tpd.scala

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -847,7 +847,13 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
847847
assert(denot.exists, i"no member $receiver . $method, members = ${receiver.tpe.decls}")
848848
val selected =
849849
if (denot.isOverloaded) {
850-
val allAlts = denot.alternatives.map(_.termRef)
850+
def typeParamCount(tp: Type) = tp.widen match {
851+
case tp: PolyType => tp.paramBounds.length
852+
case _ => 0
853+
}
854+
var allAlts = denot.alternatives
855+
.map(_.termRef).filter(tr => typeParamCount(tr) == targs.length)
856+
if (targs.isEmpty) allAlts = allAlts.filterNot(_.widen.isInstanceOf[PolyType])
851857
val alternatives =
852858
ctx.typer.resolveOverloaded(allAlts, proto, Nil)
853859
assert(alternatives.size == 1,

0 commit comments

Comments
 (0)