RFR: 8263590: Rawtypes warnings should be produced for pattern matching in instanceof

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

RFR: 8263590: Rawtypes warnings should be produced for pattern matching in instanceof

Jan Lahoda-3
For code like:
Object o = null;
boolean b = o instanceof List l;

There should be a raw-type warning for `List`, as we are effectively declaring a variable with a raw type.

Code like:
Object o = null;
boolean b = o instanceof List;

Will not produce a warning (as it doesn't so far), as the (raw) type is not used in a problematic context.

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

Commit messages:
 - 8263589: Rawtypes warnings should be produced for pattern matching in instanceof

Changes: https://git.openjdk.java.net/jdk/pull/3016/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=3016&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8263590
  Stats: 17 lines in 3 files changed: 16 ins; 0 del; 1 mod
  Patch: https://git.openjdk.java.net/jdk/pull/3016.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/3016/head:pull/3016

PR: https://git.openjdk.java.net/jdk/pull/3016
Reply | Threaded
Open this post in threaded view
|

Re: RFR: 8263590: Rawtypes warnings should be produced for pattern matching in instanceof

Maurizio Cimadamore-2
On Mon, 15 Mar 2021 17:59:33 GMT, Jan Lahoda <[hidden email]> wrote:

> For code like:
> Object o = null;
> boolean b = o instanceof List l;
>
> There should be a raw-type warning for `List`, as we are effectively declaring a variable with a raw type.
>
> Code like:
> Object o = null;
> boolean b = o instanceof List;
>
> Will not produce a warning (as it doesn't so far), as the (raw) type is not used in a problematic context.

Looks good!

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

Marked as reviewed by mcimadamore (Reviewer).

PR: https://git.openjdk.java.net/jdk/pull/3016
Reply | Threaded
Open this post in threaded view
|

Integrated: 8263590: Rawtypes warnings should be produced for pattern matching in instanceof

Jan Lahoda-3
In reply to this post by Jan Lahoda-3
On Mon, 15 Mar 2021 17:59:33 GMT, Jan Lahoda <[hidden email]> wrote:

> For code like:
> Object o = null;
> boolean b = o instanceof List l;
>
> There should be a raw-type warning for `List`, as we are effectively declaring a variable with a raw type.
>
> Code like:
> Object o = null;
> boolean b = o instanceof List;
>
> Will not produce a warning (as it doesn't so far), as the (raw) type is not used in a problematic context.

This pull request has now been integrated.

Changeset: 9cd21b68
Author:    Jan Lahoda <[hidden email]>
URL:       https://git.openjdk.java.net/jdk/commit/9cd21b68
Stats:     17 lines in 3 files changed: 16 ins; 0 del; 1 mod

8263590: Rawtypes warnings should be produced for pattern matching in instanceof

Reviewed-by: mcimadamore

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

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