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
/** Provides `check` method to check that all top-level definitions
@@ -108,11 +110,13 @@ class VarianceChecker()(implicit ctx: Context) {
108
110
}
109
111
110
112
privateobjectTraverserextendsTreeTraverser {
111
-
defcheckVariance(sym: Symbol) =Validator.validateDefinition(sym) match {
113
+
defcheckVariance(sym: Symbol, pos: Position) =Validator.validateDefinition(sym) match {
112
114
caseSome(VarianceError(tvar, required)) =>
113
115
defmsg=i"${varianceString(tvar.flags)}$tvar occurs in ${varianceString(required)} position in type ${sym.info} of $sym"
114
-
if (ctx.scala2Mode && sym.owner.isConstructor)
115
-
ctx.migrationWarning(s"According to new variance rules, this is no longer accepted; need to annotate with @uncheckedVariance:\n$msg", sym.pos)
116
+
if (ctx.scala2Mode && sym.owner.isConstructor) {
117
+
ctx.migrationWarning(s"According to new variance rules, this is no longer accepted; need to annotate with @uncheckedVariance:\n$msg, pos = ${sym.pos}", sym.pos)
118
+
patch(ctx.compilationUnit.source, Position(pos.end), " @scala.annotation.unchecked.uncheckedVariance") // TODO use an import or shorten if possible
119
+
}
116
120
else ctx.error(msg, sym.pos)
117
121
caseNone=>
118
122
}
@@ -128,12 +132,11 @@ class VarianceChecker()(implicit ctx: Context) {
128
132
casedefn: MemberDefif skip =>
129
133
ctx.debuglog(s"Skipping variance check of ${sym.showDcl}")
0 commit comments