@@ -774,7 +774,15 @@ void ModuleFile::lookupClassMember(ImportPath::Access accessPath,
774774 // one.
775775 if (name.isSimpleName ()) {
776776 for (auto item : *iter) {
777- auto vd = cast<ValueDecl>(getDecl (item.second ));
777+ auto declOrError = getDeclChecked (item.second );
778+ if (!declOrError) {
779+ if (!getContext ().LangOpts .EnableDeserializationRecovery )
780+ fatal (declOrError.takeError ());
781+ consumeError (declOrError.takeError ());
782+ continue ;
783+ }
784+
785+ auto vd = cast<ValueDecl>(declOrError.get ());
778786 auto dc = vd->getDeclContext ();
779787 while (!dc->getParent ()->isModuleScopeContext ())
780788 dc = dc->getParent ();
@@ -784,7 +792,15 @@ void ModuleFile::lookupClassMember(ImportPath::Access accessPath,
784792 }
785793 } else {
786794 for (auto item : *iter) {
787- auto vd = cast<ValueDecl>(getDecl (item.second ));
795+ auto declOrError = getDeclChecked (item.second );
796+ if (!declOrError) {
797+ if (!getContext ().LangOpts .EnableDeserializationRecovery )
798+ fatal (declOrError.takeError ());
799+ consumeError (declOrError.takeError ());
800+ continue ;
801+ }
802+
803+ auto vd = cast<ValueDecl>(declOrError.get ());
788804 if (!vd->getName ().matchesRef (name))
789805 continue ;
790806
@@ -800,7 +816,15 @@ void ModuleFile::lookupClassMember(ImportPath::Access accessPath,
800816 }
801817
802818 for (auto item : *iter) {
803- auto vd = cast<ValueDecl>(getDecl (item.second ));
819+ auto declOrError = getDeclChecked (item.second );
820+ if (!declOrError) {
821+ if (!getContext ().LangOpts .EnableDeserializationRecovery )
822+ fatal (declOrError.takeError ());
823+ consumeError (declOrError.takeError ());
824+ continue ;
825+ }
826+
827+ auto vd = cast<ValueDecl>(declOrError.get ());
804828 results.push_back (vd);
805829 }
806830}
@@ -818,6 +842,8 @@ void ModuleFile::lookupClassMembers(ImportPath::Access accessPath,
818842 for (auto item : list) {
819843 auto decl = getDeclChecked (item.second );
820844 if (!decl) {
845+ if (!getContext ().LangOpts .EnableDeserializationRecovery )
846+ fatal (decl.takeError ());
821847 llvm::consumeError (decl.takeError ());
822848 continue ;
823849 }
@@ -839,6 +865,8 @@ void ModuleFile::lookupClassMembers(ImportPath::Access accessPath,
839865 for (auto item : list) {
840866 auto decl = getDeclChecked (item.second );
841867 if (!decl) {
868+ if (!getContext ().LangOpts .EnableDeserializationRecovery )
869+ fatal (decl.takeError ());
842870 llvm::consumeError (decl.takeError ());
843871 continue ;
844872 }
0 commit comments