[AL] Take API_AVAILABLE into account in the Unavailable_Api check

Reviewed By: ngorogiannis

Differential Revision: D17788412

fbshipit-source-id: ef6fd2e1b
master
Dulma Churchill 5 years ago committed by Facebook Github Bot
parent e3f0ba8c54
commit 6cfbd38355

@ -1145,20 +1145,24 @@ let iphoneos_target_sdk_version_greater_or_equal (cxt : CLintersContext.context)
let decl_unavailable_in_supported_ios_sdk (cxt : CLintersContext.context) an =
let config_iphoneos_target_sdk_version = iphoneos_target_sdk_version_by_path cxt in
let available_attr_ios_sdk_current_method =
match cxt.current_method with
| Some decl ->
get_available_attr_ios_sdk (Decl decl)
| None ->
None
in
let ios_version_guard =
match cxt.if_context with Some if_context -> if_context.ios_version_guard | None -> []
in
let allowed_os_versions =
match
(config_iphoneos_target_sdk_version, (cxt.if_context : CLintersContext.if_context option))
with
| Some iphoneos_target_sdk_version, Some if_context ->
iphoneos_target_sdk_version :: if_context.ios_version_guard
| Some iphoneos_target_sdk_version, None ->
[iphoneos_target_sdk_version]
| _ ->
[]
Option.to_list config_iphoneos_target_sdk_version
@ ios_version_guard
@ Option.to_list available_attr_ios_sdk_current_method
in
let max_allowed_version_opt = List.max_elt allowed_os_versions ~compare:Utils.compare_versions in
let max_allowed_version = List.max_elt allowed_os_versions ~compare:Utils.compare_versions in
let available_attr_ios_sdk = get_available_attr_ios_sdk an in
match (available_attr_ios_sdk, max_allowed_version_opt) with
match (available_attr_ios_sdk, max_allowed_version) with
| Some available_attr_ios_sdk, Some max_allowed_version ->
Utils.compare_versions available_attr_ios_sdk max_allowed_version > 0
| _ ->

@ -1,8 +1,8 @@
codetoanalyze/objc/ioslints/unavailable_api_allowed_cases.m, Unavailable_api_allowed_cases::m2, 136, UNAVAILABLE_API_IN_SUPPORTED_IOS_SDK, no_bucket, ERROR, []
codetoanalyze/objc/ioslints/unavailable_api_allowed_cases.m, Unavailable_api_allowed_cases::m3, 144, UNAVAILABLE_API_IN_SUPPORTED_IOS_SDK, no_bucket, ERROR, []
codetoanalyze/objc/ioslints/unavailable_api_allowed_cases.m, Unavailable_api_allowed_cases::uifont_without_respondstoselector, 119, UNAVAILABLE_API_IN_SUPPORTED_IOS_SDK, no_bucket, ERROR, []
codetoanalyze/objc/ioslints/unavailable_api_allowed_cases.m, Unavailable_api_allowed_cases::with_responds_to_selector_in_else, 72, UNAVAILABLE_API_IN_SUPPORTED_IOS_SDK, no_bucket, ERROR, []
codetoanalyze/objc/ioslints/unavailable_api_allowed_cases.m, Unavailable_api_allowed_cases::without_instances_responds_to_selector, 96, UNAVAILABLE_API_IN_SUPPORTED_IOS_SDK, no_bucket, ERROR, []
codetoanalyze/objc/ioslints/unavailable_api_allowed_cases.m, Unavailable_api_allowed_cases::m2, 144, UNAVAILABLE_API_IN_SUPPORTED_IOS_SDK, no_bucket, ERROR, []
codetoanalyze/objc/ioslints/unavailable_api_allowed_cases.m, Unavailable_api_allowed_cases::m3, 152, UNAVAILABLE_API_IN_SUPPORTED_IOS_SDK, no_bucket, ERROR, []
codetoanalyze/objc/ioslints/unavailable_api_allowed_cases.m, Unavailable_api_allowed_cases::uifont_without_respondstoselector, 127, UNAVAILABLE_API_IN_SUPPORTED_IOS_SDK, no_bucket, ERROR, []
codetoanalyze/objc/ioslints/unavailable_api_allowed_cases.m, Unavailable_api_allowed_cases::with_responds_to_selector_in_else, 80, UNAVAILABLE_API_IN_SUPPORTED_IOS_SDK, no_bucket, ERROR, []
codetoanalyze/objc/ioslints/unavailable_api_allowed_cases.m, Unavailable_api_allowed_cases::without_instances_responds_to_selector, 104, UNAVAILABLE_API_IN_SUPPORTED_IOS_SDK, no_bucket, ERROR, []
codetoanalyze/objc/ioslints/unavailable_api_allowed_cases.m, Unavailable_api_allowed_cases::without_responds_to_selector, 65, UNAVAILABLE_API_IN_SUPPORTED_IOS_SDK, no_bucket, ERROR, []
codetoanalyze/objc/ioslints/unavailable_api_in_supported_ios_sdk.m, OpenURLOptionsFromSourceApplication, 69, UNAVAILABLE_API_IN_SUPPORTED_IOS_SDK, no_bucket, ERROR, []
codetoanalyze/objc/ioslints/unavailable_api_in_supported_ios_sdk.m, Unavailable_api_in_supported_ios_sdk::unsupported_class, 35, UNAVAILABLE_CLASS_IN_SUPPORTED_IOS_SDK, no_bucket, ERROR, []

@ -65,6 +65,14 @@
[a m];
}
// no bug
- (void)call_m:(Unavailable_api_allowed_cases*)a
API_AVAILABLE(ios(10), macosx(10.13)) {
int x = 1;
[a m];
x = 3;
}
// bug
- (void)with_responds_to_selector_in_else:(Unavailable_api_allowed_cases*)a {
if ([a respondsToSelector:@selector(m)]) {

Loading…
Cancel
Save