Skip to content

Commit 1f45c67

Browse files
committed
Merge pull request #730 from smarter/fix/constructor-prefix
tpd#New: Make constructor TermRefs non-ambiguous
2 parents b8da1ee + 1f1f1a2 commit 1f45c67

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

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

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,9 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
383383
/** new C(args), calling given constructor `constr` of C */
384384
def New(tp: Type, constr: TermSymbol, args: List[Tree])(implicit ctx: Context): Apply = {
385385
val targs = tp.argTypes
386-
New(tp withoutArgs targs)
387-
.select(TermRef.withSig(tp.normalizedPrefix, constr))
386+
val tycon = tp.withoutArgs(targs)
387+
New(tycon)
388+
.select(TermRef.withSig(tycon, constr))
388389
.appliedToTypes(targs)
389390
.appliedToArgs(args)
390391
}
@@ -818,15 +819,9 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
818819
val alternatives = ctx.typer.resolveOverloaded(alts, proto, Nil)
819820
assert(alternatives.size == 1) // this is parsed from bytecode tree. there's nothing user can do about it
820821

821-
val prefixTpe =
822-
if (method eq nme.CONSTRUCTOR)
823-
receiver.tpe.normalizedPrefix // <init> methods are part of the enclosing scope
824-
else
825-
receiver.tpe
826-
827822
val selected = alternatives.head
828823
val fun = receiver
829-
.select(TermRef.withSig(prefixTpe, selected.termSymbol.asTerm))
824+
.select(TermRef.withSig(receiver.tpe, selected.termSymbol.asTerm))
830825
.appliedToTypes(targs)
831826

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

0 commit comments

Comments
 (0)