Skip to content

Commit 6d77b99

Browse files
committed
Don't complain about Objective-C method conflicts with unavailable requirements.
Specifically, method requirements that become unnecessary because they get superseded by the subscript they imply. Fixes rdar://problem/21420656. Swift SVN r30194
1 parent 497e990 commit 6d77b99

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1663,7 +1663,8 @@ void ConformanceChecker::recordOptionalWitness(ValueDecl *requirement) {
16631663

16641664
// If the requirement is @objc, note that we have an unsatisfied
16651665
// optional @objc requirement.
1666-
if (requirement->isObjC()) {
1666+
if (requirement->isObjC() &&
1667+
!requirement->getAttrs().isUnavailable(TC.Context)) {
16671668
// If we're not suppressing diagnostics, look for a non-@objc near
16681669
// match.
16691670
if (!SuppressDiagnostics)

test/ClangModules/Inputs/custom-modules/ObjCSubscripts.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,12 @@
2020
- (nullable NSString *)objectForKeyedSubscript:(nonnull NSArray *)subscript;
2121
- (void)setObject:(nullable NSString *)object forKeyedSubscript:(nonnull NSArray *)key;
2222
@end
23+
24+
@protocol KeySubscriptProto1
25+
- (nullable NSString *)objectForKeyedSubscript:(nonnull NSString *)subscript;
26+
@end
27+
28+
@protocol KeySubscriptProto2
29+
- (NSString *)objectForKeyedSubscript:(NSString *)subscript;
30+
- (void)setObject:(NSString *)object forKeyedSubscript:(NSString *)key;
31+
@end

test/ClangModules/objc_subscript.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,16 @@ class KeySubscript4Sub : KeySubscript4 {
4040
set { }
4141
}
4242
}
43+
44+
class ConformsToKeySubscriptProto1 : KeySubscriptProto1 {
45+
@objc subscript (s: String) -> String? {
46+
return s
47+
}
48+
}
49+
50+
class ConformsToKeySubscriptProto2 : KeySubscriptProto2 {
51+
@objc subscript (s: String!) -> String! {
52+
get { return s }
53+
set { }
54+
}
55+
}

0 commit comments

Comments
 (0)