Ref<PyType> (@Nullable PyType initial, @Nullable PyType suggested, boolean positive, boolean transformToDefinition, @NotNull TypeEvalContext context, @Nullable PyExpression typeElement) { final PyType transformedType = transformTypeFromAssertion(suggested, transformToDefinition, context, typeElement); if (positive) { if (!(initial instanceof PyUnionType) && !(initial instanceof PyStructuralType) && !PyTypeChecker.isUnknown(initial, context) && PyTypeChecker.match(transformedType, initial, context)) { return Ref.create(initial); } return Ref.create(transformedType); } else if (initial instanceof PyUnionType) { return Ref.create(((PyUnionType)initial).exclude(transformedType, context)); } else if (!(initial instanceof PyStructuralType) && !PyTypeChecker.isUnknown(initial, context) && PyTypeChecker.match(transformedType, initial, context)) { return null; } return Ref.create(initial); }