Skip to content

Commit 058c14c

Browse files
authored
Merge pull request #77285 from xymus/recover-under-loadObjCMethods
Serialization: Recover from errors under `loadObjCMethods`
2 parents e54bcef + 9d090c8 commit 058c14c

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

lib/Serialization/ModuleFile.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,8 +713,15 @@ void ModuleFile::loadObjCMethods(
713713
continue;
714714

715715
// Deserialize the method and add it to the list.
716+
// Drop methods with errors.
717+
auto funcOrError = getDeclChecked(std::get<2>(result));
718+
if (!funcOrError) {
719+
diagnoseAndConsumeError(funcOrError.takeError());
720+
continue;
721+
}
722+
716723
if (auto func = dyn_cast_or_null<AbstractFunctionDecl>(
717-
getDecl(std::get<2>(result)))) {
724+
funcOrError.get())) {
718725
methods.push_back(func);
719726
}
720727
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/// Recover under diagnoseUnintendedObjCMethodOverrides.
2+
/// rdar://138764733
3+
4+
// RUN: %empty-directory(%t)
5+
// RUN: split-file %s %t
6+
// REQUIRES: objc_interop
7+
8+
// RUN: %target-swift-frontend -emit-module %t/HiddenDep.swift -I %t \
9+
// RUN: -o %t/HiddenDep.swiftmodule \
10+
// RUN: -disable-objc-attr-requires-foundation-module
11+
12+
// RUN: %target-swift-frontend -emit-module %t/Lib.swift -I %t \
13+
// RUN: -o %t/Lib.swiftmodule \
14+
// RUN: -swift-version 6 -enable-library-evolution \
15+
// RUN: -disable-objc-attr-requires-foundation-module
16+
17+
// RUN: %target-swift-frontend -typecheck %t/Client.swift -I %t \
18+
// RUN: -disable-objc-attr-requires-foundation-module
19+
20+
//--- HiddenDep.swift
21+
@objc
22+
public class HiddenType {}
23+
24+
//--- Lib.swift
25+
internal import HiddenDep
26+
27+
@objc public class Redecl {
28+
@objc
29+
func methodWithXref() -> HiddenType { fatalError() }
30+
}
31+
32+
//--- Client.swift
33+
import Lib
34+
35+
extension Redecl {
36+
@objc(methodWithXref)
37+
func methodWithXref_alias() { }
38+
}

0 commit comments

Comments
 (0)