Create a unit test describing an issue with `DisambiguateProperties` and templatized types.
@@ -2017,7 +2017,8 @@ public final class DisambiguatePropertiesTest extends CompilerTestCase {
"",
"function f(/** Bar */ i) { return i.x; }");
- String output = lines(
+ String output =
+ lines(
"/** @record */",
"function I(){}",
"/** @type {number} */",
@@ -2035,6 +2036,31 @@ public final class DisambiguatePropertiesTest extends CompilerTestCase {
testSets(js, output, "{x=[[Bar.prototype], [Foo.prototype, I.prototype]]}");
}
+ @Test
+ public void testStructuralTyping_typeConflationIsRecordedThroughTemplateTypes() {
+ testSets(
+ lines(
+ "/** @record */",
+ "class Record {",
+ " /** @return {string} */",
+ " bar() {}",
+ "}",
+ "",
+ "class Concrete {",
+ " /** @return {string} */",
+ " bar() { return ''; }",
+ "}",
+ "",
+ "/**",
+ " * @param {!Array<!Concrete>} concretes",
+ " * @return {!Array<!Record>}",
+ " */",
+ "function conflate(concretes) { return concretes; }"),
+ // TODO(b/124766232): The correct disambiguation sets would be:
+ // "{bar=[[Concrete.prototype, Record.prototype]]}"
+ "{bar=[[Concrete.prototype], [Record.prototype]]}");
+ }
+
/**
* Tests that the type based version skips renaming on types that have a mismatch, and the type
* tightened version continues to work as normal.
