Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions compiler/src/dotty/tools/dotc/typer/CrossVersionChecks.scala
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,12 @@ class CrossVersionChecks extends MiniPhase:
val tpe = tree.tpe
tpe.foreachPart {
case TypeRef(_, sym: Symbol) =>
checkDeprecated(sym, tree.srcPos)
if tree.span.isSourceDerived then
checkDeprecated(sym, tree.srcPos)
checkExperimentalRef(sym, tree.srcPos)
case TermRef(_, sym: Symbol) =>
checkDeprecated(sym, tree.srcPos)
if tree.span.isSourceDerived then
checkDeprecated(sym, tree.srcPos)
checkExperimentalRef(sym, tree.srcPos)
case _ =>
}
Expand Down
20 changes: 20 additions & 0 deletions tests/warn/i19302.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
-- Deprecation Warning: tests/warn/i19302.scala:8:20 -------------------------------------------------------------------
8 | def doo(): Option[Thing] = // warn
| ^^^^^
| class Thing is deprecated since n/a: is deprecated
-- Deprecation Warning: tests/warn/i19302.scala:9:13 -------------------------------------------------------------------
9 | Some(new Thing(1)) // warn
| ^^^^^
| class Thing is deprecated since n/a: is deprecated
-- Deprecation Warning: tests/warn/i19302.scala:10:23 ------------------------------------------------------------------
10 | def wop(x: => Option[Thing]) = println(x) // warn
| ^^^^^
| class Thing is deprecated since n/a: is deprecated
-- Deprecation Warning: tests/warn/i19302.scala:13:16 ------------------------------------------------------------------
13 | doo().map((t: Thing) => println(t)) // warn
| ^^^^^
| class Thing is deprecated since n/a: is deprecated
-- Deprecation Warning: tests/warn/i19302.scala:18:18 ------------------------------------------------------------------
18 | val thing = new Thing(42) // warn
| ^^^^^
| class Thing is deprecated since n/a: is deprecated
23 changes: 23 additions & 0 deletions tests/warn/i19302.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//> using options -deprecation

@deprecated("is deprecated", "n/a")
class Thing(val value: Int)

object Main extends App {

def doo(): Option[Thing] = // warn
Some(new Thing(1)) // warn
def wop(x: => Option[Thing]) = println(x) // warn

doo().map(t => println(t))
doo().map((t: Thing) => println(t)) // warn
doo().map(println)
doo().foreach(println)
for (x <- doo()) println(x)

val thing = new Thing(42) // warn
println(thing)

val something = Some(thing)
wop(something)
}