Skip to content

Commit df74102

Browse files
committed
Gradual warning for deprecated nonlocal return
1 parent 001bfc3 commit df74102

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,9 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
262262
case tp: ClassInfo =>
263263
if tp.cls.derivesFrom(defn.PolyFunctionClass) then
264264
tp.member(nme.apply).info match
265-
case info: PolyType => return toTextMethodAsFunction(info)
266-
case _ =>
267-
toTextParents(tp.parents) ~~ "{...}"
265+
case info: PolyType => toTextMethodAsFunction(info)
266+
case _ => toTextParents(tp.parents) ~~ "{...}"
267+
else toTextParents(tp.parents) ~~ "{...}"
268268
case JavaArrayType(elemtp) =>
269269
toText(elemtp) ~ "[]"
270270
case tp: LazyRef if !printDebug =>

compiler/src/dotty/tools/dotc/transform/NonLocalReturns.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import core._
55
import Contexts._, Symbols._, Types._, Flags._, StdNames._
66
import MegaPhase._
77
import NameKinds.NonLocalReturnKeyName
8-
import config.SourceVersion._
8+
import config.SourceVersion.*
99

1010
object NonLocalReturns {
1111
import ast.tpd._
@@ -95,10 +95,11 @@ class NonLocalReturns extends MiniPhase {
9595

9696
override def transformReturn(tree: Return)(using Context): Tree =
9797
if isNonLocalReturn(tree) then
98-
report.errorOrMigrationWarning(
98+
report.gradualErrorOrMigrationWarning(
9999
"Non local returns are no longer supported; use scala.util.control.NonLocalReturns instead",
100100
tree.srcPos,
101-
from = future)
101+
warnFrom = `3.0`,
102+
errorFrom = future)
102103
nonLocalReturnThrow(tree.expr, tree.from.symbol).withSpan(tree.span)
103104
else tree
104105
}

library/src/scala/util/control/NonLocalReturns.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package scala.util.control
44
*
55
* Usage:
66
*
7-
* import scala.util.control.NonLocalReturns._
7+
* import scala.util.control.NonLocalReturns.*
88
*
99
* returning { ... throwReturn(x) ... }
1010
*/

0 commit comments

Comments
 (0)