-
Notifications
You must be signed in to change notification settings - Fork 1.1k
First steps towards rewriting from Scala2 in dotty #1154
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
Conversation
vdef1 | ||
} | ||
|
||
/** Add a @volitile to lazy vals when rewriting from Scala2 */ |
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.
Typo
Firs version of patching that can be invoked by dotty compiler itself.
Driver should not know that patch functionality exists. Instead, introduce settings that can introduce their own stateful values.
No more leaking ofMove PatchedFiles in a settings option. Move all patch classes into a `Rewrites` object.
Map typed to corresponding untyped trees.
Imports are missing afterwards.
Selectors should be defs, not lazy vals.
Some random neg tests from previous experiments.
Revert this commit once scala#1149 is fixed.
Scala2 allows `x _` even if `x` is not a method. Dotty disallows them. The patch removes the ` _` in these cases.
Test rewritings that were implemented so far.
Remove println; add docs
Gave overlapping positions in the case of longer lists of children.
`Iterator.sliding(2, 1)` returns a one-element result if the original iterator contains only one element, which makes it unpleasant to use for our task. Replaced by a fold.
A constructor def this() { ... } needs to be rewritten to def this() = { ... } not to def this(): Unit = { ... }
1. trailing `_`: `x _` is rewritten to `(() => x)` not to `x` 2. lazy vals: Rewrites are done in Typer, not LazyVals. Later on we are too much at risk to hit synthetically generated lazy vals.
Any objections to merge this one? |
I'll review it today. |
if (ctx.scala2Mode && sym.owner.isConstructor) | ||
ctx.migrationWarning(s"According to new variance rules, this is no longer accepted; need to annotate with @uncheckedVariance:\n$msg", sym.pos) | ||
if (ctx.scala2Mode && sym.owner.isConstructor) { | ||
ctx.migrationWarning(s"According to new variance rules, this is no longer accepted; need to annotate with @uncheckedVariance:\n$msg, pos = ${sym.pos}", sym.pos) |
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 don't think we need pos = ${sym.pos}
in the migration warning
* | ||
* Otherwise, in case there is exactly one variable x_1 in pattern | ||
* val/var p = e ==> val/var x_1 = (e: @unchecked) match (case p => (x_1)) | ||
* val/var/lazy val p = e ==> val/var x_1 = (e: @unchecked) match (case p => (x_1)) |
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.
val/var x_1
should be val/var/lazy val x_1
I think
Probably not worth fixing if it's complicated to deal with but note that: object Foo {
lazy val x, y = 1
} gets rewritten to: object Foo {
@volatile @volatile lazy val x, y = 1
} |
First steps towards rewriting from Scala2 in dotty
This is an attempt to do the rewriting right in the dotty compiler. The logic is, if dotty can detect
Scala2 incompatibilities it should be able to apply fixes at the same time. That way there is no error-prone syncing between different tools.
This PR
There is also a change the way annotations are propagated to derived symbols.
With this PR, stdlib can be patched and recompiled without -language:Scala2 (pending fix of
@volatile implicit issues).