RFR: 8265900: Use pattern matching for instanceof at module jdk.compiler(part 2)
Brian Goetz
brian.goetz at oracle.com
Mon Apr 26 14:04:25 UTC 2021
Also, FYI: we had a discussion over a similar topic over on corelibs,
and settled on making the binding variable names a little less "fussy",
especially in patterns like Object::equals (calling it `that` or `other`
is fine; we don't have to call it `standardFinalManager`.) These are
convenience variables with small scopes; they don't need super-specific
names (and the super-specific names often make the code harder to
read.) You don't have to go and change them, just keep this in mind for
next time.
On 4/26/2021 9:55 AM, Maurizio Cimadamore wrote:
> On Sun, 25 Apr 2021 09:20:49 GMT, Guoxiong Li <gli at openjdk.org> wrote:
>
>> Hi all,
>>
>> This series of patches update the code of the module jdk.compiler by using the pattern matching for instanceof.
>>
>> This patch would revise the following packages:
>>
>> com.sun.tools.javac.code
>> com.sun.tools.javac.comp
>> com.sun.tools.javac.jvm
>> com.sun.tools.javac.parser
>> com.sun.tools.javac.processing
>>
>>
>> Thank you for taking the time to review.
>>
>> --
>> Best Regards,
>> Guoxiong.
> Looks good, one minor nit comment
>
> src/jdk.compiler/share/classes/com/sun/tools/javac/code/Scope.java line 756:
>
>> 754:
>> 755: protected Scope finalizeSingleScope(Scope impScope) {
>> 756: if (impScope instanceof FilterImportScope filterImportScope && impScope.owner.kind == Kind.TYP &&
> break vertically on each `&&` ?
>
> src/jdk.compiler/share/classes/com/sun/tools/javac/comp/ArgumentAttr.java line 754:
>
>> 752: @Override
>> 753: public boolean equals(Object obj) {
>> 754: return (obj instanceof UniquePos uniquePos)
> For another day - UniquePos can be a record :-)
>
> src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/PoolConstant.java line 190:
>
>> 188: @Override
>> 189: public boolean equals(Object obj) {
>> 190: return (obj instanceof BsmKey key)
> BsmKey smells of records too...
>
> -------------
>
> Marked as reviewed by mcimadamore (Reviewer).
>
> PR: https://git.openjdk.java.net/jdk/pull/3674
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20210426/a7516187/attachment.htm>
More information about the compiler-dev
mailing list