Skip to content

Commit 0bd6f25

Browse files
committed
PrintAsClang: More idiomatic conformance lookup
1 parent 43b7493 commit 0bd6f25

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

lib/PrintAsClang/DeclAndTypePrinter.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "swift/AST/ASTVisitor.h"
2525
#include "swift/AST/ClangSwiftTypeCorrespondence.h"
2626
#include "swift/AST/Comment.h"
27+
#include "swift/AST/ConformanceLookup.h"
2728
#include "swift/AST/Decl.h"
2829
#include "swift/AST/ExistentialLayout.h"
2930
#include "swift/AST/ForeignAsyncConvention.h"
@@ -2155,16 +2156,16 @@ class DeclAndTypePrinter::Implementation
21552156
auto proto = ctx.getProtocol(KnownProtocolKind::ObjectiveCBridgeable);
21562157
if (!proto) return nullptr;
21572158

2159+
auto declaredType = nominal->getDeclaredInterfaceType();
2160+
21582161
// Determine whether this nominal type is _ObjectiveCBridgeable.
2159-
SmallVector<ProtocolConformance *, 2> conformances;
2160-
if (!nominal->lookupConformance(proto, conformances))
2162+
auto conformance = lookupConformance(declaredType, proto);
2163+
if (!conformance)
21612164
return nullptr;
21622165

21632166
// Dig out the Objective-C type.
2164-
auto conformance = conformances.front();
2165-
Type objcType = ProtocolConformanceRef(conformance).getTypeWitnessByName(
2166-
nominal->getDeclaredType(),
2167-
ctx.Id_ObjectiveCType);
2167+
Type objcType = conformance.getTypeWitnessByName(
2168+
declaredType, ctx.Id_ObjectiveCType);
21682169

21692170
// Dig out the Objective-C class.
21702171
return objcType->getClassOrBoundGenericClass();

0 commit comments

Comments
 (0)