Optional<Boolean> (@NotNull PyTupleType expected, @NotNull PyTupleType actual, @NotNull MatchContext context) { // TODO Delegate to UnpackedTupleType here, once it's introduced if (!expected.isHomogeneous() && !actual.isHomogeneous()) { return Optional.of(matchTypeParameters(expected.getElementTypes(), actual.getElementTypes(), context)); } if (expected.isHomogeneous() && !actual.isHomogeneous()) { final PyType expectedElementType = expected.getIteratedItemType(); for (int i = 0; i < actual.getElementCount(); i++) { if (!match(expectedElementType, actual.getElementType(i), context).orElse(true)) { return Optional.of(false); } } return Optional.of(true); } if (!expected.isHomogeneous() && actual.isHomogeneous()) { return Optional.of(false); } return match(expected.getIteratedItemType(), actual.getIteratedItemType(), context); }