@@ -632,26 +632,27 @@ static Type lookupDefaultLiteralType(const DeclContext *dc,
632
632
return cast<TypeAliasDecl>(TD)->getDeclaredInterfaceType ();
633
633
}
634
634
635
- static llvm::Optional<KnownProtocolKind>
636
- getKnownProtocolKindIfAny (const ProtocolDecl *protocol) {
637
- #define EXPRESSIBLE_BY_LITERAL_PROTOCOL_WITH_NAME (Id, _, __, ___ ) \
638
- if (protocol == TypeChecker::getProtocol (protocol->getASTContext (), \
639
- SourceLoc (), \
640
- KnownProtocolKind::Id)) \
641
- return KnownProtocolKind::Id;
642
- #include " swift/AST/KnownProtocols.def"
643
- #undef EXPRESSIBLE_BY_LITERAL_PROTOCOL_WITH_NAME
635
+ Type TypeChecker::getDefaultType (ProtocolDecl *protocol, DeclContext *dc) {
636
+ auto knownKind = protocol->getKnownProtocolKind ();
637
+ if (!knownKind)
638
+ return Type ();
644
639
645
- return llvm::None;
646
- }
640
+ switch (knownKind.value ()) {
641
+ #define EXPRESSIBLE_BY_LITERAL_PROTOCOL_WITH_NAME (Id, _, __, ___ ) \
642
+ case KnownProtocolKind::Id: \
643
+ break ;
644
+ #define PROTOCOL_WITH_NAME (Id, _ ) \
645
+ case KnownProtocolKind::Id: \
646
+ return Type ();
647
647
648
- Type TypeChecker::getDefaultType (ProtocolDecl *protocol, DeclContext *dc) {
649
- if (auto knownProtocolKindIfAny = getKnownProtocolKindIfAny (protocol)) {
650
- return evaluateOrDefault (
651
- protocol->getASTContext ().evaluator ,
652
- DefaultTypeRequest{knownProtocolKindIfAny.value (), dc}, nullptr );
648
+ #include " swift/AST/KnownProtocols.def"
649
+ #undef EXPRESSIBLE_BY_LITERAL_PROTOCOL_WITH_NAME
650
+ #undef PROTOCOL_WITH_NAME
653
651
}
654
- return Type ();
652
+
653
+ return evaluateOrDefault (
654
+ protocol->getASTContext ().evaluator ,
655
+ DefaultTypeRequest{knownKind.value (), dc}, nullptr );
655
656
}
656
657
657
658
static std::pair<const char *, bool > lookupDefaultTypeInfoForKnownProtocol (
0 commit comments