diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2016-02-25 21:45:05 +1000 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2016-02-25 21:48:26 +1000 |
commit | 964630ec1f4cf94f4d09eff394f959e733e3fcf7 (patch) | |
tree | edbe21ff3fd89156701c8ecedf5d900915bfb759 /src/reflect/scala/reflect/internal/Symbols.scala | |
parent | d375334c26c625da345c5e77bca2975f21b8bd10 (diff) | |
parent | e0fc92a2b7b27141b41cecafd3ec7804ad02707b (diff) | |
download | scala-964630ec1f4cf94f4d09eff394f959e733e3fcf7.tar.gz scala-964630ec1f4cf94f4d09eff394f959e733e3fcf7.tar.bz2 scala-964630ec1f4cf94f4d09eff394f959e733e3fcf7.zip |
Merge remote-tracking branch 'origin/2.11.x' into merge/2.11.x-to-2.12.x-20160225
Conflicts:
scripts/jobs/integrate/bootstrap
src/build/maven/scala-actors-pom.xml
test/files/pos/t3420.flags
Conflicts were trivial to resolve.
Diffstat (limited to 'src/reflect/scala/reflect/internal/Symbols.scala')
-rw-r--r-- | src/reflect/scala/reflect/internal/Symbols.scala | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/src/reflect/scala/reflect/internal/Symbols.scala b/src/reflect/scala/reflect/internal/Symbols.scala index 5b613316cc..9a3f6a6f3f 100644 --- a/src/reflect/scala/reflect/internal/Symbols.scala +++ b/src/reflect/scala/reflect/internal/Symbols.scala @@ -1267,8 +1267,9 @@ trait Symbols extends api.Symbols { self: SymbolTable => /** These should be moved somewhere like JavaPlatform. */ def javaSimpleName: Name = addModuleSuffix(simpleName.dropLocal) - def javaBinaryName: Name = addModuleSuffix(fullNameInternal('/')) - def javaClassName: String = addModuleSuffix(fullNameInternal('.')).toString + def javaBinaryName: Name = name.newName(javaBinaryNameString) + def javaBinaryNameString: String = fullName('/', moduleSuffix) + def javaClassName: String = fullName('.', moduleSuffix) /** The encoded full path name of this symbol, where outer names and inner names * are separated by `separator` characters. @@ -1276,18 +1277,29 @@ trait Symbols extends api.Symbols { self: SymbolTable => * Never adds id. * Drops package objects. */ - final def fullName(separator: Char): String = fullNameAsName(separator).toString - - /** Doesn't drop package objects, for those situations (e.g. classloading) - * where the true path is needed. - */ - private def fullNameInternal(separator: Char): Name = ( - if (isRoot || isRootPackage || this == NoSymbol) name - else if (owner.isEffectiveRoot) name - else effectiveOwner.enclClass.fullNameAsName(separator) append (separator, name) - ) + final def fullName(separator: Char): String = fullName(separator, "") + + private def fullName(separator: Char, suffix: CharSequence): String = { + var b: java.lang.StringBuffer = null + def loop(size: Int, sym: Symbol): Unit = { + val symName = sym.name + val nSize = symName.length - (if (symName.endsWith(nme.LOCAL_SUFFIX_STRING)) 1 else 0) + if (sym.isRoot || sym.isRootPackage || sym == NoSymbol || sym.owner.isEffectiveRoot) { + val capacity = size + nSize + b = new java.lang.StringBuffer(capacity) + b.append(chrs, symName.start, nSize) + } else { + loop(size + nSize + 1, sym.effectiveOwner.enclClass) + b.append(separator) + b.append(chrs, symName.start, nSize) + } + } + loop(suffix.length(), this) + b.append(suffix) + b.toString + } - def fullNameAsName(separator: Char): Name = fullNameInternal(separator).dropLocal + def fullNameAsName(separator: Char): Name = name.newName(fullName(separator, "")) /** The encoded full path name of this symbol, where outer names and inner names * are separated by periods. |