@@ -10,14 +10,16 @@ import scala.tools.asm
1010import asm .Opcodes
1111
1212/**
13- * The BTypes component defines The BType class hierarchy. BTypes encapsulates all type information
13+ * The BTypes component defines The BType class hierarchy. BTypes encapsulate all type information
1414 * that is required after building the ASM nodes. This includes optimizations, generation of
1515 * InnerClass attributes and generation of stack map frames.
1616 *
1717 * This representation is immutable and independent of the compiler data structures, hence it can
1818 * be queried by concurrent threads.
1919 */
2020abstract class BTypes {
21+ import BTypes .InternalName
22+
2123 /**
2224 * A map from internal names to ClassBTypes. Every ClassBType is added to this map on its
2325 * construction.
@@ -29,12 +31,12 @@ abstract class BTypes {
2931 * Concurrent because stack map frames are computed when in the class writer, which might run
3032 * on multiple classes concurrently.
3133 */
32- protected val classBTypeFromInternalNameMap : collection.concurrent.Map [String , ClassBType ]
34+ protected val classBTypeFromInternalNameMap : collection.concurrent.Map [InternalName , ClassBType ]
3335
3436 /**
3537 * Obtain a previously constructed ClassBType for a given internal name.
3638 */
37- def classBTypeFromInternalName (internalName : String ) = classBTypeFromInternalNameMap(internalName)
39+ def classBTypeFromInternalName (internalName : InternalName ) = classBTypeFromInternalNameMap(internalName)
3840
3941 // Some core BTypes are required here, in class BType, where no Global instance is available.
4042 // The Global is only available in the subclass BTypesFromSymbols. We cannot depend on the actual
@@ -566,7 +568,7 @@ abstract class BTypes {
566568 * A ClassBType represents a class or interface type. The necessary information to build a
567569 * ClassBType is extracted from compiler symbols and types, see BTypesFromSymbols.
568570 */
569- final case class ClassBType (internalName : String ) extends RefBType {
571+ final case class ClassBType (internalName : InternalName ) extends RefBType {
570572 /**
571573 * Write-once variable allows initializing a cyclic graph of infos. This is required for
572574 * nested classes. Example: for the definition `class A { class B }` we have
@@ -827,3 +829,12 @@ abstract class BTypes {
827829 */
828830 def isCompilingPrimitive : Boolean
829831}
832+
833+ object BTypes {
834+ /**
835+ * A marker for strings that represent class internal names.
836+ * Ideally the type would be incompatible with String, for example by making it a value class.
837+ * But that would create overhead in a Collection[InternalName].
838+ */
839+ type InternalName = String
840+ }
0 commit comments