aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-01-18 18:05:43 +0100
committerMartin Odersky <odersky@gmail.com>2014-01-18 18:05:52 +0100
commitd172c1687eb4558369616696d93ed944f2fc8776 (patch)
treeba14d2bb7d8752d3ed0a0a167b3c4dd233c2b85f
parent55c84fb40bccf7ab7c42f3544bd5f92e69b20ac4 (diff)
downloaddotty-d172c1687eb4558369616696d93ed944f2fc8776.tar.gz
dotty-d172c1687eb4558369616696d93ed944f2fc8776.tar.bz2
dotty-d172c1687eb4558369616696d93ed944f2fc8776.zip
Make signatures use fully qualified names.
Needed a refactoring of fullname to be able to refer to fullName without passing a context explicitly. Also, relax isAccessible check. The prefix condition for protected access need not hold for constructors.
-rw-r--r--src/dotty/tools/dotc/core/NameOps.scala2
-rw-r--r--src/dotty/tools/dotc/core/SymDenotations.scala12
-rw-r--r--src/dotty/tools/dotc/core/transform/Erasure.scala4
3 files changed, 10 insertions, 8 deletions
diff --git a/src/dotty/tools/dotc/core/NameOps.scala b/src/dotty/tools/dotc/core/NameOps.scala
index cd37c6086..de9bc0e5e 100644
--- a/src/dotty/tools/dotc/core/NameOps.scala
+++ b/src/dotty/tools/dotc/core/NameOps.scala
@@ -123,7 +123,7 @@ object NameOps {
/** The expanded name of `name` relative to this class `base` with given `separator`
*/
def expandedName(base: Symbol, separator: Name = nme.EXPAND_SEPARATOR)(implicit ctx: Context): N = {
- val prefix = if (base is Flags.ExpandedName) base.name else base.fullName('$')
+ val prefix = if (base is Flags.ExpandedName) base.name else base.fullNameSeparated('$')
name.fromName(prefix ++ separator ++ name).asInstanceOf[N]
}
diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala
index 9da918867..40f155ed9 100644
--- a/src/dotty/tools/dotc/core/SymDenotations.scala
+++ b/src/dotty/tools/dotc/core/SymDenotations.scala
@@ -229,7 +229,7 @@ object SymDenotations {
* Never translates expansions of operators back to operator symbol.
* Drops package objects. Represents terms in the owner chain by a simple `separator`.
*/
- def fullName(separator: Char)(implicit ctx: Context): Name =
+ def fullNameSeparated(separator: Char)(implicit ctx: Context): Name =
if (symbol == NoSymbol || owner == NoSymbol || owner.isEffectiveRoot) name
else {
var owner = this
@@ -238,11 +238,12 @@ object SymDenotations {
owner = owner.owner
sep += separator
} while (!owner.isClass)
- owner.skipPackageObject.fullName(separator) ++ sep ++ name
+ val fn = owner.skipPackageObject.fullNameSeparated(separator) ++ sep ++ name
+ if (isType) fn.toTypeName else fn.toTermName
}
/** `fullName` where `.' is the separator character */
- def fullName(implicit ctx: Context): Name = fullName('.')
+ def fullName(implicit ctx: Context): Name = fullNameSeparated('.')
// ----- Tests -------------------------------------------------
@@ -426,6 +427,7 @@ object SymDenotations {
else if (
!( isType // allow accesses to types from arbitrary subclasses fixes #4737
|| pre.baseType(cls).exists
+ || isConstructor
|| (owner is ModuleClass) // don't perform this check for static members
))
fail(
@@ -1092,11 +1094,11 @@ object SymDenotations {
}
private[this] var fullNameCache: SimpleMap[Character, Name] = SimpleMap.Empty
- override final def fullName(separator: Char)(implicit ctx: Context): Name = {
+ override final def fullNameSeparated(separator: Char)(implicit ctx: Context): Name = {
val cached = fullNameCache(separator)
if (cached != null) cached
else {
- val fn = super.fullName(separator)
+ val fn = super.fullNameSeparated(separator)
fullNameCache = fullNameCache.updated(separator, fn)
fn
}
diff --git a/src/dotty/tools/dotc/core/transform/Erasure.scala b/src/dotty/tools/dotc/core/transform/Erasure.scala
index 9b118dfe7..34f339d9a 100644
--- a/src/dotty/tools/dotc/core/transform/Erasure.scala
+++ b/src/dotty/tools/dotc/core/transform/Erasure.scala
@@ -107,8 +107,8 @@ object Erasure {
val sym = tp.symbol
if (sym.isClass)
/*if (sym.isDerivedValueClass) eraseDerivedValueClassRef(tref)
- else */if (sym.owner is Package) normalizeClass(sym.asClass).name
- else sym.asClass.name
+ else */if (sym.owner is Package) normalizeClass(sym.asClass).fullName.asTypeName
+ else sym.asClass.fullName.asTypeName
else sigName(tp.info)
case tp: RefinedType =>
val parent = tp.parent