From 0432bb0a5a754fd51744403721b4eb043f4534d1 Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Sat, 28 Mar 2015 21:18:20 +0100 Subject: [PATCH] Make tpd#applyOverloaded work with methods other than --- src/dotty/tools/dotc/ast/tpd.scala | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/dotty/tools/dotc/ast/tpd.scala b/src/dotty/tools/dotc/ast/tpd.scala index d1fa1733f0d3..9e799a8d3a85 100644 --- a/src/dotty/tools/dotc/ast/tpd.scala +++ b/src/dotty/tools/dotc/ast/tpd.scala @@ -707,9 +707,15 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo { val alternatives = ctx.typer.resolveOverloaded(alts, proto, Nil) assert(alternatives.size == 1) // this is parsed from bytecode tree. there's nothing user can do about it + val prefixTpe = + if (method eq nme.CONSTRUCTOR) + receiver.tpe.normalizedPrefix // methods are part of the enclosing scope + else + receiver.tpe + val selected = alternatives.head val fun = receiver - .select(TermRef.withSig(receiver.tpe.normalizedPrefix, selected.termSymbol.asTerm)) + .select(TermRef.withSig(prefixTpe, selected.termSymbol.asTerm)) .appliedToTypes(targs) def adaptLastArg(lastParam: Tree, expectedType: Type) = {