-
Notifications
You must be signed in to change notification settings - Fork 3.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
Introduce -Xsource-features
, for customizing the behavior of -Xsource:3
and -Xsource:3-cross
#10709
Conversation
3d44731
to
c7a5c05
Compare
To be squashed after review. Nominally (whatever that weaselly word means), I checked usages of The |
associated doc change PR scala/docs.scala-lang#2994 |
Thank you for getting it rolling, I was going to pick it up this week. I'm forming somewhat strong opinions about providing multiple ways to do the same thing. It takes time for people to learn / look up what all those variants mean.
Compiler flags are not code, they are only touched once in a while and don't need to be as succinct as possible. The current proposal also doesn't really solve the auditing problem. If I'm using I'll give it a go today and push to this PR. |
Happy to have you progress this experiment to your liking. Here, you find out "what's new" by I think just having Here, |
@@ -1128,7 +1128,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper | |||
def adaptApplyInsertion(): Tree = doAdaptApplyInsertion(retry = false) | |||
|
|||
def doAdaptApplyInsertion(retry: Boolean): Tree = | |||
if (currentRun.isScala3Cross && !isPastTyper && tree.symbol != null && tree.symbol.isModule && tree.symbol.companion.isCase && isFunctionType(pt)) | |||
if (currentRun.isScala3X && !isPastTyper && tree.symbol != null && tree.symbol.isModule && tree.symbol.companion.isCase && isFunctionType(pt)) |
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 realize that apply insertion should be enabled by default, not even under -Xsource:3
.
For a library built with -Xsoruce:3-cross
, case class companions don't extend FunctionN
. This should not break List(1).map(A)
for users of the library that use the default compiler options.
@som-snytt wdyt?
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.
The library would use 3-compat
(or equivalent) to avoid incompatible changes.
The librarian, for the same reason, would not add object A
companion that has the same effect; or would be sorry if they did.
But you may be right that this should be considered a "benign" feature change that everyone could benefit from. Fork all the language features! It is of general utility. The downside is your 2.12 build breaks; but who does that? I guess only middle-size fish who consume smaller fish and are consumed in turn.
We might rename Also I could probably live with an alias |
111b007
to
4d5fed9
Compare
I squashed almost everything into one commit, only a few semantic changes as separate commits as good as possible. |
|`-Xsource:3-cross` is a shorthand for `-Xsource:3 -Xsource-features:_`. | ||
| | ||
|Available features: | ||
|""".stripMargin) |
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.
extra strip (it would be interesting if that failed to compile)
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.
👍 IntelliJ adds it when typing sm"""<return>
...
@@ -26,6 +27,7 @@ object Test extends DirectTest { | |||
""" | |||
def show() = { | |||
assert(!compile()) | |||
//assertEquals(expected.linesIterator.toList, Files.readAllLines(argfile).asScala.toList) |
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.
debug cruft. The expected
needs .trim
and assert could be
import scala.tools.testkit.AssertUtil.assertSameElements
assertSameElements(expected.linesIterator, Files.readAllLines(argfile).asScala)
The test is because -Vprint-args
was broken; the -Xsource
is not relevant.
I'll submit the tweak separately. :)
The buffet option makes it easier to see in the source where the features take effect. It also simplifies the warnings under the rule of "no warning if they asked for a feature". (I just remembered that the point of It took me two tries to correctly test moving the "case function" check from ident to adapt. Very nice! |
4d5fed9
to
bf8b650
Compare
LGTM. Lukas pulled that old github mind trick where he gets me to open the PR so that only he can approve it later. :) I partially edited the OP comment, which is probably still inaccurate. |
bf8b650
to
33559dd
Compare
fad7e0b
to
9c96b42
Compare
Your old trick of emitting the "how to suppress it" message would be helpful, especially when the category differs if not https://discord.com/channels/632150470000902164/632150470000902166/1217725189018615848 |
travis claims
|
Co-authored-by: A. P. Marki <som.snytt@gmail.com>
A dependency might be built with -Xsource-features:case-companion-function. Apply insertion should work for users that don't enable that flag. Co-authored-by: A. P. Marki <som.snytt@gmail.com>
Move the warning to adapt. This makes it work also for selections, not just idents. Co-authored-by: A. P. Marki <som.snytt@gmail.com>
Workaround for scala/bug 12968. Co-authored-by: A. P. Marki <som.snytt@gmail.com>
This allows enabling Scala 3 semantics for cross-building individually. Co-authored-by: A. P. Marki <som.snytt@gmail.com>
9c96b42
to
68bab66
Compare
semantic merge conflict with #10706, rebased.
Maybe somebody will eventually figure out how to do interactive verbose (not "re-run with ...").
|
-Xsource-features
for customizing the behavior of -Xsource:3
and -Xsource:3-cross
-Xsource-features
for customizing the behavior of -Xsource:3
and -Xsource:3-cross
-Xsource-features
, for customizing the behavior of -Xsource:3
and -Xsource:3-cross
I'm noticing in the community build that despite this change:
I'm still seeing errors like:
seems like an oversight that this advice wasn't updated? |
I never read those messages all the way to the end. Edit: until now. Tweak at #10718 |
a bit of good news: over in the community build, I removed
|
This feature is only recommended for projects that cross-build between Scala 2.13 and Scala 3. For migrating to Scala 3, use plain
-Xsource:3
. See also https://docs.scala-lang.org/scala3/guides/migration/tooling-scala2-xsource3.html.This PR makes Scala 3 language features opt-in under an option "buffet" or "à la carte". To view the menu:
-Xsource:3 -Xsource-features:_
(or-Xsource:3-cross
for convenience to start a REPL) offers all "courses" as "prix fixe". It's not recommended in a build script, usev2.13.14
instead to get migration warnings as new features are adopted.-Xmigration
is no longer "overloaded" to mean-Wconf:cat=scala3-migration:w
. That incantation must be written in full.Fixes scala/bug#12961