diff options
author | Lukas Rytz <lukas.rytz@gmail.com> | 2015-01-16 23:18:02 +0100 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@gmail.com> | 2015-01-16 23:18:07 +0100 |
commit | 45efefaa9b16532c1f61560bde09a7346dcfe5a1 (patch) | |
tree | 29f6f5e43238e0c958be817966a1d8274ba56562 /src | |
parent | 91435f68d280071d286c9d0e13b279293843ae7e (diff) | |
download | scala-45efefaa9b16532c1f61560bde09a7346dcfe5a1.tar.gz scala-45efefaa9b16532c1f61560bde09a7346dcfe5a1.tar.bz2 scala-45efefaa9b16532c1f61560bde09a7346dcfe5a1.zip |
Type alias for InternalName
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/backend/jvm/BTypes.scala | 19 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/backend/jvm/BTypesFromSymbols.scala | 3 |
2 files changed, 17 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BTypes.scala b/src/compiler/scala/tools/nsc/backend/jvm/BTypes.scala index 879f234918..e1ca13cba9 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/BTypes.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/BTypes.scala @@ -10,7 +10,7 @@ import scala.tools.asm import asm.Opcodes /** - * The BTypes component defines The BType class hierarchy. BTypes encapsulates all type information + * The BTypes component defines The BType class hierarchy. BTypes encapsulate all type information * that is required after building the ASM nodes. This includes optimizations, generation of * InnerClass attributes and generation of stack map frames. * @@ -18,6 +18,8 @@ import asm.Opcodes * be queried by concurrent threads. */ abstract class BTypes { + import BTypes.InternalName + /** * A map from internal names to ClassBTypes. Every ClassBType is added to this map on its * construction. @@ -29,12 +31,12 @@ abstract class BTypes { * Concurrent because stack map frames are computed when in the class writer, which might run * on multiple classes concurrently. */ - protected val classBTypeFromInternalNameMap: collection.concurrent.Map[String, ClassBType] + protected val classBTypeFromInternalNameMap: collection.concurrent.Map[InternalName, ClassBType] /** * Obtain a previously constructed ClassBType for a given internal name. */ - def classBTypeFromInternalName(internalName: String) = classBTypeFromInternalNameMap(internalName) + def classBTypeFromInternalName(internalName: InternalName) = classBTypeFromInternalNameMap(internalName) // Some core BTypes are required here, in class BType, where no Global instance is available. // The Global is only available in the subclass BTypesFromSymbols. We cannot depend on the actual @@ -566,7 +568,7 @@ abstract class BTypes { * A ClassBType represents a class or interface type. The necessary information to build a * ClassBType is extracted from compiler symbols and types, see BTypesFromSymbols. */ - final case class ClassBType(internalName: String) extends RefBType { + final case class ClassBType(internalName: InternalName) extends RefBType { /** * Write-once variable allows initializing a cyclic graph of infos. This is required for * nested classes. Example: for the definition `class A { class B }` we have @@ -827,3 +829,12 @@ abstract class BTypes { */ def isCompilingPrimitive: Boolean } + +object BTypes { + /** + * A marker for strings that represent class internal names. + * Ideally the type would be incompatible with String, for example by making it a value class. + * But that would create overhead in a Collection[InternalName]. + */ + type InternalName = String +}
\ No newline at end of file diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BTypesFromSymbols.scala b/src/compiler/scala/tools/nsc/backend/jvm/BTypesFromSymbols.scala index d02dd853d0..ef18d29841 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/BTypesFromSymbols.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/BTypesFromSymbols.scala @@ -7,6 +7,7 @@ package scala.tools.nsc package backend.jvm import scala.tools.asm +import BTypes.InternalName /** * This class mainly contains the method classBTypeFromSymbol, which extracts the necessary @@ -37,7 +38,7 @@ class BTypesFromSymbols[G <: Global](val global: G) extends BTypes { } protected val classBTypeFromInternalNameMap = { - global.perRunCaches.recordCache(collection.concurrent.TrieMap.empty[String, ClassBType]) + global.perRunCaches.recordCache(collection.concurrent.TrieMap.empty[InternalName, ClassBType]) } /** |