@@ -289,39 +289,40 @@ object SymDenotations {
289
289
}
290
290
291
291
/** The encoded full path name of this denotation, where outer names and inner names
292
- * are separated by `separator` characters .
292
+ * are separated by `separator` strings .
293
293
* Never translates expansions of operators back to operator symbol.
294
- * Drops package objects. Represents terms in the owner chain by a simple `separator`.
294
+ * Drops package objects. Represents terms in the owner chain by a simple `~`.
295
+ * A separator "" means "flat name"; the real separator in this case is "$" and
296
+ * enclosing packages do not form part of the name.
295
297
*/
296
- def fullNameSeparated (separator : Char )(implicit ctx : Context ): Name =
297
- if (symbol == NoSymbol || owner == NoSymbol || owner.isEffectiveRoot) name
298
+ def fullNameSeparated (separator : String )(implicit ctx : Context ): Name = {
299
+ var sep = separator
300
+ var stopAtPackage = false
301
+ if (sep.isEmpty) {
302
+ sep = " $"
303
+ stopAtPackage = true
304
+ }
305
+ if (symbol == NoSymbol ||
306
+ owner == NoSymbol ||
307
+ owner.isEffectiveRoot ||
308
+ stopAtPackage && owner.is(PackageClass )) name
298
309
else {
299
- var owner = this
300
- var sep = " "
301
- do {
302
- owner = owner.owner
303
- sep += separator
304
- } while ( ! owner.isClass && ! owner.isPackageObject)
305
- val fn = owner .fullNameSeparated(separator) ++ sep ++ name
310
+ var encl = owner
311
+ while ( ! encl.isClass && ! encl.isPackageObject) {
312
+ encl = encl.owner
313
+ sep += " ~ "
314
+ }
315
+ if ( owner.is( ModuleClass ) && sep == " $ " ) sep = " " // duplicate scalac's behavior: don't write a double '$$' for module class members.
316
+ val fn = encl .fullNameSeparated(separator) ++ sep ++ name
306
317
if (isType) fn.toTypeName else fn.toTermName
307
318
}
319
+ }
308
320
309
321
/** The encoded flat name of this denotation, where joined names are separated by `separator` characters. */
310
- def flatName (separator : Char = '$' )(implicit ctx : Context ): Name =
311
- if (symbol == NoSymbol || owner == NoSymbol || owner.isEffectiveRoot || (owner is PackageClass )) name
312
- else {
313
- var owner = this
314
- var sep = " "
315
- do {
316
- owner = owner.owner
317
- sep += separator
318
- } while (! owner.isClass && ! owner.isPackageObject)
319
- val fn = owner.flatName(separator) ++ sep ++ name
320
- if (isType) fn.toTypeName else fn.toTermName
321
- }
322
+ def flatName (implicit ctx : Context ): Name = fullNameSeparated(" " )
322
323
323
324
/** `fullName` where `.' is the separator character */
324
- def fullName (implicit ctx : Context ): Name = fullNameSeparated('.' )
325
+ def fullName (implicit ctx : Context ): Name = fullNameSeparated(" . " )
325
326
326
327
// ----- Tests -------------------------------------------------
327
328
@@ -1367,7 +1368,7 @@ object SymDenotations {
1367
1368
1368
1369
/** Enter a symbol in given `scope` without potentially replacing the old copy. */
1369
1370
def enterNoReplace (sym : Symbol , scope : MutableScope )(implicit ctx : Context ): Unit = {
1370
- require((sym.denot.flagsUNSAFE is Private ) || ! (this is Frozen ))
1371
+ require((sym.denot.flagsUNSAFE is Private ) || ! (this is Frozen ) || (unforcedDecls ne scope ))
1371
1372
scope.enter(sym)
1372
1373
1373
1374
if (myMemberFingerPrint != FingerPrint .unknown)
@@ -1572,8 +1573,8 @@ object SymDenotations {
1572
1573
}
1573
1574
}
1574
1575
1575
- private [this ] var fullNameCache : SimpleMap [Character , Name ] = SimpleMap .Empty
1576
- override final def fullNameSeparated (separator : Char )(implicit ctx : Context ): Name = {
1576
+ private [this ] var fullNameCache : SimpleMap [String , Name ] = SimpleMap .Empty
1577
+ override final def fullNameSeparated (separator : String )(implicit ctx : Context ): Name = {
1577
1578
val cached = fullNameCache(separator)
1578
1579
if (cached != null ) cached
1579
1580
else {
0 commit comments