-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Fix ignored type variable bound warning in type quote pattern #18199
Merged
nicolasstucki
merged 1 commit into
scala:main
from
dotty-staging:fix-ignored-type-quote-pattern-type-variable-bound-inference-warning
Jul 20, 2023
Merged
Changes from all commits
Commits
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 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
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,13 @@ | ||
-- Warning: tests/neg-macros/quote-type-variable-no-inference-2.scala:5:22 --------------------------------------------- | ||
5 | case '{ $_ : F[t, t]; () } => // warn // error | ||
| ^ | ||
| Ignored bound <: Double | ||
| | ||
| Consider defining bounds explicitly: | ||
| '{ type t <: Int & Double; ... } | ||
-- [E057] Type Mismatch Error: tests/neg-macros/quote-type-variable-no-inference-2.scala:5:12 -------------------------- | ||
5 | case '{ $_ : F[t, t]; () } => // warn // error | ||
| ^ | ||
| Type argument t does not conform to upper bound Double in inferred type F[t, t] | ||
| | ||
| longer explanation available when compiling with `-explain` |
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,8 @@ | ||
import scala.quoted.* | ||
|
||
def test2(x: Expr[Any])(using Quotes) = | ||
x match | ||
case '{ $_ : F[t, t]; () } => // warn // error | ||
case '{ type u <: Int & Double; $_ : F[u, u] } => | ||
|
||
type F[X <: Int, Y <: Double] |
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/neg-macros/quote-type-variable-no-inference-3.scala:5:22 --------------------------------------------- | ||
5 | case '{ $_ : F[t, t]; () } => // warn // error | ||
| ^ | ||
| Ignored bound <: Comparable[U] | ||
| | ||
| Consider defining bounds explicitly: | ||
| '{ type t <: Comparable[U]; ... } | ||
-- Warning: tests/neg-macros/quote-type-variable-no-inference-3.scala:6:49 --------------------------------------------- | ||
6 | case '{ type u <: Comparable[`u`]; $_ : F[u, u] } => | ||
| ^ | ||
| Ignored bound <: Comparable[Any] | ||
| | ||
| Consider defining bounds explicitly: | ||
| '{ type u <: Comparable[u] & Comparable[Any]; ... } | ||
-- [E057] Type Mismatch Error: tests/neg-macros/quote-type-variable-no-inference-3.scala:5:12 -------------------------- | ||
5 | case '{ $_ : F[t, t]; () } => // warn // error | ||
| ^ | ||
| Type argument t does not conform to upper bound Comparable[t] in inferred type F[t, t] | ||
| | ||
| longer explanation available when compiling with `-explain` |
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,8 @@ | ||
import scala.quoted.* | ||
|
||
def test2(x: Expr[Any])(using Quotes) = | ||
x match | ||
case '{ $_ : F[t, t]; () } => // warn // error | ||
case '{ type u <: Comparable[`u`]; $_ : F[u, u] } => | ||
|
||
type F[T, U <: Comparable[U]] |
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
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.
I wonder if we could take advantage of #17561 to automatically propose a rewrite that does that.
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.
I am considering doing that. The complication is finding the position where this needs to be inserted. It would be also be a bit more challenging if we consider handling two of these errors at the same time. I plan to try this in the near future.