@@ -16,13 +16,13 @@ import config.Printers.nullables
1616import ast .{tpd , untpd }
1717
1818/** Operations for implementing a flow analysis for nullability */
19- object Nullables with
19+ object Nullables :
2020 import ast .tpd ._
2121
2222 /** A set of val or var references that are known to be not null, plus a set of
2323 * variable references that are not known (anymore) to be not null
2424 */
25- case class NotNullInfo (asserted : Set [TermRef ], retracted : Set [TermRef ])
25+ case class NotNullInfo (asserted : Set [TermRef ], retracted : Set [TermRef ]):
2626 assert((asserted & retracted).isEmpty)
2727
2828 def isEmpty = this eq NotNullInfo .empty
@@ -43,18 +43,18 @@ object Nullables with
4343 def alt (that : NotNullInfo ): NotNullInfo =
4444 NotNullInfo (this .asserted.intersect(that.asserted), this .retracted.union(that.retracted))
4545
46- object NotNullInfo with
46+ object NotNullInfo :
4747 val empty = new NotNullInfo (Set (), Set ())
4848 def apply (asserted : Set [TermRef ], retracted : Set [TermRef ]): NotNullInfo =
4949 if asserted.isEmpty && retracted.isEmpty then empty
5050 else new NotNullInfo (asserted, retracted)
5151 end NotNullInfo
5252
5353 /** A pair of not-null sets, depending on whether a condition is `true` or `false` */
54- case class NotNullConditional (ifTrue : Set [TermRef ], ifFalse : Set [TermRef ]) with
54+ case class NotNullConditional (ifTrue : Set [TermRef ], ifFalse : Set [TermRef ]):
5555 def isEmpty = this eq NotNullConditional .empty
5656
57- object NotNullConditional with
57+ object NotNullConditional :
5858 val empty = new NotNullConditional (Set (), Set ())
5959 def apply (ifTrue : Set [TermRef ], ifFalse : Set [TermRef ]): NotNullConditional =
6060 if ifTrue.isEmpty && ifFalse.isEmpty then empty
@@ -72,7 +72,7 @@ object Nullables with
7272 private [typer] val NNInfo = Property .StickyKey [NotNullInfo ]
7373
7474 /** An extractor for null comparisons */
75- object CompareNull with
75+ object CompareNull :
7676
7777 /** Matches one of
7878 *
@@ -97,7 +97,7 @@ object Nullables with
9797 end CompareNull
9898
9999 /** An extractor for null-trackable references */
100- object TrackedRef
100+ object TrackedRef :
101101 def unapply (tree : Tree )(using Context ): Option [TermRef ] = tree.typeOpt match
102102 case ref : TermRef if isTracked(ref) => Some (ref)
103103 case _ => None
@@ -160,7 +160,7 @@ object Nullables with
160160 // TODO: Add constant pattern if the constant type is not nullable
161161 case _ => false
162162
163- extension notNullInfoOps on (infos : List [NotNullInfo ]) with
163+ extension notNullInfoOps on (infos : List [NotNullInfo ]):
164164
165165 /** Do the current not-null infos imply that `ref` is not null?
166166 * Not-null infos are as a history where earlier assertions and retractions replace
@@ -191,7 +191,7 @@ object Nullables with
191191 infos.extendWith(NotNullInfo (Set (), mutables))
192192 // end notNullInfoOps
193193
194- extension refOps on (ref : TermRef ) with
194+ extension refOps on (ref : TermRef ):
195195
196196 /** Is the use of a mutable variable out of order
197197 *
@@ -245,7 +245,7 @@ object Nullables with
245245 && refOwner.isTerm
246246 && recur(curCtx.owner)
247247
248- extension treeOps on (tree : Tree ) with
248+ extension treeOps on (tree : Tree ):
249249
250250 /* The `tree` with added nullability attachment */
251251 def withNotNullInfo (info : NotNullInfo ): tree.type =
@@ -335,7 +335,7 @@ object Nullables with
335335 tree.computeNullable()
336336 }.traverse(tree)
337337
338- extension assignOps on (tree : Assign ) with
338+ extension assignOps on (tree : Assign ):
339339 def computeAssignNullable ()(using Context ): tree.type = tree.lhs match
340340 case TrackedRef (ref) =>
341341 val rhstp = tree.rhs.typeOpt
0 commit comments