-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix #4373: reject wildcard types in syntactically invalid positions #4422
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 all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
5b3d81b
Produce AndTypeTree and OrTypeTree directly in Parsers, not Desugar
Blaisorblade 9177c15
Refactor parser code that rejects forbidden wildcards
Blaisorblade 3183c50
Fix #4373: reject wildcard types in syntactically invalid positions
Blaisorblade 02a8f14
Avoid cascade type errors from error-correction-generated code
Blaisorblade f4ea23c
Add and fix missing testcases with `with`
Blaisorblade 95d0901
Handle by-name types better
Blaisorblade c17ed3e
Refactor, simplify and extend wildcard checking
Blaisorblade 3ddd88a
Reject by-name types as arguments of AndTypeTree and OrTypeTree
Blaisorblade 7f3a0cf
Add some testcases
Blaisorblade 35f09c4
Review feedback: findWildcardType -> findNonValueTypeTree
Blaisorblade 0804fde
Exhaustive testing of permutations with annotations
Blaisorblade 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
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
trait Base | ||
trait TypeConstr[X] | ||
|
||
class X1[A >: _ | X1[_]] // error | ||
class X2[A >: _ & X2[_]] // error | ||
class X3[A >: X3[_] | _] // error | ||
class X4[A >: X4[_] & _] // error | ||
class X5[A >: _ with X5[_]] // error | ||
class X6[A >: X6[_] with _] // error | ||
|
||
class A1 extends _ // error | ||
class A2 extends _ with _ // error // error | ||
class A3 extends Base with _ // error | ||
class A4 extends _ with Base // error | ||
|
||
object Test { | ||
type T1 = _ // error | ||
type T2 = _[Int] // error | ||
type T3 = _ { type S } // error | ||
type T4 = [X] => _ // error | ||
|
||
// Open questions: | ||
type T5 = TypeConstr[_ { type S }] // error | ||
type T6 = TypeConstr[_[Int]] // error | ||
|
||
// expression types | ||
type T7 = (=> Int) | (Int => Int) // error | ||
type T8 = (=> Int) & (Int => Int) // error | ||
type T9 = (=> Int) with (Int => Int) // error | ||
type T10 = (Int => Int) | (=> Int) // error | ||
type T11 = (Int => Int) & (=> Int) // error | ||
type T12 = (Int => Int) with (=> Int) // error | ||
|
||
// annotations | ||
type T13 = _ @ annotation.tailrec // error | ||
type T14 = Int @ _ // error | ||
type T15 = (_ | Int) @ annotation.tailrec // error | ||
type T16 = (Int | _) @ annotation.tailrec // error | ||
type T17 = Int @ (_ | annotation.tailrec) // error | ||
type T18 = Int @ (annotation.tailrec | _) // error | ||
|
||
type T19 = (_ with Int) @ annotation.tailrec // error | ||
type T20 = (Int with _) @ annotation.tailrec // error | ||
type T21 = Int @ (_ with annotation.tailrec) // error // error | ||
type T22 = Int @ (annotation.tailrec with _) // error // error | ||
|
||
type T23 = (_ & Int) @ annotation.tailrec // error | ||
type T24 = (Int & _) @ annotation.tailrec // error | ||
type T25 = Int @ (_ & annotation.tailrec) // error | ||
type T26 = Int @ (annotation.tailrec & _) // 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// ==> 040fb47fbaf718cecb11a7d51ac5a48bf4f6a1fe.scala <== | ||
object x0 { | ||
val x0 : _ with // error // error // 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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// ==> 05bef7805687ba94da37177f7568e3ba7da1f91c.scala <== | ||
class x0 { | ||
x1: // error | ||
x0 | _ // error // 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// ==> 18b253a4a89a84c5674165c6fc3efafad535eee3.scala <== | ||
object x0 { | ||
def x1[x2 <:_[ // error // error // error |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add some examples involving annotations too?
@_
,_ @x
, ...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!