-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Fix opaque type substitution in the package cmo resilience domain #73794
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
aschwaighofer
merged 2 commits into
swiftlang:main
from
aschwaighofer:package_cmo_opaque_type_subst
May 24, 2024
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// RUN: %empty-directory(%t) | ||
// RUN: split-file %s %t | ||
|
||
// RUN: %target-build-swift %t/Lib.swift \ | ||
// RUN: -module-name=Lib -package-name Pkg \ | ||
// RUN: -parse-as-library -emit-module -emit-module-path %t/Lib.swiftmodule -I%t \ | ||
// RUN: -Xfrontend -experimental-package-cmo -Xfrontend -experimental-allow-non-resilient-access \ | ||
// RUN: -O -wmo -enable-library-evolution -Xfrontend -disable-availability-checking | ||
|
||
// RUN: %target-build-swift -module-name=Main -package-name Pkg -I%t -emit-sil -O %t/main.swift -o %t/Main-res.sil | ||
// RUN: %FileCheck %s --check-prefixes=CHECK-OPAQUE < %t/Main-res.sil | ||
|
||
// REQUIRES: swift_in_compiler | ||
|
||
//--- main.swift | ||
|
||
import Lib | ||
|
||
// CHECK-OPAQUE: sil @$s4Main023testPackageInSerializedC4FuncyyF : $@convention(thin) () -> () | ||
// CHECK-OPAQUE: struct $Thing | ||
// CHECK-OPAQUE: struct $Thing1 | ||
// CHECK-OPAQUE: function_ref @$s3Lib13getSomeProto2QryF | ||
// CHECK-OPAQUE: function_ref @$s3Lib13getSomeProto3QryF | ||
// CHECK-OPAQUE: } // end sil function '$s4Main023testPackageInSerializedC4FuncyyF' | ||
|
||
public func testPackageInSerializedPackageFunc() { | ||
print(getSomeProto()) | ||
print(getSomeProto1()) | ||
print(getSomeProto2()) | ||
print(getSomeProto3()) | ||
} | ||
|
||
//--- Lib.swift | ||
|
||
public protocol SomeProto {} | ||
|
||
public struct Thing : SomeProto {} | ||
package struct Thing1 : SomeProto {} | ||
internal struct Thing2 : SomeProto {} | ||
private struct Thing3 : SomeProto {} | ||
|
||
// Don't crash on this example. | ||
public func getSomeProto() -> some SomeProto { | ||
return Thing() | ||
} | ||
public func getSomeProto1() -> some SomeProto { | ||
return Thing1() | ||
} | ||
public func getSomeProto2() -> some SomeProto { | ||
return Thing2() | ||
} | ||
public func getSomeProto3() -> some SomeProto { | ||
return Thing3() | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we throw a proper diagnostics somewhere else so we don't need this -disable-availability-checking flag?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this flag is used out of convenience, without it availability annotations would have to be used (because of opaque result types).