Open lrytz opened 1 month ago
$ scala -deprecation
Welcome to Scala 3.4.1 (21.0.2, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
scala> @deprecated class K
// defined class K
scala> val k = Some(new K)
1 warning found
-- Deprecation Warning: ------------------------------------------------------------------------------------------------
1 |val k = Some(new K)
| ^
| class K is deprecated
val k: Some[K] = Some(rs$line$1$K@5e7e7a7e)
scala> k match { case Some(v) => v }
1 warning found
-- Deprecation Warning: ------------------------------------------------------------------------------------------------
1 |k match { case Some(v) => v }
| ^
| class K is deprecated
val res0: K = K@5e7e7a7e
scala>
without -deprecation
the summary is
scala> val k = Some(new K)
there were 2 deprecation warnings; re-run with -deprecation for details
1 warning found
val k: Some[K] = Some(rs$line$1$K@7e1762e6)
The spec talks only about the expected type of the variable pattern. (It is not specified as a typed pattern.)
Spurious deprecation warning when the type of a bound value in a pattern is deprecated.
Scala 2.13.14:
the
case Some(the_k)
tree is transformed tocase (value: K): Some[K]((the_k @ _)) => 0
where the(value: K): Some[K]
tree is aTypeTree
with aMethodType
. The reference toK
in there is reported by RefChecks.