Skip to content

Fix type inferencing for multiple method overloads (static and non-static) #646

@eric-milles

Description

@eric-milles

Consider the following:

class Unit {
}

class Utility {
  protected void assertType(String contents, String expected) {}

  protected void assertType(String contents, int exprStart, int exprEnd, String expected) {}

  public static void assertType(Unit contents, int exprStart, int exprEnd, String expected) {}

  protected void assertType(String contents, String expectedType, boolean forceWorkingCopy) {}

  protected void assertType(String contents, int exprStart, int exprEnd, String expectedType, boolean forceWorkingCopy) {}

  protected void assertType(String contents, int exprStart, int exprEnd, String expectedType, String extraDocSnippet, boolean forceWorkingCopy) {}

  public static void assertType(Unit contents, int exprStart, int exprEnd, String expectedType, boolean forceWorkingCopy) {}

  public static void assertType(Unit unit, int exprStart, int exprEnd, String expectedType, String extraDocSnippet, boolean forceWorkingCopy) {}
}

Unit unit = null; int offset = 0;
Utility.assertType(unit, offset, offset + 'types'.length(), 'java.util.Collection<E extends java.lang.Object>')

assertType is inferencing as unknown because the first non-static 4 parameter method is being selected. The type of offset + 'types'.length() is inferenced as Object by TypeInferencingVisitorWithRequestor.getMethodCallArgumentTypes.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions