-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Migration rewrites for infix arguments interpreted as named tuples #21949
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
WojciechMazur
merged 6 commits into
scala:main
from
WojciechMazur:rewrite/infix-named-args
Nov 18, 2024
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8cc355c
Deprecate infix named args
som-snytt 9881324
Make message more obvious in the myopic case
som-snytt ad3f38d
Fix named arg deprecation
som-snytt f085145
Implement automatic rewrites for named infix arguments interpreted as…
WojciechMazur e99aeee
Ensure to use no colors printer when preparing rewrites
WojciechMazur 65ef960
Apply review suggstion
WojciechMazur 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
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
-- [E134] Type Error: tests/neg/infix-named-args.scala:2:13 ------------------------------------------------------------ | ||
2 | def f = 42 + (x = 1) // error // werror | ||
| ^^^^ | ||
| None of the overloaded alternatives of method + in class Int with types | ||
| (x: Double): Double | ||
| (x: Float): Float | ||
| (x: Long): Long | ||
| (x: Int): Int | ||
| (x: Char): Int | ||
| (x: Short): Int | ||
| (x: Byte): Int | ||
| (x: String): String | ||
| match arguments ((x : Int)) (a named tuple) | ||
-- [E204] Syntax Warning: tests/neg/infix-named-args.scala:2:15 -------------------------------------------------------- | ||
2 | def f = 42 + (x = 1) // error // werror | ||
| ^^^^^^^ | ||
|Ambigious syntax: this infix call argument list is interpreted as single named tuple argument, not as an named arguments list. | ||
|This can be rewritten automatically under -rewrite -source 3.6-migration. | ||
| | ||
| longer explanation available when compiling with `-explain` | ||
-- [E204] Syntax Warning: tests/neg/infix-named-args.scala:5:26 -------------------------------------------------------- | ||
5 | def g = new C() `multi` (x = 42, y = 27) // werror | ||
| ^^^^^^^^^^^^^^^^ | ||
|Ambigious syntax: this infix call argument list is interpreted as single named tuple argument, not as an named arguments list. | ||
|This can be rewritten automatically under -rewrite -source 3.6-migration. | ||
| | ||
| longer explanation available when compiling with `-explain` | ||
-- [E204] Syntax Warning: tests/neg/infix-named-args.scala:6:21 -------------------------------------------------------- | ||
6 | def h = new C() ** (x = 42, y = 27) // werror | ||
| ^^^^^^^^^^^^^^^^ | ||
|Ambigious syntax: this infix call argument list is interpreted as single named tuple argument, not as an named arguments list. | ||
|This can be rewritten automatically under -rewrite -source 3.6-migration. | ||
| | ||
| longer explanation available when compiling with `-explain` | ||
-- [E204] Syntax Warning: tests/neg/infix-named-args.scala:13:18 ------------------------------------------------------- | ||
13 | def f = this ** (x = 2) // werror | ||
| ^^^^^^^ | ||
|Ambigious syntax: this infix call argument list is interpreted as single named tuple argument, not as an named arguments list. | ||
|This can be rewritten automatically under -rewrite -source 3.6-migration. | ||
| | ||
| longer explanation available when compiling with `-explain` |
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,14 @@ | ||
class C: | ||
def f = 42 + (x = 1) // error // werror | ||
def multi(x: Int, y: Int): Int = x + y | ||
def **(x: Int, y: Int): Int = x + y | ||
def g = new C() `multi` (x = 42, y = 27) // werror | ||
def h = new C() ** (x = 42, y = 27) // werror | ||
|
||
type X = (x: Int) | ||
|
||
class D(d: Int): | ||
def **(x: Int): Int = d * x | ||
def **(x: X): Int = d * x.x | ||
def f = this ** (x = 2) // werror | ||
def g = this ** 2 |
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,15 @@ | ||
class C: | ||
def multi(x: Int, y: Int): Int = x + y | ||
def **(x: Int, y: Int): Int = x + y | ||
def g = new C().multi(x = 42, y = 27) | ||
def h = new C().**(x = 42, y = 27) | ||
|
||
type X = (x: Int) | ||
|
||
class D(d: Int): | ||
def **(x: Int): Int = d * x | ||
def **(x: X): Int = d * x.x | ||
def f = this.**(x = 2) | ||
def g = this ** 2 | ||
def h = this ** ((x = 2)) | ||
def i = this.**(x = (1 + 1)) |
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,15 @@ | ||
class C: | ||
def multi(x: Int, y: Int): Int = x + y | ||
def **(x: Int, y: Int): Int = x + y | ||
def g = new C() `multi` (x = 42, y = 27) | ||
def h = new C() ** (x = 42, y = 27) | ||
|
||
type X = (x: Int) | ||
|
||
class D(d: Int): | ||
def **(x: Int): Int = d * x | ||
def **(x: X): Int = d * x.x | ||
def f = this ** (x = 2) | ||
def g = this ** 2 | ||
def h = this ** ((x = 2)) | ||
def i = this ** (x = (1 + 1)) |
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,14 @@ | ||
//> using options -source:3.6-migration | ||
class C: | ||
def f = 42 + (x = 1) // warn // interpreted as 42.+(x = 1) under migration, x is a valid synthetic parameter name | ||
def multi(x: Int, y: Int): Int = x + y | ||
def **(x: Int, y: Int): Int = x + y | ||
def g = new C() `multi` (x = 42, y = 27) // warn | ||
def h = new C() ** (x = 42, y = 27) // warn | ||
|
||
type X = (x: Int) | ||
|
||
class D(d: Int): | ||
def **(x: Int): Int = d * x | ||
def f = this ** (x = 2) // warn | ||
def g = this ** 2 |
Oops, something went wrong.
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.