Skip to content

Fix type inferencing for logical-or instanceof and switch types #1649

@eric-milles

Description

@eric-milles

Consider the following:

void test(Object o) {
  if (o instanceof Number || o instanceof String) {
    o // typeof(o) is (Number | String)
  }
}

If a non-instanceof clause is found, the type may also be the original expression type.

void test(Object o) {
  if (o instanceof Number || something) {
    o // typeof(o) is (Number | Object)
  }
}

A similar situation exists for catch and switch.

Image

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions