-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Reject all explicitly written type references with bad bounds #15577
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
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7104d2e
Reject all explicitly written type references with bad bounds
odersky 69858b5
Undo ZIO changes
odersky 875b9f8
Fix explanation for lower bounds failures
odersky cac3d78
Flag type creation rather than usage
odersky a24915c
Don't check bounds for type definitions in abstract classes
odersky fbdcf5e
Add test for type projections
odersky 116a48b
Update compiler/src/dotty/tools/dotc/typer/Checking.scala
odersky 7c13eee
Re-instantiate accidentally dropped comment
odersky 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
Submodule zio
updated
2 files
+1 −1 | test/shared/src/main/scala/zio/test/Spec.scala | |
+12 −12 | test/shared/src/main/scala/zio/test/TestAspect.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
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
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
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,5 +1,5 @@ | ||
class B { | ||
val a: String = (((1: Any): b.A): Nothing): String | ||
val b: { type A >: Any <: Nothing } = loop() // error | ||
val b: { type A >: Any <: Nothing } = loop() // error | ||
def loop(): Nothing = loop() | ||
} |
This file was deleted.
Oops, something went wrong.
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,40 @@ | ||
-- [E057] Type Mismatch Error: tests/neg-custom-args/i15575.scala:3:27 ------------------------------------------------- | ||
3 | def bar[T]: Unit = foo[T & Any] // error | ||
| ^ | ||
| Type argument T & Any does not conform to lower bound Any | ||
|--------------------------------------------------------------------------------------------------------------------- | ||
| Explanation (enabled by `-explain`) | ||
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
| I tried to show that | ||
| Any | ||
| conforms to | ||
| T & Any | ||
| but the comparison trace ended with `false`: | ||
| | ||
| ==> Any <: T & Any | ||
| ==> Any <: T | ||
| <== Any <: T = false | ||
| <== Any <: T & Any = false | ||
| | ||
| The tests were made under the empty constraint | ||
--------------------------------------------------------------------------------------------------------------------- | ||
-- [E057] Type Mismatch Error: tests/neg-custom-args/i15575.scala:7:14 ------------------------------------------------- | ||
7 | val _ = foo[String] // error | ||
| ^ | ||
| Type argument String does not conform to lower bound CharSequence | ||
|--------------------------------------------------------------------------------------------------------------------- | ||
| Explanation (enabled by `-explain`) | ||
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
| I tried to show that | ||
| CharSequence | ||
| conforms to | ||
| String | ||
| but the comparison trace ended with `false`: | ||
| | ||
| ==> CharSequence <: String | ||
| ==> CharSequence <: String | ||
| <== CharSequence <: String = false | ||
| <== CharSequence <: String = false | ||
| | ||
| The tests were made under the empty constraint | ||
--------------------------------------------------------------------------------------------------------------------- |
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,7 @@ | ||
object Test1: | ||
def foo[T >: Any]: Unit = () | ||
def bar[T]: Unit = foo[T & Any] // error | ||
|
||
object Test2: | ||
def foo[T >: CharSequence]: Unit = () | ||
val _ = foo[String] // error |
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,4 +1,4 @@ | ||
-- Error: tests/neg/i15568.scala:3:15 ---------------------------------------------------------------------------------- | ||
-- [E057] Type Mismatch Error: tests/neg/i15568.scala:3:15 ------------------------------------------------------------- | ||
3 |type Bar = Foo[? >: Int <: String] // error | ||
| ^ | ||
| type argument has potentially unrealizable bounds >: Int <: String | ||
| Type argument >: Int <: String does not overlap with upper bound String |
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
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,11 +1,7 @@ | ||
package i5854 | ||
|
||
class B/*<-i5854::B#*/ { | ||
// Known issue: Can't lookup the symbol of `b.A` | ||
// we have to register the symbol of `b { type A }` to the refinementSymtab first | ||
// then resolve, or assign same semanticdb symbol for both | ||
// fake symbol for b.A, and real symbol of A in b | ||
val a/*<-i5854::B#a.*/: String/*->scala::Predef.String#*/ = (((1: Any/*->scala::Any#*/): b/*->i5854::B#b.*/.A): Nothing/*->scala::Nothing#*/): String/*->scala::Predef.String#*/ | ||
val b/*<-i5854::B#b.*/: { type A/*<-local0*/ >: Any/*->scala::Any#*/ <: Nothing/*->scala::Nothing#*/ } = loop/*->i5854::B#loop().*/() // error | ||
val b/*<-i5854::B#b.*/: { type A/*<-local0*/ >: Any/*->scala::Any#*/ <: Nothing/*->scala::Nothing#*/ } = loop/*->i5854::B#loop().*/() // error | ||
def loop/*<-i5854::B#loop().*/(): Nothing/*->scala::Nothing#*/ = loop/*->i5854::B#loop().*/() | ||
} |
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,11 +1,7 @@ | ||
package i5854 | ||
|
||
class B { | ||
// Known issue: Can't lookup the symbol of `b.A` | ||
// we have to register the symbol of `b { type A }` to the refinementSymtab first | ||
// then resolve, or assign same semanticdb symbol for both | ||
// fake symbol for b.A, and real symbol of A in b | ||
dwijnand marked this conversation as resolved.
Show resolved
Hide resolved
|
||
val a: String = (((1: Any): b.A): Nothing): String | ||
val b: { type A >: Any <: Nothing } = loop() // error | ||
val b: { type A >: Any <: Nothing } = loop() // error | ||
def loop(): Nothing = loop() | ||
} |
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
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.