Skip to content

Commit 4820453

Browse files
committed
[Type checker] Minor cleanups for @objc inference from witnesses.
1 parent 47e1151 commit 4820453

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
@@ -4920,6 +4920,7 @@ TypeChecker::findWitnessedObjCRequirements(const ValueDecl *witness,
49204920
// We only care about Objective-C protocols.
49214921
if (!proto->isObjC()) continue;
49224922

4923+
Optional<ProtocolConformance *> conformance;
49234924
for (auto req : proto->lookupDirect(name, true)) {
49244925
// Skip anything in a protocol extension.
49254926
if (req->getDeclContext() != proto) continue;
@@ -4928,7 +4929,6 @@ TypeChecker::findWitnessedObjCRequirements(const ValueDecl *witness,
49284929
if (isa<TypeDecl>(req)) continue;
49294930

49304931
// Dig out the conformance.
4931-
Optional<ProtocolConformance *> conformance;
49324932
if (!conformance.hasValue()) {
49334933
SmallVector<ProtocolConformance *, 2> conformances;
49344934
nominal->lookupConformance(dc->getParentModule(), proto,

test/attr/attr_objc.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2180,20 +2180,18 @@ extension ClassInfersFromProtocol3 {
21802180
func method1(value: String) { }
21812181
}
21822182

2183+
// Inference for subclasses.
21832184
class SuperclassImplementsProtocol : InferFromProtocol { }
21842185

2185-
// Note: no inference for subclasses
21862186
class SubclassInfersFromProtocol1 : SuperclassImplementsProtocol {
21872187
// CHECK: {{^}} @objc func method1(value: Int)
21882188
func method1(value: Int) { }
21892189
}
21902190

2191-
// Note: no inference for subclasses
21922191
class SubclassInfersFromProtocol2 : SuperclassImplementsProtocol {
21932192
}
21942193

21952194
extension SubclassInfersFromProtocol2 {
21962195
// CHECK: {{^}} @objc dynamic func method1(value: Int)
21972196
func method1(value: Int) { }
21982197
}
2199-

0 commit comments

Comments
 (0)