File tree Expand file tree Collapse file tree 2 files changed +65
-0
lines changed
core/src/test/java/com/google/errorprone/bugpatterns/threadsafety Expand file tree Collapse file tree 2 files changed +65
-0
lines changed Original file line number Diff line number Diff line change @@ -4213,4 +4213,35 @@ record R(ImmutableList<String> xs) {}
42134213 """ )
42144214 .doTest ();
42154215 }
4216+
4217+ @ Test
4218+ public void subtyping () {
4219+ compilationHelper
4220+ .addSourceLines (
4221+ "Test.java" ,
4222+ """
4223+ import com.google.errorprone.annotations.Immutable;
4224+
4225+ @Immutable
4226+ interface ImmutableInterface {}
4227+
4228+ @Immutable
4229+ abstract class ImmutableAbstractClass {}
4230+
4231+ class B implements ImmutableInterface {}
4232+
4233+ class D extends ImmutableAbstractClass {}
4234+
4235+ class F implements ImmutableInterface {
4236+ // BUG: Diagnostic contains: has non-final field
4237+ Object unsafe;
4238+ }
4239+
4240+ class H extends ImmutableAbstractClass {
4241+ // BUG: Diagnostic contains: has non-final field
4242+ Object unsafe;
4243+ }
4244+ """ )
4245+ .doTest ();
4246+ }
42164247}
Original file line number Diff line number Diff line change @@ -1602,4 +1602,38 @@ class Test {
16021602 """ )
16031603 .doTest ();
16041604 }
1605+
1606+ @ Test
1607+ public void subtyping () {
1608+ compilationHelper
1609+ .addSourceLines (
1610+ "Test.java" ,
1611+ """
1612+ package a;
1613+
1614+ import com.google.errorprone.annotations.ThreadSafe;
1615+
1616+ @ThreadSafe
1617+ interface ThreadSafeInterface {}
1618+
1619+ @ThreadSafe
1620+ abstract class ThreadSafeAbstractClass {}
1621+
1622+ // BUG: Diagnostic contains: is not annotated
1623+ class A implements ThreadSafeInterface {}
1624+
1625+ class C extends ThreadSafeAbstractClass {}
1626+
1627+ // BUG: Diagnostic contains: is not annotated
1628+ class E implements ThreadSafeInterface {
1629+ Object unsafe;
1630+ }
1631+
1632+ class G extends ThreadSafeAbstractClass {
1633+ // BUG: Diagnostic contains: fields should be final or annotated with @GuardedBy
1634+ Object unsafe;
1635+ }
1636+ """ )
1637+ .doTest ();
1638+ }
16051639}
You can’t perform that action at this time.
0 commit comments