Skip to content

Commit b2c19b6

Browse files
committed
Reinstate deprecation of unicode arrows ( & )
Unicode arrows are deprecated in Scala 2.13, thanks to scala/scala#7540 merged in January 2019. For consistency, unless there's been a conscious decision to _un_deprecate them, we should continue that on into Scala 3.
1 parent 9e8d5c5 commit b2c19b6

File tree

11 files changed

+22
-20
lines changed

11 files changed

+22
-20
lines changed

compiler/src/dotty/tools/dotc/parsing/Scanners.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -879,9 +879,11 @@ object Scanners {
879879
case _ =>
880880
def fetchOther() =
881881
if (ch == '\u21D2') {
882+
report.deprecationWarning("The unicode arrow `⇒` is deprecated, use `=>` instead. If you still wish to display it as one character, consider using a font with programming ligatures such as Fira Code.", sourcePos(offset))
882883
nextChar(); token = ARROW
883884
}
884885
else if (ch == '\u2190') {
886+
report.deprecationWarning("The unicode arrow `←` is deprecated, use `<-` instead. If you still wish to display it as one character, consider using a font with programming ligatures such as Fira Code.", sourcePos(offset))
885887
nextChar(); token = LARROW
886888
}
887889
else if (Character.isUnicodeIdentifierStart(ch)) {

sbt-test/sbt-dotty/scaladoc/src/main/scala/ImpliedInstances.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ object ImpliedInstances {
1616

1717
def apply[A](using parser: StringParser[A]): StringParser[A] = parser
1818

19-
private def baseParser[A](f: String Try[A]): StringParser[A] = new StringParser[A] {
19+
private def baseParser[A](f: String => Try[A]): StringParser[A] = new StringParser[A] {
2020
override def parse(s: String): Try[A] = f(s)
2121
}
2222

2323
given stringParser: StringParser[String] = baseParser(Success(_))
24-
given intParser: StringParser[Int] = baseParser(s Try(s.toInt))
24+
given intParser: StringParser[Int] = baseParser(s => Try(s.toInt))
2525

2626
given optionParser[A](using parser: => StringParser[A]): StringParser[Option[A]] = new StringParser[Option[A]] {
2727
override def parse(s: String): Try[Option[A]] = s match {
28-
case "" Success(None) // implicit parser not used.
29-
case str parser.parse(str).map(x Some(x)) // implicit parser is evaluated at here
28+
case "" => Success(None) // implicit parser not used.
29+
case str => parser.parse(str).map(x => Some(x)) // implicit parser is evaluated at here
3030
}
3131
}
3232
}

scaladoc/src/dotty/tools/scaladoc/util/JSON.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def jsonString(s: String): JSON =
3131

3232
sb.append('"')
3333
firstToBeEncoded() match
34-
case -1 sb.append(s)
34+
case -1 => sb.append(s)
3535
case first =>
3636
// sb.append(s, 0, first) for "abc", 0, 2 produce "(abc,0,2)" rather then "ab" as in Java
3737
sb.append(s.substring(0, first))

tests/disabled/macro/run/t7240/Macros_1.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ object Bakery {
2222

2323
val tpeName = newTypeName(names.head)
2424
names.tail.reverse match {
25-
case head :: tail
26-
Select(tail.foldLeft[Tree](Ident(newTermName(head)))((tree, name) Select(tree, newTermName(name))), tpeName)
27-
case Nil
25+
case head :: tail =>
26+
Select(tail.foldLeft[Tree](Ident(newTermName(head)))((tree, name) => Select(tree, newTermName(name))), tpeName)
27+
case Nil =>
2828
Ident(tpeName)
2929
}
3030
}

tests/patmat/t11620.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,20 @@ object B {
1919
}
2020

2121
def foo[T](b: B[T]) = b match {
22-
case B(A1(t)) t
23-
case B(A2(t, _)) t
22+
case B(A1(t)) => t
23+
case B(A2(t, _)) => t
2424
}
2525

2626
def foo2[_A[+U] <: A[U], T](b: B.Aux[_A, T]) = b match {
27-
case B.Aux(a @ A1(_ )) a.t
28-
case B.Aux(a @ A2(_, _)) a.t1 // 👎 (false-positive): unreachable code
27+
case B.Aux(a @ A1(_ )) => a.t
28+
case B.Aux(a @ A2(_, _)) => a.t1 // 👎 (false-positive): unreachable code
2929
}
3030

3131
def foo3[_A[+U] <: A[U], T](b: B.Aux[_A, T]) = b match {
32-
case B.Aux(a: A1[T]) a.t
33-
case B.Aux(a: A2[T]) a.t1 // 👎 (false-positive): unreachable code
32+
case B.Aux(a: A1[T]) => a.t
33+
case B.Aux(a: A2[T]) => a.t1 // 👎 (false-positive): unreachable code
3434
}
3535

3636
def foo4[T](b: B[T]) = b match {
37-
case B(A1(t)) t // 👎 (false-negative): incomplete match
37+
case B(A1(t)) => t // 👎 (false-negative): incomplete match
3838
}

tests/pending/i12194.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ def f(): Unit =
1212

1313
@main def Test(): Unit =
1414
println(summonAll[Tuple.Map[("foo", "bar"), ValueOf]].toList.map{
15-
case str: ValueOf[_] str.value
15+
case str: ValueOf[_] => str.value
1616
})

tests/pending/pos/TypeIndexing.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
object Test {
1212
def use(a : A) = a match {
13-
case b @ A(t)
13+
case b @ A(t) =>
1414
val s: b.T = t // type mismatch.
1515
// found t.type (with underlying type <unapply-selector>.T)
1616
// required: a.T

tests/pending/run/t8091.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
object Test extends App {
2-
val result = "börk börk" flatMap (ch if (ch > 127) f"&#x${ch}%04x;" else "" + ch)
2+
val result = "börk börk" flatMap (ch => if (ch > 127) f"&#x${ch}%04x;" else "" + ch)
33
println(result)
44
}

tests/pos-special/utf16encoded.scala

2 Bytes
Binary file not shown.

tests/pos-special/utf8encoded.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//this file is saved as UTF-8
22
object Test {
33
def main(args: Array[String]): Unit = {
4-
val testchar = ''
4+
val testchar = '=>'
55
println(testchar == '\u21D2')
66
}
77

tests/run/cochis.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ trait A {
66
def trans[A] (x : A) (implicit f : A => A) = f(x)
77
}
88
object Test extends A with App {
9-
implicit def succ : Int Int = x x + 1 // (3)
9+
implicit def succ : Int => Int = x => x + 1 // (3)
1010
def bad [A] (x : A) : A = trans[A](x) // (4) incoherent de€nition !
1111
val v1 = bad [Int] (3) // (5) evaluates to 3
1212
val v2 = trans [Int] (3) // (6) substituting bad by trans is rejected

0 commit comments

Comments
 (0)