@@ -95,36 +95,26 @@ object Nullables with
95
95
96
96
/** An extractor for null-trackable references */
97
97
object TrackedRef
98
- def unapply (tree : Tree )(given Context ): Option [TermRef ] = isTracked(tree)
98
+ def unapply (tree : Tree )(given Context ): Option [TermRef ] = tree.typeOpt match
99
+ case ref : TermRef if isTracked(ref) => println(" tr: " + ref); Some (ref)
100
+ case _ => None
99
101
end TrackedRef
100
102
101
103
/** Is given reference tracked for nullability?
102
104
* This is the case if the reference is a path to an immutable val, or if it refers
103
105
* to a local mutable variable where all assignments to the variable are _reachable_
104
106
* (in the sense of how it is defined in assignmentSpans).
105
107
*/
106
- def isTracked (tree : Tree )(given Context ): Option [TermRef ] = tree.typeOpt match
107
- case ref : TermRef
108
- if ref.isStable
109
- || isTrackedNotNull(tree)
108
+ def isTracked (ref : TermRef )(given Context ) =
109
+ ref.isStable
110
110
|| { val sym = ref.symbol
111
- sym.is(Mutable )
112
- && sym.owner.isTerm
113
- && sym.owner.enclosingMethod == curCtx.owner.enclosingMethod
114
- && sym.span.exists
115
- && curCtx.compilationUnit != null // could be null under -Ytest-pickler
116
- && curCtx.compilationUnit.assignmentSpans.contains(sym.span.start)
117
- } =>
118
- Some (ref)
119
- case _ => None
120
-
121
- def isTrackedNotNull (tree : Tree )(given Context ) = tree match
122
- case Select (Apply (TypeApply (f : Ident , _), x :: Nil ), _) =>
123
- f.symbol == defn.Compiletime_notNull
124
- && tree.symbol.isStableMember
125
- && isTracked(x).isDefined
126
- case _ =>
127
- false
111
+ sym.is(Mutable )
112
+ && sym.owner.isTerm
113
+ && sym.owner.enclosingMethod == curCtx.owner.enclosingMethod
114
+ && sym.span.exists
115
+ && curCtx.compilationUnit != null // could be null under -Ytest-pickler
116
+ && curCtx.compilationUnit.assignmentSpans.contains(sym.span.start)
117
+ }
128
118
129
119
/** The nullability context to be used after a case that matches pattern `pat`.
130
120
* If `pat` is `null`, this will assert that the selector `sel` is not null afterwards.
0 commit comments