boolean (@NotNull PyType expected, @NotNull PyUnionType actual, @NotNull MatchContext context) { if (expected instanceof PyTupleType expectedTupleType) { // XXX A type-widening hack for cases like PyTypeTest.testDictFromTuple Optional<Boolean> match = match(expectedTupleType, actual, context); if (match.isPresent()) { return match.get(); } } // checking strictly separately until PY-24834 gets implemented if (ContainerUtil.exists(actual.getMembers(), x -> x instanceof PyLiteralStringType || x instanceof PyLiteralType)) { return ContainerUtil.and(actual.getMembers(), type -> match(expected, type, context).orElse(false)); } return ContainerUtil.or(actual.getMembers(), type -> match(expected, type, context).orElse(false)); }