-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[5.1] IRGen: Save the current generic signature before mangling an opaque type decl #27022
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
airspeedswift
merged 1 commit into
swiftlang:swift-5.1-branch
from
aschwaighofer:mangling_opaque_decl_fix-5.1
Sep 9, 2019
Merged
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
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,73 @@ | ||
public protocol Proto { | ||
associatedtype Assoc : Proto | ||
var value: Assoc { get } | ||
} | ||
|
||
extension Never : Proto {} | ||
|
||
extension Never { | ||
public typealias Assoc = Never | ||
|
||
public var value: Never { | ||
switch self {} | ||
} | ||
} | ||
protocol PrimitiveProto : Proto {} | ||
|
||
extension PrimitiveProto { | ||
public var value: Never { valueError() } | ||
} | ||
|
||
extension Proto { | ||
func valueError() -> Never { | ||
fatalError("value() should not be called on \(Self.self).") | ||
} | ||
} | ||
|
||
public struct EmptyProto : PrimitiveProto { | ||
public init() {} | ||
} | ||
|
||
struct M<Content: Proto> : Proto { | ||
var t: Content | ||
|
||
init(_ t: Content) { | ||
self.t = t | ||
} | ||
|
||
var value: some Proto { | ||
return t.value | ||
} | ||
} | ||
|
||
public struct Group<T> { | ||
var t: T | ||
|
||
public init(_ t: T) { | ||
self.t = t | ||
} | ||
} | ||
|
||
extension Group : Proto, PrimitiveProto where T : Proto { | ||
public typealias Assoc = Never | ||
} | ||
|
||
public struct Choice<T, V>{ | ||
var v: V | ||
|
||
public init(_ t: T, _ v: V) { | ||
self.v = v | ||
} | ||
} | ||
|
||
extension Choice : Proto where T: Proto, V: Proto { | ||
public var value: some Proto { | ||
return v.value | ||
} | ||
} | ||
|
||
extension Proto { | ||
public func add() -> some Proto { | ||
return M(self) | ||
} | ||
} |
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,19 @@ | ||
// RUN: %empty-directory(%t) | ||
// RUN: %target-swift-frontend -disable-availability-checking -emit-module -enable-library-evolution -emit-module-path=%t/A.swiftmodule -module-name=A %S/Inputs/mangle-opaque-return-types-A.swift | ||
// RUN: %target-swift-frontend -disable-availability-checking -I %t -emit-ir %s | ||
import A | ||
|
||
public struct C<T, Content: Proto> { | ||
let data: T | ||
let content: Content | ||
|
||
init(_ t: T, _ c: Content) { | ||
data = t | ||
content = c | ||
} | ||
|
||
public var dontCrash : some Proto { | ||
return Group(Choice(content, EmptyProto().add())) | ||
} | ||
} | ||
|
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.
Should CurGenericSignature be a stack then, with an RAII utility to save and restore the signature?
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.
llvm::SaveAndRestore
is a good way to indicate what's happening hereThere 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.
#27093