Skip to content

Commit 6a51859

Browse files
committed
[Type checker] Minor cleanups for @objc inference from witnesses.
(cherry picked from commit 4820453)
1 parent 5169982 commit 6a51859

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4853,6 +4853,7 @@ TypeChecker::findWitnessedObjCRequirements(const ValueDecl *witness,
48534853
// We only care about Objective-C protocols.
48544854
if (!proto->isObjC()) continue;
48554855

4856+
Optional<ProtocolConformance *> conformance;
48564857
for (auto req : proto->lookupDirect(name, true)) {
48574858
// Skip anything in a protocol extension.
48584859
if (req->getDeclContext() != proto) continue;
@@ -4861,7 +4862,6 @@ TypeChecker::findWitnessedObjCRequirements(const ValueDecl *witness,
48614862
if (isa<TypeDecl>(req)) continue;
48624863

48634864
// Dig out the conformance.
4864-
Optional<ProtocolConformance *> conformance;
48654865
if (!conformance.hasValue()) {
48664866
SmallVector<ProtocolConformance *, 2> conformances;
48674867
nominal->lookupConformance(dc->getParentModule(), proto,

test/attr/attr_objc.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2147,20 +2147,18 @@ extension ClassInfersFromProtocol3 {
21472147
func method1(value: String) { }
21482148
}
21492149

2150+
// Inference for subclasses.
21502151
class SuperclassImplementsProtocol : InferFromProtocol { }
21512152

2152-
// Note: no inference for subclasses
21532153
class SubclassInfersFromProtocol1 : SuperclassImplementsProtocol {
21542154
// CHECK: {{^}} @objc func method1(value: Int)
21552155
func method1(value: Int) { }
21562156
}
21572157

2158-
// Note: no inference for subclasses
21592158
class SubclassInfersFromProtocol2 : SuperclassImplementsProtocol {
21602159
}
21612160

21622161
extension SubclassInfersFromProtocol2 {
21632162
// CHECK: {{^}} @objc dynamic func method1(value: Int)
21642163
func method1(value: Int) { }
21652164
}
2166-

0 commit comments

Comments
 (0)