-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backport "Check if a fatal warning issued in typer is silenced, befor…
…e converting it into an error" to LTS (#20701) Backports #18089 to the LTS branch. PR submitted by the release tooling. [skip ci]
- Loading branch information
Showing
7 changed files
with
123 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// scalac: -Wvalue-discard | ||
|
||
import scala.collection.mutable | ||
import scala.annotation.nowarn | ||
|
||
object Foo: | ||
|
||
def f(b: Boolean): String = | ||
val messageBuilder = mutable.StringBuilder() | ||
if b then | ||
// Here @nowarn is effective with or without -Wfatal-warnings | ||
// i.e. no warning without -Wfatal-warnings and no error with -Wfatal-warnings | ||
messageBuilder.append("helloworld").append("\n"): @nowarn("msg=discarded non-Unit value*") | ||
|
||
messageBuilder.result() | ||
|
||
def g(x: String => Unit) = ??? | ||
def h: String = | ||
val messageBuilder = mutable.StringBuilder() | ||
g: s => | ||
// here @nowarn is effective without -Wfatal-warnings (i.e. no warning) | ||
// But with -Wfatal-warnings we get an error | ||
messageBuilder.append("\n").append(s): @nowarn("msg=discarded non-Unit value*") | ||
messageBuilder.result() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// scalac: -Wvalue-discard -Wconf:msg=non-Unit:s | ||
|
||
import scala.collection.mutable | ||
import scala.annotation.nowarn | ||
|
||
object Test: | ||
|
||
def f(b: Boolean): String = | ||
val messageBuilder = mutable.StringBuilder() | ||
if b then | ||
// Here @nowarn is effective with or without -Wfatal-warnings | ||
// i.e. no warning without -Wfatal-warnings and no error with -Wfatal-warnings | ||
messageBuilder.append("helloworld").append("\n") | ||
|
||
messageBuilder.result() | ||
|
||
def g(x: String => Unit) = ??? | ||
def h: String = | ||
val messageBuilder = mutable.StringBuilder() | ||
g: s => | ||
// here @nowarn is effective without -Wfatal-warnings (i.e. no warning) | ||
// But with -Wfatal-warnings we get an error | ||
messageBuilder.append("\n").append(s) | ||
messageBuilder.result() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// scalac: -Wnonunit-statement | ||
|
||
class Node() | ||
class Elem( | ||
prefix: String, | ||
label: String, | ||
minimizeEmpty: Boolean, | ||
child: Node* | ||
) extends Node | ||
class Text(text: String) extends Node | ||
class NodeBuffer() { | ||
def &+(node: Node): NodeBuffer = | ||
this | ||
} | ||
class NodeSeq() | ||
object NodeSeq { | ||
def seqToNodeSeq(seq: NodeBuffer): Seq[Node] = ??? | ||
} | ||
|
||
object Main { | ||
def example() = { | ||
{ | ||
new Elem(null, "foo", false, | ||
{ | ||
val $buf: NodeBuffer = new NodeBuffer() | ||
$buf.&+(new Text("bar")) | ||
NodeSeq.seqToNodeSeq($buf) | ||
}* | ||
) | ||
} | ||
}: @annotation.nowarn() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
case class F(i: Int) | ||
|
||
object Main { | ||
def example() = | ||
List(1, 2, 3).map(F): @annotation.nowarn | ||
} |