Skip to content

[Serialization] Handle llvm::Error in member deserialization recovery #16957

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/Serialization/ModuleFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1850,6 +1850,8 @@ ModuleFile::loadNamedMembers(const IterableDeclContext *IDC, DeclBaseName N,
} else {
if (!getContext().LangOpts.EnableDeserializationRecovery)
fatal(mem.takeError());
llvm::consumeError(mem.takeError());

// Treat this as a cache-miss to the caller and let them attempt
// to refill through the normal loadAllMembers() path.
return None;
Expand Down
11 changes: 11 additions & 0 deletions test/Serialization/Recovery/Inputs/typedefs-helper.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Tiny test that only accesses specific members of the 'User' class, never
// forcing /all/ members to be loaded, in order to test recovery for lazy member
// loading.

import Typedefs
import Lib

func test(user: User) {
_ = user.returnsWrappedMethod() // expected-error {{value of type 'User' has no member 'returnsWrappedMethod'; did you mean 'returnsUnwrappedMethod'?}}
_ = user.returnsUnwrappedMethod() // okay
}
2 changes: 2 additions & 0 deletions test/Serialization/Recovery/typedefs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// RUN: %target-swift-frontend -emit-ir -I %t -I %S/Inputs/custom-modules -DTEST %s | %FileCheck -check-prefix CHECK-IR %s
// RUN: %target-swift-frontend -emit-ir -I %t -I %S/Inputs/custom-modules -Xcc -DBAD -DTEST %s | %FileCheck -check-prefix CHECK-IR %s

// RUN: %target-swift-frontend -typecheck -I %t -I %S/Inputs/custom-modules -Xcc -DBAD %S/Inputs/typedefs-helper.swift -verify

#if TEST

import Typedefs
Expand Down