Skip to content

Pattern matching for instanceof #2388

Open
@blazek

Description

@blazek

How can I get "pattern matching for instanceof" working?

The issue #2345 states that "You can use post-Java11 features that are implemented by javac, like switch expressions, text blocks, and pattern matching for instanceof."

I have j2objc master compiled with jdk 17, running with Java 17, it silently converts pattern matching for instanceof but the variable to which it should be casted, is not declared in objc output. For example:

if ( o instanceof List l ) {
    l.clear();
}

is converted to (regardless -XDallVersions -source 17 options):

if ([o isKindOfClass:[JavaUtilArrayList class]]) {
    [l clear];
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions