Add more tests for forward referenced supertypes
@@ -2620,6 +2620,29 @@ public final class TypedScopeCreatorTest extends CompilerTestCase {
assertThat(fooProto.hasOwnProperty("constructor")).isFalse();
}
+ @Test
+ public void testClassDeclarationWithImplementsForwardRef() {
+ testSame(
+ lines(
+ "/** @implements {Bar} */", //
+ "class Foo {}",
+ "/** @interface */",
+ "class Bar {}",
+ "class SubFoo extends Foo {}"));
+
+ FunctionType fooCtorType = globalScope.getVar("Foo").getType().toMaybeFunctionType();
+ ObjectType fooType = fooCtorType.getInstanceType();
+
+ assertThat(fooCtorType.loosenTypecheckingDueToForwardReferencedSupertype()).isFalse();
+ assertThat(fooType.loosenTypecheckingDueToForwardReferencedSupertype()).isTrue();
+
+ FunctionType subFooCtorType = globalScope.getVar("SubFoo").getType().toMaybeFunctionType();
+ ObjectType subFooType = subFooCtorType.getInstanceType();
+
+ assertThat(subFooCtorType.loosenTypecheckingDueToForwardReferencedSupertype()).isTrue();
+ assertThat(subFooType.loosenTypecheckingDueToForwardReferencedSupertype()).isTrue();
+ }
+
@Test
public void testClassDeclarationWithExtends() {
testSame(
