@@ -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
@@ -1250,11 +1234,7 @@ class Definitions {
1250
1234
1251
1235
lazy val NotRuntimeClasses : Set [Symbol ] = {
1252
1236
val classes : Set [Symbol ] = Set (AnyClass , AnyValClass , NullClass , NothingClass )
1253
- if (ctx.explicitNulls) {
1254
- classes + RefEqClass
1255
- } else {
1256
- classes
1257
- }
1237
+ if (ctx.explicitNulls) classes + RefEqClass else classes
1258
1238
}
1259
1239
1260
1240
/** Classes that are known not to have an initializer irrespective of
@@ -1468,7 +1448,7 @@ class Definitions {
1468
1448
// ----- Initialization ---------------------------------------------------
1469
1449
1470
1450
/** Lists core classes that don't have underlying bytecode, but are synthesized on-the-fly in every reflection universe */
1471
- def syntheticScalaClasses ( implicit ctx : Context ) : List [TypeSymbol ] = {
1451
+ lazy val syntheticScalaClasses : List [TypeSymbol ] = {
1472
1452
val synth = List (
1473
1453
AnyClass ,
1474
1454
AnyRefAlias ,
@@ -1487,18 +1467,14 @@ class Definitions {
1487
1467
else synth
1488
1468
}
1489
1469
1490
- def syntheticCoreClasses ( implicit ctx : Context ) : List [Symbol ] = syntheticScalaClasses ++ List (
1470
+ lazy val syntheticCoreClasses : List [Symbol ] = syntheticScalaClasses ++ List (
1491
1471
EmptyPackageVal ,
1492
1472
OpsPackageClass )
1493
1473
1494
1474
/** Lists core methods that don't have underlying bytecode, but are synthesized on-the-fly in every reflection universe */
1495
1475
lazy val syntheticCoreMethods : List [TermSymbol ] = {
1496
1476
val methods = AnyMethods ++ ObjectMethods ++ List (String_+ , throwMethod)
1497
- if (ctx.explicitNulls) {
1498
- methods ++ RefEqMethods
1499
- } else {
1500
- methods
1501
- }
1477
+ if (ctx.explicitNulls) methods ++ RefEqMethods else methods
1502
1478
}
1503
1479
1504
1480
lazy val reservedScalaClassNames : Set [Name ] = syntheticScalaClasses.map(_.name).toSet
@@ -1513,7 +1489,7 @@ class Definitions {
1513
1489
ScalaPackageClass .enter(m)
1514
1490
1515
1491
// force initialization of every symbol that is synthesized or hijacked by the compiler
1516
- val forced = syntheticCoreClasses(ctx) ++ syntheticCoreMethods ++ ScalaValueClasses ()
1492
+ val forced = syntheticCoreClasses ++ syntheticCoreMethods ++ ScalaValueClasses ()
1517
1493
1518
1494
isInitialized = true
1519
1495
}
0 commit comments