Skip to content

Fix a couple of check-swift-validation-optimize test failures #22834

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 2 commits into from
Feb 23, 2019
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
3 changes: 2 additions & 1 deletion lib/AST/Decl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,8 @@ bool Decl::isWeakImported(ModuleDecl *fromModule,
return false;

auto containingContext =
AvailabilityInference::availableRange(this, fromModule->getASTContext());
AvailabilityInference::availableRange(this,
containingModule->getASTContext());
if (!fromContext.isContainedIn(containingContext))
return true;

Expand Down
2 changes: 1 addition & 1 deletion lib/SIL/SILFunctionBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ SILFunctionBuilder::getOrCreateFunction(SILLocation loc, SILDeclRef constant,
if (constant.isForeign && decl->hasClangNode())
F->setClangNodeOwner(decl);

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

if (auto *accessor = dyn_cast<AccessorDecl>(decl)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
public func getVersion() -> Int {
#if BEFORE
return 0
#else
return 1
#endif
}

#if AFTER
@_weakLinked @usableFromInline func weakFunction() -> String {
return "new"
}

@_alwaysEmitIntoClient public func serializedFunction() -> String {
if getVersion() == 1 {
return weakFunction()
}
return "old"
}
#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// RUN: %target-resilience-test --backward-deployment
// REQUIRES: executable_test

import StdlibUnittest
import backward_deploy_always_emit_into_client


var BackwardDeployTopLevelTest = TestSuite("BackwardDeployAlwaysEmitIntoClient")

BackwardDeployTopLevelTest.test("BackwardDeployAlwaysEmitIntoClient") {
expectEqual(serializedFunction(), getVersion() == 1 ? "new" : "old")
}

runAllTests()
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class ClassWithResilientField {
@_optimize(none) func blackHole<T>(_: T) {}

@_optimize(none) func forceMetadata() {
blackHole(ClassWithResilientField.self)
blackHole(ClassWithResilientField())
}

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