-
Notifications
You must be signed in to change notification settings - Fork 10.5k
IRGen: We can't look through opaque archetypes if the underlying type contains a private type #27609
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
Closed
aschwaighofer
wants to merge
1
commit into
swiftlang:master
from
aschwaighofer:irgen_opaque_result_type_private_underlying
Closed
IRGen: We can't look through opaque archetypes if the underlying type contains a private type #27609
Changes from all commits
Commits
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
17 changes: 17 additions & 0 deletions
17
test/IRGen/Inputs/opaque_result_type_private_underlying_2.swift
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,17 @@ | ||
public protocol A { | ||
associatedtype Assoc | ||
func bindAssoc() -> Assoc | ||
} | ||
|
||
public protocol Q {} | ||
|
||
fileprivate struct PrivateS : Q { | ||
init() {} | ||
} | ||
|
||
public struct G : A { | ||
public init() {} | ||
public func bindAssoc() -> some Q { | ||
return PrivateS() | ||
} | ||
} |
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,8 @@ | ||
// RUN: %target-swift-frontend -disable-availability-checking -emit-ir -primary-file %s -primary-file %S/Inputs/opaque_result_type_private_underlying_2.swift | ||
|
||
public struct G2 : A { | ||
public init() {} | ||
public func bindAssoc() -> some Q { | ||
return G().bindAssoc() | ||
} | ||
} |
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.
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.
Since you have an IRGenModule here, I think you should instead use
getTypeInfo(type).isABIAccessible()
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.
isABIAccessible does not give the right answer for private non resilient types:
The failure occurs when we build the associated type witness. The associated type resolves to an opaque type and the underlying type contains the private type.
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.
Ah, good point. In that case, I think it's still worth extracting a new predicate since it might come up elsewhere.
Is 'private' access enough though? It seems if the declaration is internal, you'll run into the same problem.
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.
You are right internal access is problematic across modules (the problematic case can happen with non-inlineable functions from non resilient modules).
I will fix the code in the ReplaceOpaqueTypesWithUnderlyingTypes utility instead.
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.
New PR: #27666