@@ -305,16 +305,8 @@ class Definitions {
305
305
def AnyRefType : TypeRef = AnyRefAlias .typeRef
306
306
307
307
// TODO(abeln): modify usage sites to use `RefEq_eq/ne` once we migrate to explicit nulls?
308
- lazy val Object_eq : TermSymbol = if (ctx.explicitNulls) {
309
- RefEq_eq
310
- } else {
311
- enterMethod(ObjectClass , nme.eq, methOfAnyRef(BooleanType ), Final )
312
- }
313
- lazy val Object_ne : TermSymbol = if (ctx.explicitNulls) {
314
- RefEq_ne
315
- } else {
316
- enterMethod(ObjectClass , nme.ne, methOfAnyRef(BooleanType ), Final )
317
- }
308
+ lazy val Object_eq : TermSymbol = if (ctx.explicitNulls) RefEq_eq else enterMethod(ObjectClass , nme.eq, methOfAnyRef(BooleanType ), Final )
309
+ lazy val Object_ne : TermSymbol = if (ctx.explicitNulls) RefEq_ne else enterMethod(ObjectClass , nme.ne, methOfAnyRef(BooleanType ), Final )
318
310
lazy val Object_synchronized : TermSymbol = enterPolyMethod(ObjectClass , nme.synchronized_, 1 ,
319
311
pt => MethodType (List (pt.paramRefs(0 )), pt.paramRefs(0 )), Final )
320
312
lazy val Object_clone : TermSymbol = enterMethod(ObjectClass , nme.clone_, MethodType (Nil , ObjectType ), Protected )
@@ -349,11 +341,7 @@ class Definitions {
349
341
350
342
/** Method representing a throw */
351
343
lazy val throwMethod : TermSymbol = {
352
- val argTpe = if (ctx.explicitNulls) {
353
- OrType (ThrowableType , NullType )
354
- } else {
355
- ThrowableType
356
- }
344
+ val argTpe = if (ctx.explicitNulls) OrType (ThrowableType , NullType ) else ThrowableType
357
345
enterMethod(OpsPackageClass , nme.THROWkw , MethodType (List (argTpe), NothingType ))
358
346
}
359
347
@@ -362,7 +350,7 @@ class Definitions {
362
350
def NothingType : TypeRef = NothingClass .typeRef
363
351
lazy val RuntimeNothingModuleRef : TermRef = ctx.requiredModuleRef(" scala.runtime.Nothing" )
364
352
365
- /** `RefEq` is the trait defining the reference equality operators (`eq`, `neq `).
353
+ /** `RefEq` is the trait defining the reference equality operators (`eq`, `ne `).
366
354
* It's a supertype of both `AnyRef` (which is non-nullable) and `Null`.
367
355
* With `RefEq`, we can compare `null` for reference equality a la `null eq foo`.
368
356
* `RefEq` is just a marker trait and there's no corresponding class file, since it gets erased to `Object`.
@@ -391,11 +379,7 @@ class Definitions {
391
379
}
392
380
393
381
lazy val NullClass : ClassSymbol = {
394
- val parents = if (ctx.explicitNulls) {
395
- List (AnyType , RefEqType )
396
- } else {
397
- List (ObjectType )
398
- }
382
+ val parents = if (ctx.explicitNulls) List (AnyType , RefEqType ) else List (ObjectType )
399
383
enterCompleteClassSymbol(ScalaPackageClass , tpnme.Null , AbstractFinal , parents)
400
384
}
401
385
def NullType : TypeRef = NullClass .typeRef
@@ -1252,11 +1236,7 @@ class Definitions {
1252
1236
1253
1237
lazy val NotRuntimeClasses : Set [Symbol ] = {
1254
1238
val classes : Set [Symbol ] = Set (AnyClass , AnyValClass , NullClass , NothingClass )
1255
- if (ctx.explicitNulls) {
1256
- classes + RefEqClass
1257
- } else {
1258
- classes
1259
- }
1239
+ if (ctx.explicitNulls) classes + RefEqClass else classes
1260
1240
}
1261
1241
1262
1242
/** Classes that are known not to have an initializer irrespective of
@@ -1470,7 +1450,7 @@ class Definitions {
1470
1450
// ----- Initialization ---------------------------------------------------
1471
1451
1472
1452
/** Lists core classes that don't have underlying bytecode, but are synthesized on-the-fly in every reflection universe */
1473
- def syntheticScalaClasses ( implicit ctx : Context ) : List [TypeSymbol ] = {
1453
+ lazy val syntheticScalaClasses : List [TypeSymbol ] = {
1474
1454
val synth = List (
1475
1455
AnyClass ,
1476
1456
AnyRefAlias ,
@@ -1489,18 +1469,14 @@ class Definitions {
1489
1469
else synth
1490
1470
}
1491
1471
1492
- def syntheticCoreClasses ( implicit ctx : Context ) : List [Symbol ] = syntheticScalaClasses ++ List (
1472
+ lazy val syntheticCoreClasses : List [Symbol ] = syntheticScalaClasses ++ List (
1493
1473
EmptyPackageVal ,
1494
1474
OpsPackageClass )
1495
1475
1496
1476
/** Lists core methods that don't have underlying bytecode, but are synthesized on-the-fly in every reflection universe */
1497
1477
lazy val syntheticCoreMethods : List [TermSymbol ] = {
1498
1478
val methods = AnyMethods ++ ObjectMethods ++ List (String_+ , throwMethod)
1499
- if (ctx.explicitNulls) {
1500
- methods ++ RefEqMethods
1501
- } else {
1502
- methods
1503
- }
1479
+ if (ctx.explicitNulls) methods ++ RefEqMethods else methods
1504
1480
}
1505
1481
1506
1482
lazy val reservedScalaClassNames : Set [Name ] = syntheticScalaClasses.map(_.name).toSet
@@ -1515,7 +1491,7 @@ class Definitions {
1515
1491
ScalaPackageClass .enter(m)
1516
1492
1517
1493
// force initialization of every symbol that is synthesized or hijacked by the compiler
1518
- val forced = syntheticCoreClasses(ctx) ++ syntheticCoreMethods ++ ScalaValueClasses ()
1494
+ val forced = syntheticCoreClasses ++ syntheticCoreMethods ++ ScalaValueClasses ()
1519
1495
1520
1496
isInitialized = true
1521
1497
}
0 commit comments