@@ -109,13 +109,6 @@ class PostTyper extends MacroTransform with InfoTransformer { thisPhase =>
109109 try op finally noCheckNews = saved
110110 }
111111
112- /** The set of all private class variables that are assigned
113- * when selected with a qualifier other than the `this` of the owning class.
114- * Such variables can contain only invariant type parameters in
115- * their types.
116- */
117- private var privateVarsSetNonLocally : Set [Symbol ] = Set ()
118-
119112 def isCheckable (t : New ): Boolean = ! inJavaAnnot && ! noCheckNews.contains(t)
120113
121114 /** Mark parameter accessors that are aliases of like-named parameters
@@ -156,8 +149,6 @@ class PostTyper extends MacroTransform with InfoTransformer { thisPhase =>
156149 private def processMemberDef (tree : Tree )(using Context ): tree.type = {
157150 val sym = tree.symbol
158151 Checking .checkValidOperator(sym)
159- if sym.isClass then
160- VarianceChecker .check(tree, privateVarsSetNonLocally)
161152 sym.transformAnnotations(transformAnnot)
162153 sym.defTree = tree
163154 tree
@@ -266,14 +257,6 @@ class PostTyper extends MacroTransform with InfoTransformer { thisPhase =>
266257 }
267258 }
268259
269- /** Update privateVarsSetNonLocally is symbol is a private variable
270- * that is selected from something other than `this` when assigned
271- */
272- private def markVarAccess (tree : Tree , qual : Tree )(using Context ): Unit =
273- val sym = tree.symbol
274- if sym.is(Private , butNot = Local ) && ! sym.isCorrectThisType(qual.tpe) then
275- privateVarsSetNonLocally += sym
276-
277260 def checkNoConstructorProxy (tree : Tree )(using Context ): Unit =
278261 if tree.symbol.is(ConstructorProxy ) then
279262 report.error(em " constructor proxy ${tree.symbol} cannot be used as a value " , tree.srcPos)
@@ -412,6 +395,7 @@ class PostTyper extends MacroTransform with InfoTransformer { thisPhase =>
412395 registerIfHasMacroAnnotations(tree)
413396 val sym = tree.symbol
414397 if (sym.isClass)
398+ VarianceChecker .check(tree)
415399 annotateExperimental(sym)
416400 checkMacroAnnotation(sym)
417401 if sym.isOneOf(GivenOrImplicit ) then
@@ -488,9 +472,6 @@ class PostTyper extends MacroTransform with InfoTransformer { thisPhase =>
488472 case tpe => tpe
489473 }
490474 )
491- case Assign (lhs @ Select (qual, _), _) =>
492- markVarAccess(lhs, qual)
493- super .transform(tree)
494475 case Typed (Ident (nme.WILDCARD ), _) =>
495476 withMode(Mode .Pattern )(super .transform(tree))
496477 // The added mode signals that bounds in a pattern need not
0 commit comments