Skip to content

Commit 653fe1a

Browse files
committed
Make PerRun take a CFT
1 parent c8afb18 commit 653fe1a

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

compiler/src/dotty/tools/dotc/core/Definitions.scala

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ class Definitions {
422422
def getWrapVarargsArrayModule: Symbol = ScalaRuntimeModule
423423

424424
// The set of all wrap{X, Ref}Array methods, where X is a value type
425-
val WrapArrayMethods: PerRun[collection.Set[Symbol]] = new PerRun({ implicit ctx =>
425+
val WrapArrayMethods: PerRun[collection.Set[Symbol]] = new PerRun({
426426
val methodNames = ScalaValueTypes.map(ast.tpd.wrapArrayMethodName) `union` Set(nme.wrapRefArray)
427427
methodNames.map(getWrapVarargsArrayModule.requiredMethod(_))
428428
})
@@ -983,12 +983,12 @@ class Definitions {
983983
// ----- Symbol sets ---------------------------------------------------
984984

985985
@tu lazy val AbstractFunctionType: Array[TypeRef] = mkArityArray("scala.runtime.AbstractFunction", MaxImplementedFunctionArity, 0)
986-
val AbstractFunctionClassPerRun: PerRun[Array[Symbol]] = new PerRun(implicit ctx => AbstractFunctionType.map(_.symbol.asClass))
986+
val AbstractFunctionClassPerRun: PerRun[Array[Symbol]] = new PerRun(AbstractFunctionType.map(_.symbol.asClass))
987987
def AbstractFunctionClass(n: Int)(using Context): Symbol = AbstractFunctionClassPerRun()(using ctx)(n)
988988
@tu private lazy val ImplementedFunctionType = mkArityArray("scala.Function", MaxImplementedFunctionArity, 0)
989-
def FunctionClassPerRun: PerRun[Array[Symbol]] = new PerRun(implicit ctx => ImplementedFunctionType.map(_.symbol.asClass))
989+
def FunctionClassPerRun: PerRun[Array[Symbol]] = new PerRun(ImplementedFunctionType.map(_.symbol.asClass))
990990

991-
val LazyHolder: PerRun[Map[Symbol, Symbol]] = new PerRun({ implicit ctx =>
991+
val LazyHolder: PerRun[Map[Symbol, Symbol]] = new PerRun({
992992
def holderImpl(holderType: String) = requiredClass("scala.runtime." + holderType)
993993
Map[Symbol, Symbol](
994994
IntClass -> holderImpl("LazyInt"),
@@ -1233,15 +1233,15 @@ class Definitions {
12331233
Function1SpecializedReturnTypes
12341234

12351235
@tu lazy val Function1SpecializedParamClasses: PerRun[collection.Set[Symbol]] =
1236-
new PerRun(implicit ctx => Function1SpecializedParamTypes.map(_.symbol))
1236+
new PerRun(Function1SpecializedParamTypes.map(_.symbol))
12371237
@tu lazy val Function2SpecializedParamClasses: PerRun[collection.Set[Symbol]] =
1238-
new PerRun(implicit ctx => Function2SpecializedParamTypes.map(_.symbol))
1238+
new PerRun(Function2SpecializedParamTypes.map(_.symbol))
12391239
@tu lazy val Function0SpecializedReturnClasses: PerRun[collection.Set[Symbol]] =
1240-
new PerRun(implicit ctx => Function0SpecializedReturnTypes.map(_.symbol))
1240+
new PerRun(Function0SpecializedReturnTypes.map(_.symbol))
12411241
@tu lazy val Function1SpecializedReturnClasses: PerRun[collection.Set[Symbol]] =
1242-
new PerRun(implicit ctx => Function1SpecializedReturnTypes.map(_.symbol))
1242+
new PerRun(Function1SpecializedReturnTypes.map(_.symbol))
12431243
@tu lazy val Function2SpecializedReturnClasses: PerRun[collection.Set[Symbol]] =
1244-
new PerRun(implicit ctx => Function2SpecializedReturnTypes.map(_.symbol))
1244+
new PerRun(Function2SpecializedReturnTypes.map(_.symbol))
12451245

12461246
def isSpecializableFunction(cls: ClassSymbol, paramTypes: List[Type], retType: Type)(using Context): Boolean =
12471247
paramTypes.length <= 2 && cls.derivesFrom(FunctionClass(paramTypes.length)) && (paramTypes match {
@@ -1352,13 +1352,12 @@ class Definitions {
13521352

13531353
// ----- primitive value class machinery ------------------------------------------
13541354

1355-
/** This class would also be obviated by the implicit function type design */
1356-
class PerRun[T](generate: Context => T) {
1355+
class PerRun[T](generate: Context ?=> T) {
13571356
private var current: RunId = NoRunId
13581357
private var cached: T = _
13591358
def apply()(using Context): T = {
13601359
if (current != currentRunId) {
1361-
cached = generate(ctx)
1360+
cached = generate
13621361
current = currentRunId
13631362
}
13641363
cached
@@ -1371,10 +1370,10 @@ class Definitions {
13711370
@tu private lazy val ScalaNumericValueTypes: collection.Set[TypeRef] = ScalaNumericValueTypeList.toSet
13721371
@tu private lazy val ScalaValueTypes: collection.Set[TypeRef] = ScalaNumericValueTypes `union` Set(UnitType, BooleanType)
13731372

1374-
val ScalaNumericValueClasses: PerRun[collection.Set[Symbol]] = new PerRun(implicit ctx => ScalaNumericValueTypes.map(_.symbol))
1375-
val ScalaValueClasses: PerRun[collection.Set[Symbol]] = new PerRun(implicit ctx => ScalaValueTypes.map(_.symbol))
1373+
val ScalaNumericValueClasses: PerRun[collection.Set[Symbol]] = new PerRun(ScalaNumericValueTypes.map(_.symbol))
1374+
val ScalaValueClasses: PerRun[collection.Set[Symbol]] = new PerRun(ScalaValueTypes.map(_.symbol))
13761375

1377-
val ScalaBoxedClasses: PerRun[collection.Set[Symbol]] = new PerRun(implicit ctx =>
1376+
val ScalaBoxedClasses: PerRun[collection.Set[Symbol]] = new PerRun(
13781377
Set(BoxedByteClass, BoxedShortClass, BoxedCharClass, BoxedIntClass, BoxedLongClass, BoxedFloatClass, BoxedDoubleClass, BoxedUnitClass, BoxedBooleanClass)
13791378
)
13801379

0 commit comments

Comments
 (0)