From dcfd96328f350a6265d7aac55c411ab798e93e77 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Fri, 4 Apr 2014 10:24:25 +0200 Subject: Shadowed references In TypeAssigner#ensureAccible we sometimes pick an inherited public member as the denotation of a NamedType instead of an inaccessible private one. The problem is that both are denotations for the same type, which caused a noDoubleBindings assert failure. We now solve this problem by creating a "shadowed" named type to hold the inherited member. The shadowed named type is distinguished by its name, which reads (inherited)originalName In the future, we should make this more robust by using a general tagging scheme to create shadowed names. Another fix is about import symbols. They are now referenced with NonMemberTermRefs. With this fix, the test suite passes with no double def violations. --- src/dotty/tools/dotc/typer/TypeAssigner.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/dotty/tools/dotc/typer/TypeAssigner.scala') diff --git a/src/dotty/tools/dotc/typer/TypeAssigner.scala b/src/dotty/tools/dotc/typer/TypeAssigner.scala index b194bdd60..12f2415d8 100644 --- a/src/dotty/tools/dotc/typer/TypeAssigner.scala +++ b/src/dotty/tools/dotc/typer/TypeAssigner.scala @@ -110,7 +110,7 @@ trait TypeAssigner { // an inherited non-private member with the same name and signature. val d2 = pre.nonPrivateMember(name) if (reallyExists(d2) && firstTry) - test(pre.select(name, d2), false) + test(tpe.shadowed.withDenot(d2), false) else { val alts = tpe.denot.alternatives.map(_.symbol).filter(_.exists) val what = alts match { @@ -326,7 +326,7 @@ trait TypeAssigner { tree.withType(sym.typeRef) def assignType(tree: untpd.Import, sym: Symbol)(implicit ctx: Context) = - tree.withType(sym.termRef) + tree.withType(sym.nonMemberTermRef) def assignType(tree: untpd.Annotated, annot: Tree, arg: Tree)(implicit ctx: Context) = tree.withType(AnnotatedType(Annotation(annot), arg.tpe)) -- cgit v1.2.3