-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix #2772: Special case Devalify for java.lang.System.* #2781
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
Changes from 4 commits
be8bcee
f4c19d9
faa8864
cd035b2
f824164
cf54051
09d4a8c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -146,4 +146,15 @@ object Simplify { | |
case _ => None | ||
} | ||
} | ||
|
||
// System.in is static final fields that, for legacy reasons, must be | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is -> is a This description is a bit confusing: it starts by talking just about System.in and then mention the rest. |
||
// allowed to be changed by the methods System.setIn. `isMutable` is true | ||
// is the field is Mutable or if it's a field of java.lang.System. | ||
// https://docs.oracle.com/javase/specs/jls/se8/html/jls-17.html#jls-17.5.4 | ||
def isMutable(t: Tree)(implicit ctx: Context): Boolean = t match { | ||
case _ if t.symbol.is(Mutable) => true | ||
case s: Symbol => (s.symbol == defn.SystemModule) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you want s.owner.symbol here. |
||
case i: Ident => desugarIdent(i).exists(isMutable) | ||
case _ => false | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import java.io.OutputStream | ||
|
||
object Test { | ||
def main(args: Array[String]): Unit = { | ||
val oldErr = System.err | ||
System.setErr(null) // setOut(null) confuses the testing framework... | ||
val a = () => foo(oldErr) | ||
a() | ||
} | ||
|
||
def foo(err: OutputStream): Unit = { | ||
err.write(0) | ||
} | ||
} |
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.
Of An ImmutableField