RFR: 8250625: Compiler implementation of Pattern Matching for instanceof (Final) [v2]

Jan Lahoda jlahoda at openjdk.java.net
Wed Oct 21 10:08:01 UTC 2020


On Wed, 21 Oct 2020 03:11:28 GMT, Vicente Romero <vromero at openjdk.org> wrote:

>> Jan Lahoda has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains 15 additional commits since the last revision:
>> 
>>  - Cleanup: using a null instead of List.of() as a parameter to JavaCompiler.getTask
>>  - Merge branch 'master' into patterns-instanceof3
>>  - Fixing more tests.
>>  - Correcting positions.
>>  - Improve the AST model.
>>  - Merge branch 'master' into patterns-instanceof3
>>  - Updating @since tags.
>>  - Merge branch 'master' into patterns-instanceof3
>>  - Cleaning up preview comments in javadoc.
>>  - Merge branch 'master' into patterns-instanceof3
>>  - ... and 5 more: https://git.openjdk.java.net/jdk/compare/0290d7bd...5978bca0
>
> src/jdk.compiler/share/classes/com/sun/source/tree/PatternTree.java line 34:
> 
>> 32:  * @since 16
>> 33:  */
>> 34: public interface PatternTree extends Tree {}
> 
> I think that this interface is there for forward compatibility, and I don't like empty interfaces but I found that we already did that with com.sun.source.tree.DirectiveTree

We have multiple such interfaces - like StatementTree and ExpressionTree. It is a forward-looking interface, but I think necessary: InstanceofTree.getPattern() needs to return something, and having a PatternTree is (I think) better than returning generic Tree, or BindingPatternTree (the latter is likely to be insufficient sometime soon).

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

PR: https://git.openjdk.java.net/jdk/pull/559


More information about the core-libs-dev mailing list