-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Emit deferred reachability warnings & fix boxing/unboxing adapting #13485
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
dwijnand
merged 7 commits into
scala:master
from
dwijnand:emit-deferred-reachability-warnings
Sep 13, 2021
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3a8274c
Update checkfiles is success & rm out file
dwijnand 3340ba6
Test order-dependent reachability warnings
dwijnand f45c11d
Emit deferred reachability warnings
dwijnand 85747b5
Redo & organise adaptType in SpaceEngine
dwijnand 404d53c
Simplify adaptType by introducing unboxedType
dwijnand b9ecea2
Avoid generating skolems just to return true
dwijnand 48790dd
Restore adaptType, with expanded docs & tests
dwijnand File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
25 changes: 25 additions & 0 deletions
25
compiler/test/dotty/tools/dotc/transform/SpaceEngineTest.scala
This file contains hidden or 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,25 @@ | ||
package dotty.tools | ||
package dotc | ||
package transform | ||
|
||
import org.junit.*, Assert.* | ||
|
||
import core.*, Constants.*, Contexts.*, Decorators.*, Symbols.*, Types.* | ||
|
||
class SpaceEngineTest extends DottyTest: | ||
@Test def testAdaptTest(): Unit = | ||
given Context = ctx | ||
val defn = ctx.definitions | ||
import defn._ | ||
val e = patmat.SpaceEngine() | ||
|
||
val BoxedIntType = BoxedIntClass.typeRef | ||
val ConstOneType = ConstantType(Constant(1)) | ||
|
||
assertTrue(e.isPrimToBox(IntType, BoxedIntType)) | ||
assertFalse(e.isPrimToBox(BoxedIntType, IntType)) | ||
assertTrue(e.isPrimToBox(ConstOneType, BoxedIntType)) | ||
dwijnand marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
assertEquals(BoxedIntType, e.adaptType(IntType, BoxedIntType).widenSingleton) | ||
assertEquals(IntType, e.adaptType(BoxedIntType, IntType).widenSingleton) | ||
assertEquals(IntType, e.adaptType(BoxedIntType, ConstOneType).widenSingleton) |
This file contains hidden or 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 hidden or 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,8 +1,8 @@ | ||
-- Error: tests/neg-custom-args/fatal-warnings/i8711.scala:7:9 --------------------------------------------------------- | ||
-- [E030] Match case Unreachable Error: tests/neg-custom-args/fatal-warnings/i8711.scala:7:9 --------------------------- | ||
7 | case x: B => x // error: this case is unreachable since class A is not a subclass of class B | ||
| ^ | ||
| this case is unreachable since type A and class B are unrelated | ||
-- Error: tests/neg-custom-args/fatal-warnings/i8711.scala:12:9 -------------------------------------------------------- | ||
| ^^^^ | ||
| Unreachable case | ||
-- [E030] Match case Unreachable Error: tests/neg-custom-args/fatal-warnings/i8711.scala:12:9 -------------------------- | ||
12 | case x: C => x // error | ||
| ^ | ||
| this case is unreachable since type A | B and class C are unrelated | ||
| ^^^^ | ||
| Unreachable case |
This file contains hidden or 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,2 @@ | ||
11: Match case Unreachable | ||
16: Match case Unreachable |
This file contains hidden or 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 @@ | ||
// The intent of this test is test that changing the order of cases doesn't affect whether | ||
// warnings, originally reachability warnings but exhaustivity warnings too, are emitted. | ||
// To do so we need a case that typechecks but is statically assessed to be unreachable. | ||
// How about... a type pattern on a sealed trait that the scrutinee type doesn't extend? | ||
|
||
sealed trait Foo | ||
|
||
class Bar | ||
|
||
def test1(bar: Bar) = bar match | ||
case _: Foo => 1 | ||
case _: Bar => 2 | ||
|
||
def test2(bar: Bar) = bar match | ||
case _: Bar => 2 | ||
case _: Foo => 1 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.