Skip to content

InstanceOfPatternMatch removes try-with-resource variable #4173

@delanym

Description

@delanym

Given the code

   if (object instanceof JarArtifact) {
      try (JarArtifact a = (JarArtifact) object) {

a rewrite using InstanceOfPatternMatch results in

    if (object instanceof JarArtifact a) {
      try () {

A fix could be to simply remove the parenthesis

    if (object instanceof JarArtifact a) {
      try {

but that may leave the object unclosed, so it should probably be left alone.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions