@@ -95,36 +95,26 @@ object Nullables with
9595
9696 /** An extractor for null-trackable references */
9797 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
99101 end TrackedRef
100102
101103 /** Is given reference tracked for nullability?
102104 * This is the case if the reference is a path to an immutable val, or if it refers
103105 * to a local mutable variable where all assignments to the variable are _reachable_
104106 * (in the sense of how it is defined in assignmentSpans).
105107 */
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
110110 || { 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+ }
128118
129119 /** The nullability context to be used after a case that matches pattern `pat`.
130120 * If `pat` is `null`, this will assert that the selector `sel` is not null afterwards.
0 commit comments