Skip to content

Uncompilable casts to Object in generated tests #1641

Closed
@EgorkaKulikov

Description

@EgorkaKulikov

To Reproduce

Generate fuzzer tests for the following code:

 public int findTheLimit(Iterable<Integer> values) {
        int result = 0;
        for (var b : values) {
            result += b;
        }

        return result;
    }

Expected behavior

Test code can be compiled

Actual behavior

The following test code is generated

@Test
  @DisplayName("findTheLimit: values = collection -> return -1")
  public void testFindTheLimit1() {
      A a = new A();
      ArrayList values = new ArrayList();
      values.add(((Object) -1));

      int actual = a.findTheLimit(values);

      assertEquals(-1, actual);
  }

Additional context

This problem was introduced after another fix in ConstructorUtils.getAmbigiousOverloadsOf method (#1634)

Metadata

Metadata

Assignees

Labels

comp-codegenIssue is related to code generatorctg-bugIssue is a bug

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions