aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/NameOps.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-04-04 10:24:25 +0200
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2014-04-08 17:03:57 +0200
commitdcfd96328f350a6265d7aac55c411ab798e93e77 (patch)
treed07871190bb367e64235daa662d9f314696cc067 /src/dotty/tools/dotc/core/NameOps.scala
parentebd7df51e5b20e2c42717e216cc6be996d12c52a (diff)
downloaddotty-dcfd96328f350a6265d7aac55c411ab798e93e77.tar.gz
dotty-dcfd96328f350a6265d7aac55c411ab798e93e77.tar.bz2
dotty-dcfd96328f350a6265d7aac55c411ab798e93e77.zip
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.
Diffstat (limited to 'src/dotty/tools/dotc/core/NameOps.scala')
-rw-r--r--src/dotty/tools/dotc/core/NameOps.scala9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/dotty/tools/dotc/core/NameOps.scala b/src/dotty/tools/dotc/core/NameOps.scala
index 35f94aac7..22a7e5734 100644
--- a/src/dotty/tools/dotc/core/NameOps.scala
+++ b/src/dotty/tools/dotc/core/NameOps.scala
@@ -50,6 +50,9 @@ object NameOps {
implicit class NameDecorator[N <: Name](val name: N) extends AnyVal {
import nme._
+ def likeTyped(n: Name): N =
+ (if (name.isTermName) n.toTermName else n.toTypeName).asInstanceOf[N]
+
def isConstructorName = name == CONSTRUCTOR || name == IMPLCLASS_CONSTRUCTOR
def isExceptionResultName = name startsWith EXCEPTION_RESULT_PREFIX
def isImplClassName = name endsWith IMPL_CLASS_SUFFIX
@@ -62,6 +65,8 @@ object NameOps {
def isTraitSetterName = isSetterName && (name containsSlice TRAIT_SETTER_SEPARATOR)
def isSingletonName = name endsWith SINGLETON_SUFFIX
def isModuleClassName = name endsWith MODULE_SUFFIX
+ def isImportName = name startsWith IMPORT
+ def isInheritedName = name.head == '(' && name.startsWith(nme.INHERITED)
def isModuleVarName(name: Name): Boolean =
name.stripAnonNumberSuffix endsWith MODULE_VAR_SUFFIX
@@ -132,6 +137,10 @@ object NameOps {
if (idx < 0) name else (name drop (idx + separator.length)).asInstanceOf[N]
}
+ def inheritedName: N = likeTyped(nme.INHERITED ++ name)
+
+ def revertInherited: N = likeTyped(name.drop(nme.INHERITED.length))
+
/** Translate a name into a list of simple TypeNames and TermNames.
* In all segments before the last, type/term is determined by whether
* the following separator char is '.' or '#'. The last segment