Skip to content

Commit dbb48c8

Browse files
committed
Merge pull request #441 from smarter/fix/applyOverloaded-non-init
Make tpd#applyOverloaded work with methods other than <init>
2 parents 0cc73c6 + 0432bb0 commit dbb48c8

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
@@ -707,9 +707,15 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
707707
val alternatives = ctx.typer.resolveOverloaded(alts, proto, Nil)
708708
assert(alternatives.size == 1) // this is parsed from bytecode tree. there's nothing user can do about it
709709

710+
val prefixTpe =
711+
if (method eq nme.CONSTRUCTOR)
712+
receiver.tpe.normalizedPrefix // <init> methods are part of the enclosing scope
713+
else
714+
receiver.tpe
715+
710716
val selected = alternatives.head
711717
val fun = receiver
712-
.select(TermRef.withSig(receiver.tpe.normalizedPrefix, selected.termSymbol.asTerm))
718+
.select(TermRef.withSig(prefixTpe, selected.termSymbol.asTerm))
713719
.appliedToTypes(targs)
714720

715721
def adaptLastArg(lastParam: Tree, expectedType: Type) = {

0 commit comments

Comments
 (0)