RFR: 8302344: Compiler Implementation for Unnamed patterns and variables (Preview) [v16]

Aggelos Biboudis abimpoudis at openjdk.org
Thu May 18 16:57:06 UTC 2023


On Mon, 8 May 2023 12:12:11 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> BTW we can remove the `isUnnamed` from `VarSymbol` as @jddarcy pointed me out correctly. 
>> 
>> By keeping it we avoid sprinkling 5 core places with `@SuppressWarnings("preview")`. However, I think it will be cleaner without that override, despite the annotation and I would be in favor of that. Are there any concerns? e.g.,
>> 
>> 
>> diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java
>> index 631b0ce61ac..dc84c89f88e 100644
>> --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java
>> +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java
>> @@ -1784,11 +1784,6 @@ public abstract class Symbol extends AnnoConstruct implements PoolConstant, Elem
>>          public <R, P> R accept(Symbol.Visitor<R, P> v, P p) {
>>              return v.visitVarSymbol(this, p);
>>          }
>> -
>> -        @DefinedBy(Api.LANGUAGE_MODEL)
>> -        public boolean isUnnamed() {
>> -            return name.isEmpty();
>> -        }
>>      }
>>  
>>      public static class RecordComponent extends VarSymbol implements RecordComponentElement {
>> diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java
>> index 986f2e9fe89..26ef1c41156 100644
>> --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java
>> +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java
>> @@ -93,6 +93,7 @@ import com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag;
>>   *  This code and its internal interfaces are subject to change or
>>   *  deletion without notice.</b>
>>   */
>> + at SuppressWarnings("preview")
>>  public class Attr extends JCTree.Visitor {
>>      protected static final Context.Key<Attr> attrKey = new Context.Key<>();
>>  
>> diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java
>> index 725a8a5e37d..537635a9490 100644
>> --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java
>> +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java
>> @@ -93,6 +93,7 @@ import javax.lang.model.util.ElementKindVisitor14;
>>   *  This code and its internal interfaces are subject to change or
>>   *  deletion without notice.</b>
>>   */
>> + at SuppressWarnings("preview")
>>  public class Check {
>>      protected static final Context.Key<Check> checkKey = new Conte...
>
>> BTW we can remove the `isUnnamed` from `VarSymbol` as @jddarcy pointed me out correctly.
>> 
>> By keeping it we avoid sprinkling 5 core places with `@SuppressWarnings("preview")`. However, I think it will be cleaner without that override, despite the annotation and I would be in favor of that. Are there any concerns? e.g.,
>> 
>> ```
>> diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java
>> index 631b0ce61ac..dc84c89f88e 100644
>> --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java
>> +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java
>> @@ -1784,11 +1784,6 @@ public abstract class Symbol extends AnnoConstruct implements PoolConstant, Elem
>>          public <R, P> R accept(Symbol.Visitor<R, P> v, P p) {
>>              return v.visitVarSymbol(this, p);
>>          }
>> -
>> -        @DefinedBy(Api.LANGUAGE_MODEL)
>> -        public boolean isUnnamed() {
>> -            return name.isEmpty();
>> -        }
>>      }
>>  
>>      public static class RecordComponent extends VarSymbol implements RecordComponentElement {
>> diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java
>> index 986f2e9fe89..26ef1c41156 100644
>> --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java
>> +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java
>> @@ -93,6 +93,7 @@ import com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag;
>>   *  This code and its internal interfaces are subject to change or
>>   *  deletion without notice.</b>
>>   */
>> + at SuppressWarnings("preview")
>>  public class Attr extends JCTree.Visitor {
>>      protected static final Context.Key<Attr> attrKey = new Context.Key<>();
>>  
>> diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java
>> index 725a8a5e37d..537635a9490 100644
>> --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java
>> +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java
>> @@ -93,6 +93,7 @@ import javax.lang.model.util.ElementKindVisitor14;
>>   *  This code and its internal interfaces are subject to change or
>>   *  deletion without notice.</b>
>>   */
>> + at SuppressWarnings("preview")
>>  public class Check {
>>      protected static ...

Thank you for the review @mcimadamore. 

I have also improved error reporting a bit; in the case `_` is present.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/13528#issuecomment-1553341008


More information about the compiler-dev mailing list