You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Scala 2 a setter was created at Typer for private, non-local vars.
Variance
checking then worked on the setter. But in Scala 3, the setter is only
created
later, which caused a loophole for variance checking.
This PR does actually better than Scala 2 in the following sense: A
private variable counts as an invariant occurrence only if it is
assigned with a selector different from `this`. Or conversely, a
variable containing a covariant type parameter in its type can be read
from different objects, but all assignments must be via this. The
motivation is that such variables effectively behave like vals for the
purposes of variance checking.
0 commit comments