Skip to content

Commit

Permalink
Merge pull request #10455 from som-snytt/issue/12199-message
Browse files Browse the repository at this point in the history
Tweak deprecation of array conversion
  • Loading branch information
lrytz committed Jul 4, 2023
2 parents 7c63166 + 51e926b commit 21eed35
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/library/scala/Predef.scala
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ private[scala] abstract class LowPriorityImplicits extends LowPriorityImplicits2
}

private[scala] abstract class LowPriorityImplicits2 {
@deprecated("Implicit conversions from Array to immutable.IndexedSeq are implemented by copying; Use the more efficient non-copying ArraySeq.unsafeWrapArray or an explicit toIndexedSeq call", "2.13.0")
@deprecated("implicit conversions from Array to immutable.IndexedSeq are implemented by copying; use `toIndexedSeq` explicitly if you want to copy, or use the more efficient non-copying ArraySeq.unsafeWrapArray", since="2.13.0")
implicit def copyArrayToImmutableIndexedSeq[T](xs: Array[T]): IndexedSeq[T] =
if (xs eq null) null
else new ArrayOps(xs).toIndexedSeq
Expand Down
6 changes: 6 additions & 0 deletions test/files/neg/t12199.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
t12199.scala:4: warning: method copyArrayToImmutableIndexedSeq in class LowPriorityImplicits2 is deprecated (since 2.13.0): implicit conversions from Array to immutable.IndexedSeq are implemented by copying; use `toIndexedSeq` explicitly if you want to copy, or use the more efficient non-copying ArraySeq.unsafeWrapArray
val a: IndexedSeq[Int] = Array(1, 2, 3)
^
error: No warnings can be incurred under -Werror.
1 warning
1 error
5 changes: 5 additions & 0 deletions test/files/neg/t12199.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// scalac: -Werror -Xlint

class C {
val a: IndexedSeq[Int] = Array(1, 2, 3)
}

0 comments on commit 21eed35

Please sign in to comment.