Skip to content

Commit 3300d1a

Browse files
authored
Merge pull request #22834 from slavapestov/fix-optimized-test-failures
Fix a couple of check-swift-validation-optimize test failures
2 parents dbbac8d + b9bda84 commit 3300d1a

File tree

5 files changed

+38
-3
lines changed

5 files changed

+38
-3
lines changed

lib/AST/Decl.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,8 @@ bool Decl::isWeakImported(ModuleDecl *fromModule,
548548
return false;
549549

550550
auto containingContext =
551-
AvailabilityInference::availableRange(this, fromModule->getASTContext());
551+
AvailabilityInference::availableRange(this,
552+
containingModule->getASTContext());
552553
if (!fromContext.isContainedIn(containingContext))
553554
return true;
554555

lib/SIL/SILFunctionBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ SILFunctionBuilder::getOrCreateFunction(SILLocation loc, SILDeclRef constant,
155155
if (constant.isForeign && decl->hasClangNode())
156156
F->setClangNodeOwner(decl);
157157

158-
if (decl->isWeakImported(mod.getSwiftModule(), availCtx))
158+
if (decl->isWeakImported(/*forModule=*/nullptr, availCtx))
159159
F->setWeakLinked();
160160

161161
if (auto *accessor = dyn_cast<AccessorDecl>(decl)) {
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
public func getVersion() -> Int {
2+
#if BEFORE
3+
return 0
4+
#else
5+
return 1
6+
#endif
7+
}
8+
9+
#if AFTER
10+
@_weakLinked @usableFromInline func weakFunction() -> String {
11+
return "new"
12+
}
13+
14+
@_alwaysEmitIntoClient public func serializedFunction() -> String {
15+
if getVersion() == 1 {
16+
return weakFunction()
17+
}
18+
return "old"
19+
}
20+
#endif
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// RUN: %target-resilience-test --backward-deployment
2+
// REQUIRES: executable_test
3+
4+
import StdlibUnittest
5+
import backward_deploy_always_emit_into_client
6+
7+
8+
var BackwardDeployTopLevelTest = TestSuite("BackwardDeployAlwaysEmitIntoClient")
9+
10+
BackwardDeployTopLevelTest.test("BackwardDeployAlwaysEmitIntoClient") {
11+
expectEqual(serializedFunction(), getVersion() == 1 ? "new" : "old")
12+
}
13+
14+
runAllTests()

validation-test/Runtime/old_runtime_crash_without_fixed_layout.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class ClassWithResilientField {
2929
@_optimize(none) func blackHole<T>(_: T) {}
3030

3131
@_optimize(none) func forceMetadata() {
32-
blackHole(ClassWithResilientField.self)
32+
blackHole(ClassWithResilientField())
3333
}
3434

3535
if #available(macOS 10.14.4, iOS 12.2, tvOS 12.2, watchOS 5.2, *) {

0 commit comments

Comments
 (0)