Skip to content

Commit 9a3a625

Browse files
committed
Fix typos
1 parent 2f42d1b commit 9a3a625

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ object NullOpsDecorator {
5151
}
5252

5353
val self1 = self.widenDealias
54-
val striped = strip(self1)
55-
if (striped ne self1) striped else self
54+
val stripped = strip(self1)
55+
if (stripped ne self1) stripped else self
5656
}
5757

5858
/** Like `stripNull`, but removes only the `JavaNull`s. */
@@ -73,14 +73,14 @@ object NullOpsDecorator {
7373

7474
/** Is self (after widening and dealiasing) a type of the form `T | Null`? */
7575
def isNullableUnion(implicit ctx: Context): Boolean = {
76-
val striped = self.stripNull()
77-
striped ne self
76+
val stripped = self.stripNull()
77+
stripped ne self
7878
}
7979

8080
/** Is self (after widening and dealiasing) a type of the form `T | JavaNull`? */
8181
def isJavaNullableUnion(implicit ctx: Context): Boolean = {
82-
val striped = self.stripNull(true)
83-
striped ne self
82+
val stripped = self.stripNull(true)
83+
stripped ne self
8484
}
8585
}
8686
}

compiler/src/dotty/tools/dotc/typer/Nullables.scala

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -224,17 +224,17 @@ object Nullables with
224224
val refSym = ref.symbol
225225
val refOwner = refSym.owner
226226

227-
@tailrec def usedWithinClosure(s: Symbol): Boolean =
227+
@tailrec def recur(s: Symbol): Boolean =
228228
s != NoSymbol
229229
&& s != refOwner
230230
&& (s.isOneOf(Lazy | Method) // not at the rhs of lazy ValDef or in a method (or lambda)
231231
|| s.isClass // not in a class
232232
// TODO: need to check by-name paramter
233-
|| usedWithinClosure(s.owner))
233+
|| recur(s.owner))
234234

235235
refSym.is(Mutable) // if it is immutable, we don't need to check the rest conditions
236236
&& refOwner.isTerm
237-
&& usedWithinClosure(curCtx.owner)
237+
&& recur(curCtx.owner)
238238

239239
given treeOps: extension (tree: Tree) with
240240

@@ -335,9 +335,11 @@ object Nullables with
335335
// lhs variable is no longer trackable. We don't need to check whether the type `T`
336336
// is correct here, as typer will check it.
337337
tree.withNotNullInfo(NotNullInfo(Set(), Set(ref)))
338-
else
339-
// otherwise, we know the variable will have a non-null value
338+
else if (curCtx.explicitNulls && ref.isNullableUnion)
339+
// If the initial type is nullable and the assigned value is non-null,
340+
// we add it to the NotNull
340341
tree.withNotNullInfo(NotNullInfo(Set(ref), Set()))
342+
else tree
341343
case _ => tree
342344

343345
private val analyzedOps = Set(nme.EQ, nme.NE, nme.eq, nme.ne, nme.ZAND, nme.ZOR, nme.UNARY_!)

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2289,7 +2289,7 @@ class Typer extends Namer
22892289
}
22902290

22912291
/** Tries to adapt NotNullInfos from creation context to the DefTree,
2292-
* returns whether the adaption is successed. The adaption only success if the
2292+
* returns whether the adaption took place. An adaption only takes place if the
22932293
* DefTree has a symbol and it has not been completed (is not forward referenced).
22942294
*/
22952295
def adaptCreationContext(mdef: untpd.DefTree)(implicit ctx: Context): Boolean =

0 commit comments

Comments
 (0)