-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make fatal warnings not fail compilation early & aggregate warns (#19245
) Final PR. Adds functionality that changes the behaviour of fatal-warnings - fixes #18634 PR 5/5 (merge consecutively, per [Nicolas' suggestion](#18829 (review)) Split up version of #18829
- Loading branch information
Showing
160 changed files
with
1,067 additions
and
390 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,20 @@ | ||
//> using options -source:future-migration -deprecation -Werror | ||
scala> import scala.util._ | ||
-- Error: ---------------------------------------------------------------------- | ||
-- Migration Warning: ---------------------------------------------------------- | ||
1 | import scala.util._ | ||
| ^ | ||
| `_` is no longer supported for a wildcard import; use `*` instead | ||
|
||
No warnings can be incurred under -Werror (or -Xfatal-warnings) | ||
1 warning found | ||
1 error found | ||
scala> extension (x: Int) def foo(y: Int) = x + y | ||
def foo(x: Int)(y: Int): Int | ||
|
||
scala> 2 foo 4 | ||
-- Error: ---------------------------------------------------------------------- | ||
-- Migration Warning: ---------------------------------------------------------- | ||
1 | 2 foo 4 | ||
| ^^^ | ||
|Alphanumeric method foo is not declared infix; it should not be used as infix operator. | ||
|Instead, use method syntax .foo(...) or backticked identifier `foo`. | ||
1 error found | ||
No warnings can be incurred under -Werror (or -Xfatal-warnings) | ||
1 warning found | ||
1 error found |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,10 @@ | ||
-- Warning: tests/init-global/warn/context-sensitivity.scala:9:21 ------------------------------------------------------ | ||
9 | def foo(): Int = A.m // warn | ||
| ^^^ | ||
| Access uninitialized field value m. Calling trace: | ||
| ├── object A: [ context-sensitivity.scala:14 ] | ||
| │ ^ | ||
| ├── val m: Int = box1.value.foo() [ context-sensitivity.scala:17 ] | ||
| │ ^^^^^^^^^^^^^^^^ | ||
| └── def foo(): Int = A.m // warn [ context-sensitivity.scala:9 ] | ||
| ^^^ |
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
14 changes: 7 additions & 7 deletions
14
tests/init-global/neg/global-cycle1.check → tests/init-global/warn/global-cycle1.check
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 |
---|---|---|
@@ -1,20 +1,20 @@ | ||
-- Error: tests/init-global/neg/global-cycle1.scala:1:7 ---------------------------------------------------------------- | ||
1 |object A { // error | ||
-- Warning: tests/init-global/warn/global-cycle1.scala:1:7 ------------------------------------------------------------- | ||
1 |object A { // warn | ||
| ^ | ||
| Cyclic initialization: object A -> object B -> object A. Calling trace: | ||
| ├── object A { // error [ global-cycle1.scala:1 ] | ||
| ├── object A { // warn [ global-cycle1.scala:1 ] | ||
| │ ^ | ||
| ├── val a: Int = B.b [ global-cycle1.scala:2 ] | ||
| │ ^ | ||
| ├── object B { [ global-cycle1.scala:5 ] | ||
| │ ^ | ||
| └── val b: Int = A.a // error [ global-cycle1.scala:6 ] | ||
| └── val b: Int = A.a // warn [ global-cycle1.scala:6 ] | ||
| ^ | ||
-- Error: tests/init-global/neg/global-cycle1.scala:6:17 --------------------------------------------------------------- | ||
6 | val b: Int = A.a // error | ||
-- Warning: tests/init-global/warn/global-cycle1.scala:6:17 ------------------------------------------------------------ | ||
6 | val b: Int = A.a // warn | ||
| ^^^ | ||
| Access uninitialized field value a. Calling trace: | ||
| ├── object B { [ global-cycle1.scala:5 ] | ||
| │ ^ | ||
| └── val b: Int = A.a // error [ global-cycle1.scala:6 ] | ||
| └── val b: Int = A.a // warn [ global-cycle1.scala:6 ] | ||
| ^^^ |
4 changes: 2 additions & 2 deletions
4
tests/init-global/neg/global-cycle1.scala → tests/init-global/warn/global-cycle1.scala
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,20 @@ | ||
-- Warning: tests/init-global/warn/global-cycle14.scala:8:7 ------------------------------------------------------------ | ||
8 |object A { // warn | ||
| ^ | ||
| Cyclic initialization: object A -> object B -> object A. Calling trace: | ||
| ├── object A { // warn [ global-cycle14.scala:8 ] | ||
| │ ^ | ||
| ├── val n: Int = B.m [ global-cycle14.scala:9 ] | ||
| │ ^ | ||
| ├── object B { [ global-cycle14.scala:12 ] | ||
| │ ^ | ||
| └── val m: Int = A.n // warn [ global-cycle14.scala:13 ] | ||
| ^ | ||
-- Warning: tests/init-global/warn/global-cycle14.scala:13:17 ---------------------------------------------------------- | ||
13 | val m: Int = A.n // warn | ||
| ^^^ | ||
| Access uninitialized field value n. Calling trace: | ||
| ├── object B { [ global-cycle14.scala:12 ] | ||
| │ ^ | ||
| └── val m: Int = A.n // warn [ global-cycle14.scala:13 ] | ||
| ^^^ |
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,10 @@ | ||
-- Warning: tests/init-global/warn/global-cycle2.scala:6:21 ------------------------------------------------------------ | ||
6 | def foo(): Int = A.a * 2 // warn | ||
| ^^^ | ||
| Access uninitialized field value a. Calling trace: | ||
| ├── object A { [ global-cycle2.scala:1 ] | ||
| │ ^ | ||
| ├── val a: Int = B.foo() [ global-cycle2.scala:2 ] | ||
| │ ^^^^^^^ | ||
| └── def foo(): Int = A.a * 2 // warn [ global-cycle2.scala:6 ] | ||
| ^^^ |
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 |
---|---|---|
|
@@ -3,5 +3,5 @@ object A { | |
} | ||
|
||
object B { | ||
def foo(): Int = A.a * 2 // error | ||
def foo(): Int = A.a * 2 // warn | ||
} |
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,10 @@ | ||
-- Warning: tests/init-global/warn/global-cycle3.scala:2:21 ------------------------------------------------------------ | ||
2 | def foo(): Int = B.a + 10 // warn | ||
| ^^^ | ||
| Access uninitialized field value a. Calling trace: | ||
| ├── object B { [ global-cycle3.scala:5 ] | ||
| │ ^ | ||
| ├── val a: Int = A(4).foo() [ global-cycle3.scala:6 ] | ||
| │ ^^^^^^^^^^ | ||
| └── def foo(): Int = B.a + 10 // warn [ global-cycle3.scala:2 ] | ||
| ^^^ |
2 changes: 1 addition & 1 deletion
2
tests/init-global/neg/global-cycle3.scala → tests/init-global/warn/global-cycle3.scala
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
class A(x: Int) { | ||
def foo(): Int = B.a + 10 // error | ||
def foo(): Int = B.a + 10 // warn | ||
} | ||
|
||
object B { | ||
|
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,10 @@ | ||
-- Warning: tests/init-global/warn/global-cycle4.scala:10:21 ----------------------------------------------------------- | ||
10 | def foo(): Int = O.a + 10 // warn | ||
| ^^^ | ||
| Access uninitialized field value a. Calling trace: | ||
| ├── object O { [ global-cycle4.scala:17 ] | ||
| │ ^ | ||
| ├── val a: Int = D(5).bar().foo() [ global-cycle4.scala:18 ] | ||
| │ ^^^^^^^^^^^^^^^^ | ||
| └── def foo(): Int = O.a + 10 // warn [ global-cycle4.scala:10 ] | ||
| ^^^ |
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,9 @@ | ||
-- Warning: tests/init-global/warn/global-cycle5.scala:10:17 ----------------------------------------------------------- | ||
10 | val b: Int = A.a.foo() // warn | ||
| ^^^ | ||
|Reading mutable state of object A during initialization of object B. | ||
|Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace: | ||
|├── object B { [ global-cycle5.scala:9 ] | ||
|│ ^ | ||
|└── val b: Int = A.a.foo() // warn [ global-cycle5.scala:10 ] | ||
| ^^^ |
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,28 @@ | ||
-- Warning: tests/init-global/warn/global-cycle6.scala:1:7 ------------------------------------------------------------- | ||
1 |object A { // warn | ||
| ^ | ||
| Cyclic initialization: object A -> object B -> object A. Calling trace: | ||
| ├── object A { // warn [ global-cycle6.scala:1 ] | ||
| │ ^ | ||
| ├── val n: Int = B.m [ global-cycle6.scala:2 ] | ||
| │ ^ | ||
| ├── object B { [ global-cycle6.scala:8 ] | ||
| │ ^ | ||
| ├── val a = new A.Inner [ global-cycle6.scala:9 ] | ||
| │ ^^^^^^^^^^^ | ||
| ├── class Inner { [ global-cycle6.scala:3 ] | ||
| │ ^ | ||
| └── println(n) // warn [ global-cycle6.scala:4 ] | ||
| ^ | ||
-- Warning: tests/init-global/warn/global-cycle6.scala:4:12 ------------------------------------------------------------ | ||
4 | println(n) // warn | ||
| ^ | ||
| Access uninitialized field value n. Calling trace: | ||
| ├── object B { [ global-cycle6.scala:8 ] | ||
| │ ^ | ||
| ├── val a = new A.Inner [ global-cycle6.scala:9 ] | ||
| │ ^^^^^^^^^^^ | ||
| ├── class Inner { [ global-cycle6.scala:3 ] | ||
| │ ^ | ||
| └── println(n) // warn [ global-cycle6.scala:4 ] | ||
| ^ |
4 changes: 2 additions & 2 deletions
4
tests/init-global/neg/global-cycle6.scala → tests/init-global/warn/global-cycle6.scala
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,20 @@ | ||
-- Warning: tests/init-global/warn/global-cycle7.scala:1:7 ------------------------------------------------------------- | ||
1 |object A { // warn | ||
| ^ | ||
| Cyclic initialization: object A -> object B -> object A. Calling trace: | ||
| ├── object A { // warn [ global-cycle7.scala:1 ] | ||
| │ ^ | ||
| ├── val n: Int = B.m [ global-cycle7.scala:2 ] | ||
| │ ^ | ||
| ├── object B { [ global-cycle7.scala:5 ] | ||
| │ ^ | ||
| └── val m: Int = A.n // warn [ global-cycle7.scala:6 ] | ||
| ^ | ||
-- Warning: tests/init-global/warn/global-cycle7.scala:6:17 ------------------------------------------------------------ | ||
6 | val m: Int = A.n // warn | ||
| ^^^ | ||
| Access uninitialized field value n. Calling trace: | ||
| ├── object B { [ global-cycle7.scala:5 ] | ||
| │ ^ | ||
| └── val m: Int = A.n // warn [ global-cycle7.scala:6 ] | ||
| ^^^ |
4 changes: 2 additions & 2 deletions
4
tests/init-global/neg/global-cycle7.scala → tests/init-global/warn/global-cycle7.scala
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,16 @@ | ||
-- Warning: tests/init-global/warn/global-cycle8.scala:9:7 ------------------------------------------------------------- | ||
9 |object O { // warn | ||
| ^ | ||
| Cyclic initialization: object O -> object P -> object O. Calling trace: | ||
| ├── object O { // warn [ global-cycle8.scala:9 ] | ||
| │ ^ | ||
| ├── println(P.m) [ global-cycle8.scala:11 ] | ||
| │ ^ | ||
| ├── object P { [ global-cycle8.scala:14 ] | ||
| │ ^ | ||
| ├── val m = Q.bar(new B) [ global-cycle8.scala:15 ] | ||
| │ ^^^^^^^^^^^^ | ||
| ├── def bar(b: B) = b.a.foo() [ global-cycle8.scala:19 ] | ||
| │ ^^^^^^^^^ | ||
| └── def foo() = println(O.n) [ global-cycle8.scala:2 ] | ||
| ^ |
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 |
---|---|---|
|
@@ -6,7 +6,7 @@ class B { | |
val a = new A | ||
} | ||
|
||
object O { // error | ||
object O { // warn | ||
val n: Int = 10 | ||
println(P.m) | ||
} | ||
|
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,9 @@ | ||
-- Warning: tests/init-global/warn/global-irrelevance1.scala:5:12 ------------------------------------------------------ | ||
5 | var y = A.x * 2 // warn | ||
| ^^^ | ||
|Reading mutable state of object A during initialization of object B. | ||
|Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace: | ||
|├── object B: [ global-irrelevance1.scala:4 ] | ||
|│ ^ | ||
|└── var y = A.x * 2 // warn [ global-irrelevance1.scala:5 ] | ||
| ^^^ |
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 |
---|---|---|
|
@@ -2,4 +2,4 @@ object A: | |
var x = 6 | ||
|
||
object B: | ||
var y = A.x * 2 // error | ||
var y = A.x * 2 // warn |
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,13 @@ | ||
-- Warning: tests/init-global/warn/global-irrelevance2.scala:5:6 ------------------------------------------------------- | ||
5 | A.x = b * 2 // warn | ||
| ^^^^^^^^^^^^ | ||
| Mutating object A during initialization of object B. | ||
| Mutating other static objects during the initialization of one static object is forbidden. Calling trace: | ||
| ├── object B: [ global-irrelevance2.scala:7 ] | ||
| │ ^ | ||
| ├── new B(10) [ global-irrelevance2.scala:8 ] | ||
| │ ^^^^^^^^^ | ||
| ├── class B(b: Int): [ global-irrelevance2.scala:4 ] | ||
| │ ^ | ||
| └── A.x = b * 2 // warn [ global-irrelevance2.scala:5 ] | ||
| ^^^^^^^^^^^^ |
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 |
---|---|---|
|
@@ -2,7 +2,7 @@ object A: | |
var x = 6 | ||
|
||
class B(b: Int): | ||
A.x = b * 2 // error | ||
A.x = b * 2 // warn | ||
|
||
object B: | ||
new B(10) |
Oops, something went wrong.