@@ -883,7 +883,7 @@ class Definitions {
883
883
@ threadUnsafe lazy val FunctionClass : Array [Symbol ] =
884
884
mkArityArray(" scala.Function" , MaxImplementedFunctionArity , 0 ).map(_.symbol.asClass)
885
885
886
- val LazyHolder : PerRun [ Map [Symbol , Symbol ]] = new PerRun ({ implicit ctx =>
886
+ @ threadUnsafe lazy val LazyHolder : Map [Symbol , Symbol ] = {
887
887
def holderImpl (holderType : String ) = ctx.requiredClass(" scala.runtime." + holderType)
888
888
Map [Symbol , Symbol ](
889
889
IntClass -> holderImpl(" LazyInt" ),
@@ -896,7 +896,7 @@ class Definitions {
896
896
ShortClass -> holderImpl(" LazyShort" )
897
897
)
898
898
.withDefaultValue(holderImpl(" LazyRef" ))
899
- })
899
+ }
900
900
901
901
@ threadUnsafe lazy val TupleType : Array [TypeRef ] = mkArityArray(" scala.Tuple" , MaxTupleArity , 1 )
902
902
@@ -1108,39 +1108,28 @@ class Definitions {
1108
1108
isNonRefinedFunction(tp.dropDependentRefinement)
1109
1109
1110
1110
// Specialized type parameters defined for scala.Function{0,1,2}.
1111
- @ threadUnsafe lazy val Function1SpecializedParamTypes : collection.Set [TypeRef ] =
1112
- Set (IntType , LongType , FloatType , DoubleType )
1113
- @ threadUnsafe lazy val Function2SpecializedParamTypes : collection.Set [TypeRef ] =
1114
- Set (IntType , LongType , DoubleType )
1115
- @ threadUnsafe lazy val Function0SpecializedReturnTypes : collection.Set [TypeRef ] =
1116
- ScalaNumericValueTypeList .toSet + UnitType + BooleanType
1117
- @ threadUnsafe lazy val Function1SpecializedReturnTypes : collection.Set [TypeRef ] =
1118
- Set (UnitType , BooleanType , IntType , FloatType , LongType , DoubleType )
1119
- @ threadUnsafe lazy val Function2SpecializedReturnTypes : collection.Set [TypeRef ] =
1120
- Function1SpecializedReturnTypes
1121
-
1122
- @ threadUnsafe lazy val Function1SpecializedParamClasses : PerRun [collection.Set [Symbol ]] =
1123
- new PerRun (implicit ctx => Function1SpecializedParamTypes .map(_.symbol))
1124
- @ threadUnsafe lazy val Function2SpecializedParamClasses : PerRun [collection.Set [Symbol ]] =
1125
- new PerRun (implicit ctx => Function2SpecializedParamTypes .map(_.symbol))
1126
- @ threadUnsafe lazy val Function0SpecializedReturnClasses : PerRun [collection.Set [Symbol ]] =
1127
- new PerRun (implicit ctx => Function0SpecializedReturnTypes .map(_.symbol))
1128
- @ threadUnsafe lazy val Function1SpecializedReturnClasses : PerRun [collection.Set [Symbol ]] =
1129
- new PerRun (implicit ctx => Function1SpecializedReturnTypes .map(_.symbol))
1130
- @ threadUnsafe lazy val Function2SpecializedReturnClasses : PerRun [collection.Set [Symbol ]] =
1131
- new PerRun (implicit ctx => Function2SpecializedReturnTypes .map(_.symbol))
1111
+ @ threadUnsafe lazy val Function1SpecializedParamClasses : collection.Set [Symbol ] =
1112
+ Set (IntType , LongType , FloatType , DoubleType ).map(_.symbol)
1113
+ @ threadUnsafe lazy val Function2SpecializedParamClasses : collection.Set [Symbol ] =
1114
+ Set (IntType , LongType , DoubleType ).map(_.symbol)
1115
+ @ threadUnsafe lazy val Function0SpecializedReturnClasses : collection.Set [Symbol ] =
1116
+ (ScalaNumericValueTypeList .toSet + UnitType + BooleanType ).map(_.symbol)
1117
+ @ threadUnsafe lazy val Function1SpecializedReturnClasses : collection.Set [Symbol ] =
1118
+ Set (UnitType , BooleanType , IntType , FloatType , LongType , DoubleType ).map(_.symbol)
1119
+ @ threadUnsafe lazy val Function2SpecializedReturnClasses : collection.Set [Symbol ] =
1120
+ Function1SpecializedReturnClasses
1132
1121
1133
1122
def isSpecializableFunction (cls : ClassSymbol , paramTypes : List [Type ], retType : Type )(implicit ctx : Context ): Boolean =
1134
1123
paramTypes.length <= 2 && cls.derivesFrom(FunctionClass (paramTypes.length)) && (paramTypes match {
1135
1124
case Nil =>
1136
- Function0SpecializedReturnClasses () .contains(retType.typeSymbol)
1125
+ Function0SpecializedReturnClasses .contains(retType.typeSymbol)
1137
1126
case List (paramType0) =>
1138
- Function1SpecializedParamClasses () .contains(paramType0.typeSymbol) &&
1139
- Function1SpecializedReturnClasses () .contains(retType.typeSymbol)
1127
+ Function1SpecializedParamClasses .contains(paramType0.typeSymbol) &&
1128
+ Function1SpecializedReturnClasses .contains(retType.typeSymbol)
1140
1129
case List (paramType0, paramType1) =>
1141
- Function2SpecializedParamClasses () .contains(paramType0.typeSymbol) &&
1142
- Function2SpecializedParamClasses () .contains(paramType1.typeSymbol) &&
1143
- Function2SpecializedReturnClasses () .contains(retType.typeSymbol)
1130
+ Function2SpecializedParamClasses .contains(paramType0.typeSymbol) &&
1131
+ Function2SpecializedParamClasses .contains(paramType1.typeSymbol) &&
1132
+ Function2SpecializedReturnClasses .contains(retType.typeSymbol)
1144
1133
case _ =>
1145
1134
false
1146
1135
})
@@ -1188,31 +1177,17 @@ class Definitions {
1188
1177
1189
1178
// ----- primitive value class machinery ------------------------------------------
1190
1179
1191
- /** This class would also be obviated by the implicit function type design */
1192
- class PerRun [T ](generate : Context => T ) {
1193
- private [this ] var current : RunId = NoRunId
1194
- private [this ] var cached : T = _
1195
- def apply ()(implicit ctx : Context ): T = {
1196
- if (current != ctx.runId) {
1197
- cached = generate(ctx)
1198
- current = ctx.runId
1199
- }
1200
- cached
1201
- }
1202
- }
1203
-
1204
1180
@ threadUnsafe lazy val ScalaNumericValueTypeList : List [TypeRef ] = List (
1205
1181
ByteType , ShortType , CharType , IntType , LongType , FloatType , DoubleType )
1206
1182
1207
1183
@ threadUnsafe private lazy val ScalaNumericValueTypes : collection.Set [TypeRef ] = ScalaNumericValueTypeList .toSet
1208
1184
@ threadUnsafe private lazy val ScalaValueTypes : collection.Set [TypeRef ] = ScalaNumericValueTypes + UnitType + BooleanType
1209
1185
1210
- val ScalaNumericValueClasses : PerRun [ collection.Set [Symbol ]] = new PerRun ( implicit ctx => ScalaNumericValueTypes .map(_.symbol) )
1211
- val ScalaValueClasses : PerRun [ collection.Set [Symbol ]] = new PerRun ( implicit ctx => ScalaValueTypes .map(_.symbol) )
1186
+ @ threadUnsafe lazy val ScalaNumericValueClasses : collection.Set [Symbol ] = ScalaNumericValueTypes .map(_.symbol)
1187
+ @ threadUnsafe lazy val ScalaValueClasses : collection.Set [Symbol ] = ScalaValueTypes .map(_.symbol)
1212
1188
1213
- val ScalaBoxedClasses : PerRun [ collection.Set [Symbol ]] = new PerRun ( implicit ctx =>
1189
+ @ threadUnsafe lazy val ScalaBoxedClasses : collection.Set [Symbol ] =
1214
1190
Set (BoxedByteClass , BoxedShortClass , BoxedCharClass , BoxedIntClass , BoxedLongClass , BoxedFloatClass , BoxedDoubleClass , BoxedUnitClass , BoxedBooleanClass )
1215
- )
1216
1191
1217
1192
private val valueTypeEnc = mutable.Map [TypeName , PrimitiveClassEnc ]()
1218
1193
private val typeTags = mutable.Map [TypeName , Name ]().withDefaultValue(nme.specializedTypeNames.Object )
@@ -1314,7 +1289,7 @@ class Definitions {
1314
1289
ScalaPackageClass .enter(m)
1315
1290
1316
1291
// force initialization of every symbol that is synthesized or hijacked by the compiler
1317
- val forced = syntheticCoreClasses ++ syntheticCoreMethods ++ ScalaValueClasses () :+ JavaEnumClass
1292
+ val forced = syntheticCoreClasses ++ syntheticCoreMethods ++ ScalaValueClasses :+ JavaEnumClass
1318
1293
1319
1294
isInitialized = true
1320
1295
}
0 commit comments