@@ -30,7 +30,7 @@ import Decorators._
3030import tpd ._
3131
3232import scala .tools .asm
33- import StdNames .nme
33+ import StdNames .{ nme , str }
3434import NameOps ._
3535import NameKinds .DefaultGetterName
3636import dotty .tools .dotc .core
@@ -161,7 +161,8 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
161161 def boxMethods : Map [Symbol , Symbol ] = defn.ScalaValueClasses ().map{x => // @darkdimius Are you sure this should be a def?
162162 (x, Erasure .Boxing .boxMethod(x.asClass))
163163 }.toMap
164- def unboxMethods : Map [Symbol , Symbol ] = defn.ScalaValueClasses ().map(x => (x, Erasure .Boxing .unboxMethod(x.asClass))).toMap
164+ def unboxMethods : Map [Symbol , Symbol ] =
165+ defn.ScalaValueClasses ().map(x => (x, Erasure .Boxing .unboxMethod(x.asClass))).toMap
165166
166167 override def isSyntheticArrayConstructor (s : Symbol ) = {
167168 s eq defn.newArrayMethod
@@ -244,15 +245,15 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
244245 case ClazzTag => av.visit(name, const.typeValue.toTypeKind(bcodeStore)(innerClasesStore).toASMType)
245246 case EnumTag =>
246247 val edesc = innerClasesStore.typeDescriptor(const.tpe.asInstanceOf [bcodeStore.int.Type ]) // the class descriptor of the enumeration class.
247- val evalue = const.symbolValue.name.toString // value the actual enumeration value.
248+ val evalue = const.symbolValue.name.mangledString // value the actual enumeration value.
248249 av.visitEnum(name, edesc, evalue)
249250 }
250251 case t : TypeApply if (t.fun.symbol == Predef_classOf ) =>
251252 av.visit(name, t.args.head.tpe.classSymbol.denot.info.toTypeKind(bcodeStore)(innerClasesStore).toASMType)
252253 case t : tpd.Select =>
253254 if (t.symbol.denot.is(Flags .Enum )) {
254255 val edesc = innerClasesStore.typeDescriptor(t.tpe.asInstanceOf [bcodeStore.int.Type ]) // the class descriptor of the enumeration class.
255- val evalue = t.symbol.name.toString // value the actual enumeration value.
256+ val evalue = t.symbol.name.mangledString // value the actual enumeration value.
256257 av.visitEnum(name, edesc, evalue)
257258 } else {
258259 assert(toDenot(t.symbol).name.is(DefaultGetterName )) // this should be default getter. do not emmit.
@@ -262,8 +263,8 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
262263 for (arg <- t.elems) { emitArgument(arrAnnotV, null , arg, bcodeStore)(innerClasesStore) }
263264 arrAnnotV.visitEnd()
264265
265- case Apply (fun, args) if ( fun.symbol == defn.ArrayClass .primaryConstructor ||
266- ( toDenot(fun.symbol).owner == defn.ArrayClass .linkedClass && fun.symbol.name == nme_apply)) =>
266+ case Apply (fun, args) if fun.symbol == defn.ArrayClass .primaryConstructor ||
267+ toDenot(fun.symbol).owner == defn.ArrayClass .linkedClass && fun.symbol.name == nme_apply =>
267268 val arrAnnotV : AnnotationVisitor = av.visitArray(name)
268269
269270 var actualArgs = if (fun.tpe.isInstanceOf [ImplicitMethodType ]) {
@@ -311,7 +312,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
311312 private def emitAssocs (av : asm.AnnotationVisitor , assocs : List [(Name , Object )], bcodeStore : BCodeHelpers )
312313 (innerClasesStore : bcodeStore.BCInnerClassGen ) = {
313314 for ((name, value) <- assocs)
314- emitArgument(av, name.toString , value.asInstanceOf [Tree ], bcodeStore)(innerClasesStore)
315+ emitArgument(av, name.mangledString , value.asInstanceOf [Tree ], bcodeStore)(innerClasesStore)
315316 av.visitEnd()
316317 }
317318
@@ -360,9 +361,8 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
360361 else clazz.getName
361362 }
362363
363- def requiredClass [T ](implicit evidence : ClassTag [T ]): Symbol = {
364+ def requiredClass [T ](implicit evidence : ClassTag [T ]): Symbol =
364365 ctx.requiredClass(erasureString(evidence.runtimeClass).toTermName)
365- }
366366
367367 def requiredModule [T ](implicit evidence : ClassTag [T ]): Symbol = {
368368 val moduleName = erasureString(evidence.runtimeClass)
@@ -404,16 +404,15 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
404404 def newAnyRefMap [K <: AnyRef , V ](): mutable.AnyRefMap [K , V ] = new mutable.AnyRefMap [K , V ]()
405405 def newWeakMap [K , V ](): mutable.WeakHashMap [K , V ] = new mutable.WeakHashMap [K , V ]()
406406 def recordCache [T <: Clearable ](cache : T ): T = cache
407- def newWeakSet [K <: AnyRef ](): WeakHashSet [K ] = new WeakHashSet [K ]()
407+ def newWeakSet [K >: Null <: AnyRef ](): WeakHashSet [K ] = new WeakHashSet [K ]()
408408 def newMap [K , V ](): mutable.HashMap [K , V ] = new mutable.HashMap [K , V ]()
409409 def newSet [K ](): mutable.Set [K ] = new mutable.HashSet [K ]
410410 }
411411
412+ val MODULE_INSTANCE_FIELD : String = str.MODULE_INSTANCE_FIELD
412413
413-
414- val MODULE_INSTANCE_FIELD : String = nme.MODULE_INSTANCE_FIELD .toString
415-
416- def internalNameString (offset : Int , length : Int ): String = new String (Names .chrs, offset, length)
414+ def dropModule (str : String ) =
415+ if (! str.isEmpty && str.last == '$' ) str.take(str.length - 1 ) else str
417416
418417 def newTermName (prefix : String ): Name = prefix.toTermName
419418
@@ -424,7 +423,6 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
424423 Flags .Bridge | Flags .VBridge | Flags .Private | Flags .Macro
425424 }.bits
426425
427-
428426 def isQualifierSafeToElide (qual : Tree ): Boolean = tpd.isIdempotentExpr(qual)
429427 def desugarIdent (i : Ident ): Option [tpd.Select ] = {
430428 i.tpe match {
@@ -537,32 +535,25 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
537535 }
538536 }
539537
540-
541538 implicit def nameHelper (n : Name ): NameHelper = new NameHelper {
542- def toTypeName : Name = n.toTypeName
543539 def isTypeName : Boolean = n.isTypeName
544- def toTermName : Name = n.toTermName
545- def dropModule : Name = n.stripModuleClassSuffix
546-
547- def len : Int = n.toSimpleName.length
548- def offset : Int = n.toSimpleName.start
549540 def isTermName : Boolean = n.isTermName
550541 def startsWith (s : String ): Boolean = n.startsWith(s)
542+ def mangledString : String = n.mangledString
551543 }
552544
553-
554545 implicit def symHelper (sym : Symbol ): SymbolHelper = new SymbolHelper {
555546 // names
556547 def fullName (sep : Char ): String = sym.showFullName
557548 def fullName : String = sym.showFullName
558549 def simpleName : Name = sym.name
559- def javaSimpleName : Name = toDenot(sym).name // addModuleSuffix(simpleName.dropLocal)
560- def javaBinaryName : Name = javaClassName.replace('.' , '/' ).toTypeName // TODO: can we make this a string? addModuleSuffix(fullNameInternal('/'))
561- def javaClassName : String = toDenot(sym).fullName.toString // addModuleSuffix(fullNameInternal('.')).toString
550+ def javaSimpleName : String = toDenot(sym).name.mangledString // addModuleSuffix(simpleName.dropLocal)
551+ def javaBinaryName : String = javaClassName.replace('.' , '/' ) // TODO: can we make this a string? addModuleSuffix(fullNameInternal('/'))
552+ def javaClassName : String = toDenot(sym).fullName.mangledString // addModuleSuffix(fullNameInternal('.')).toString
562553 def name : Name = sym.name
563- def rawname : Name = {
554+ def rawname : String = {
564555 val original = toDenot(sym).initial
565- sym.name(ctx.withPhase(original.validFor.phaseId))
556+ sym.name(ctx.withPhase(original.validFor.phaseId)).mangledString
566557 }
567558
568559 // types
@@ -675,9 +666,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
675666 }
676667 def enclClass : Symbol = toDenot(sym).enclosingClass
677668 def linkedClassOfClass : Symbol = linkedClass
678- def linkedClass : Symbol = {
679- toDenot(sym)(ctx).linkedClass(ctx)
680- } // exitingPickler(sym.linkedClassOfClass)
669+ def linkedClass : Symbol = toDenot(sym)(ctx).linkedClass(ctx) // exitingPickler(sym.linkedClassOfClass)
681670 def companionClass : Symbol = toDenot(sym).companionClass
682671 def companionModule : Symbol = toDenot(sym).companionModule
683672 def companionSymbol : Symbol = if (sym is Flags .Module ) companionClass else companionModule
0 commit comments