From 82cb9059e14ae7f0cc8918f93dba525110fb5d39 Mon Sep 17 00:00:00 2001 From: Manu Sridharan Date: Sat, 17 Aug 2024 07:51:31 -0700 Subject: [PATCH] test case and fix --- .../CheckIdenticalNullabilityVisitor.java | 4 ++++ .../uber/nullaway/jspecify/GenericsTests.java | 21 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/nullaway/src/main/java/com/uber/nullaway/generics/CheckIdenticalNullabilityVisitor.java b/nullaway/src/main/java/com/uber/nullaway/generics/CheckIdenticalNullabilityVisitor.java index dda48e44ca..d89324266a 100644 --- a/nullaway/src/main/java/com/uber/nullaway/generics/CheckIdenticalNullabilityVisitor.java +++ b/nullaway/src/main/java/com/uber/nullaway/generics/CheckIdenticalNullabilityVisitor.java @@ -32,6 +32,10 @@ public Boolean visitClassType(Type.ClassType lhsType, Type rhsType) { if (rhsTypeAsSuper == null) { throw new RuntimeException("Did not find supertype of " + rhsType + " matching " + lhsType); } + // bail out of checking raw types for now + if (rhsTypeAsSuper.isRaw()) { + return true; + } List lhsTypeArguments = lhsType.getTypeArguments(); List rhsTypeArguments = rhsTypeAsSuper.getTypeArguments(); // This is impossible, considering the fact that standard Java subtyping succeeds before diff --git a/nullaway/src/test/java/com/uber/nullaway/jspecify/GenericsTests.java b/nullaway/src/test/java/com/uber/nullaway/jspecify/GenericsTests.java index 2a662b55a5..0396430e8e 100644 --- a/nullaway/src/test/java/com/uber/nullaway/jspecify/GenericsTests.java +++ b/nullaway/src/test/java/com/uber/nullaway/jspecify/GenericsTests.java @@ -1856,6 +1856,27 @@ public void issue1008() { .doTest(); } + @Test + public void issue1019() { + makeHelper() + .addSourceLines( + "Test.java", + "package com.uber;", + "", + "import java.util.ArrayList;", + "import java.util.List;", + "", + "public class Test {", + " public static class StringList extends ArrayList {", + " }", + " @SuppressWarnings(\"unchecked\")", + " public static List convert(final StringList stringList) {", + " return stringList;", + " }", + "}") + .doTest(); + } + private CompilationTestHelper makeHelper() { return makeTestHelperWithArgs( Arrays.asList(