Skip to content

Commit a20aaf8

Browse files
committed
Change according to comments
1 parent b131f61 commit a20aaf8

File tree

11 files changed

+94
-91
lines changed

11 files changed

+94
-91
lines changed

compiler/src/dotty/tools/dotc/Resident.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,8 @@ class Resident extends Driver {
5353
nextCtx = rootCtx
5454
line = getLine()
5555
}
56-
if (line.startsWith(quit)) ctx.reporter
57-
else
58-
// split returns non-nullable values
59-
loop((line split "\\s+").asInstanceOf[Array[String]], nextCtx)
56+
if line.startsWith(quit) then ctx.reporter
57+
else loop((line split "\\s+").asInstanceOf[Array[String]], nextCtx)
6058
case None =>
6159
prevCtx.reporter
6260
}

compiler/src/dotty/tools/dotc/Run.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
172172
compileSources(sources)
173173
catch
174174
case NonFatal(ex) =>
175-
if units != Nil then report.echo(i"exception occurred while compiling $units%, %")
175+
if units.nonEmpty then report.echo(i"exception occurred while compiling $units%, %")
176176
else report.echo(s"exception occurred while compiling ${files.map(_.name).mkString(", ")}")
177177
throw ex
178178

compiler/src/dotty/tools/dotc/ast/tpd.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import NameKinds.{TempResultName, OuterSelectName}
1919
import typer.ConstFold
2020

2121
import scala.annotation.tailrec
22+
import scala.collection.mutable.ListBuffer
2223

2324
/** Some creators for typed trees */
2425
object tpd extends Trees.Instance[Type] with TypedTreeInfo {

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -862,10 +862,11 @@ object Contexts {
862862

863863
/** The platform */
864864
def platform: Platform = {
865-
if _platform == null then
865+
val p = _platform
866+
if p == null then
866867
throw new IllegalStateException(
867868
"initialize() must be called before accessing platform")
868-
_platform.uncheckedNN
869+
p
869870
}
870871

871872
protected def newPlatform(using Context): Platform =

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

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,18 @@ import annotation.tailrec
1010
object Hashable {
1111

1212
/** A null terminated list of BindingTypes. We use `null` here for efficiency */
13-
class Binders(val tp: BindingType, val next: Binders | Null)
13+
class SomeBinders(val tp: BindingType, val next: Binders)
14+
15+
type Binders = SomeBinders | Null
1416

1517
/** A null terminated list of pairs of BindingTypes. Used for isomorphism tests. */
16-
class BinderPairs(tp1: BindingType, tp2: BindingType, next: BinderPairs | Null) {
18+
class SomeBinderPairs(tp1: BindingType, tp2: BindingType, next: BinderPairs) {
1719
@tailrec final def matches(t1: Type, t2: Type): Boolean =
1820
(t1 `eq` tp1) && (t2 `eq` tp2) || next != null && next.matches(t1, t2)
1921
}
2022

23+
type BinderPairs = SomeBinderPairs | Null
24+
2125
/** A hash value indicating that the underlying type is not
2226
* cached in uniques.
2327
*/
@@ -45,24 +49,24 @@ trait Hashable {
4549
protected final def finishHash(hashCode: Int, arity: Int): Int =
4650
avoidSpecialHashes(hashing.finalizeHash(hashCode, arity))
4751

48-
final def typeHash(bs: Binders | Null, tp: Type): Int =
52+
final def typeHash(bs: Binders, tp: Type): Int =
4953
if (bs == null || tp.hashIsStable) tp.hash else tp.computeHash(bs)
5054

51-
def identityHash(bs: Binders | Null): Int = avoidSpecialHashes(System.identityHashCode(this))
55+
def identityHash(bs: Binders): Int = avoidSpecialHashes(System.identityHashCode(this))
5256

53-
protected def finishHash(bs: Binders | Null, seed: Int, arity: Int, tp: Type): Int = {
57+
protected def finishHash(bs: Binders, seed: Int, arity: Int, tp: Type): Int = {
5458
val elemHash = typeHash(bs, tp)
5559
if (elemHash == NotCached) return NotCached
5660
finishHash(hashing.mix(seed, elemHash), arity + 1)
5761
}
5862

59-
protected def finishHash(bs: Binders | Null, seed: Int, arity: Int, tp1: Type, tp2: Type): Int = {
63+
protected def finishHash(bs: Binders, seed: Int, arity: Int, tp1: Type, tp2: Type): Int = {
6064
val elemHash = typeHash(bs, tp1)
6165
if (elemHash == NotCached) return NotCached
6266
finishHash(bs, hashing.mix(seed, elemHash), arity + 1, tp2)
6367
}
6468

65-
protected def finishHash(bs: Binders | Null, seed: Int, arity: Int, tps: List[Type]): Int = {
69+
protected def finishHash(bs: Binders, seed: Int, arity: Int, tps: List[Type]): Int = {
6670
var h = seed
6771
var xs = tps
6872
var len = arity
@@ -76,7 +80,7 @@ trait Hashable {
7680
finishHash(h, len)
7781
}
7882

79-
protected def finishHash(bs: Binders | Null, seed: Int, arity: Int, tp: Type, tps: List[Type]): Int = {
83+
protected def finishHash(bs: Binders, seed: Int, arity: Int, tp: Type, tps: List[Type]): Int = {
8084
val elemHash = typeHash(bs, tp)
8185
if (elemHash == NotCached) return NotCached
8286
finishHash(bs, hashing.mix(seed, elemHash), arity + 1, tps)
@@ -86,28 +90,28 @@ trait Hashable {
8690
protected final def doHash(x: Any): Int =
8791
finishHash(hashing.mix(hashSeed, x.hashCode), 1)
8892

89-
protected final def doHash(bs: Binders | Null, tp: Type): Int =
93+
protected final def doHash(bs: Binders, tp: Type): Int =
9094
finishHash(bs, hashSeed, 0, tp)
9195

92-
protected final def doHash(bs: Binders | Null, x1: Any, tp2: Type): Int =
96+
protected final def doHash(bs: Binders, x1: Any, tp2: Type): Int =
9397
finishHash(bs, hashing.mix(hashSeed, x1.hashCode), 1, tp2)
9498

95-
protected final def doHash(bs: Binders | Null, x1: Int, tp2: Type): Int =
99+
protected final def doHash(bs: Binders, x1: Int, tp2: Type): Int =
96100
finishHash(bs, hashing.mix(hashSeed, x1), 1, tp2)
97101

98-
protected final def doHash(bs: Binders | Null, x1: Int, tp2: Type, tp3: Type): Int =
102+
protected final def doHash(bs: Binders, x1: Int, tp2: Type, tp3: Type): Int =
99103
finishHash(bs, hashing.mix(hashSeed, x1), 1, tp2, tp3)
100104

101-
protected final def doHash(bs: Binders | Null, tp1: Type, tp2: Type): Int =
105+
protected final def doHash(bs: Binders, tp1: Type, tp2: Type): Int =
102106
finishHash(bs, hashSeed, 0, tp1, tp2)
103107

104-
protected final def doHash(bs: Binders | Null, x1: Any, tp2: Type, tp3: Type): Int =
108+
protected final def doHash(bs: Binders, x1: Any, tp2: Type, tp3: Type): Int =
105109
finishHash(bs, hashing.mix(hashSeed, x1.hashCode), 1, tp2, tp3)
106110

107-
protected final def doHash(bs: Binders | Null, tp1: Type, tps2: List[Type]): Int =
111+
protected final def doHash(bs: Binders, tp1: Type, tps2: List[Type]): Int =
108112
finishHash(bs, hashSeed, 0, tp1, tps2)
109113

110-
protected final def doHash(bs: Binders | Null, x1: Any, tp2: Type, tps3: List[Type]): Int =
114+
protected final def doHash(bs: Binders, x1: Any, tp2: Type, tps3: List[Type]): Int =
111115
finishHash(bs, hashing.mix(hashSeed, x1.hashCode), 1, tp2, tps3)
112116

113117
protected final def doHash(x1: Int, x2: Int): Int =

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ object TypeErasure {
132132
*/
133133
abstract case class ErasedValueType(tycon: TypeRef, erasedUnderlying: Type)
134134
extends CachedGroundType with ValueType {
135-
override def computeHash(bs: Hashable.Binders | Null): Int = doHash(bs, tycon, erasedUnderlying)
135+
override def computeHash(bs: Hashable.Binders): Int = doHash(bs, tycon, erasedUnderlying)
136136
}
137137

138138
final class CachedErasedValueType(tycon: TypeRef, erasedUnderlying: Type)

0 commit comments

Comments
 (0)