diff options
author | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2015-02-09 14:47:50 +0100 |
---|---|---|
committer | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2015-02-11 11:37:47 +0100 |
commit | 89e897072e75ea0644f6d728cf062f4fa7981443 (patch) | |
tree | 8492dcbd17d31ee081e47519cde1a142c32846bd | |
parent | f2a9a7a9b6d3ae9699f5f50b8683db05d9a1f6e0 (diff) | |
download | dotty-89e897072e75ea0644f6d728cf062f4fa7981443.tar.gz dotty-89e897072e75ea0644f6d728cf062f4fa7981443.tar.bz2 dotty-89e897072e75ea0644f6d728cf062f4fa7981443.zip |
Fix #348 flatten short name shouldn't include package names
-rw-r--r-- | src/dotty/tools/dotc/core/SymDenotations.scala | 15 | ||||
-rw-r--r-- | src/dotty/tools/dotc/transform/Flatten.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/transform/SymUtils.scala | 2 |
3 files changed, 17 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala index 8e591f677..bce4322ff 100644 --- a/src/dotty/tools/dotc/core/SymDenotations.scala +++ b/src/dotty/tools/dotc/core/SymDenotations.scala @@ -292,6 +292,21 @@ object SymDenotations { if (isType) fn.toTypeName else fn.toTermName } + + /** The encoded flat name of this denotation, where joined names are separated by `separator` characters. */ + def flatName(separator: Char = '$')(implicit ctx: Context): Name = + if (symbol == NoSymbol || owner == NoSymbol || owner.isEffectiveRoot || (owner is PackageClass)) name + else { + var owner = this + var sep = "" + do { + owner = owner.owner + sep += separator + } while (!owner.isClass && !owner.isPackageObject) + val fn = owner.flatName(separator) ++ sep ++ name + if (isType) fn.toTypeName else fn.toTermName + } + /** `fullName` where `.' is the separator character */ def fullName(implicit ctx: Context): Name = fullNameSeparated('.') diff --git a/src/dotty/tools/dotc/transform/Flatten.scala b/src/dotty/tools/dotc/transform/Flatten.scala index ff3f06c68..0bd1bb75f 100644 --- a/src/dotty/tools/dotc/transform/Flatten.scala +++ b/src/dotty/tools/dotc/transform/Flatten.scala @@ -19,7 +19,7 @@ class Flatten extends MiniPhaseTransform with SymTransformer { thisTransform => def transformSym(ref: SymDenotation)(implicit ctx: Context) = { if (ref.isClass && !ref.is(Package) && !ref.owner.is(Package)) { ref.copySymDenotation( - name = ref.flatName, + name = ref.flatName(), owner = ref.enclosingPackageClass) } else ref diff --git a/src/dotty/tools/dotc/transform/SymUtils.scala b/src/dotty/tools/dotc/transform/SymUtils.scala index 0a5854ea7..c38b7cebd 100644 --- a/src/dotty/tools/dotc/transform/SymUtils.scala +++ b/src/dotty/tools/dotc/transform/SymUtils.scala @@ -93,7 +93,7 @@ class SymUtils(val self: Symbol) extends AnyVal { self.owner.info.decl(self.asTerm.name.fieldName).suchThat(!_.is(Method)).symbol /** `fullName` where `$' is the separator character */ - def flatName(implicit ctx: Context): Name = self.fullNameSeparated('$') + def flatName(implicit ctx: Context): Name = self.flatName('$') def initializer(implicit ctx: Context): TermSymbol = self.owner.info.decl(InitializerName(self.asTerm.name)).symbol.asTerm |