Skip to content

Two regression tests #34420

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
Oct 24, 2020
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
54 changes: 54 additions & 0 deletions validation-test/compiler_crashers_2_fixed/sr12473.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// RUN: %target-swift-frontend -emit-ir %s

protocol Dismissable {
func dismiss(completion: @escaping () -> Void)
}

typealias Completion = (Dismissable?) -> Void

protocol Cancelable: AnyObject {
func cancel()
}

protocol Controller {
func asyncThing(completion: @escaping ((_ error: Error) -> Void)) -> Cancelable
}

public struct Message: Equatable {
public static let `default` = Message()

public init() {
}

public init(error: Error) {
self = .default
}
}

struct PresentAlert {
let message: Message
}

class Manager {
private let controller: Controller

init(controller: Controller) {
self.controller = controller
}

func present() {
let _: Completion = { (dismissable: Dismissable?) in
dismissable?.dismiss { [weak self] in
guard let sself = self else { return }

sself.controller.asyncThing { error in
let backupMessage = Message()
let mainMessage = Message(error: error)
let finalMessage = mainMessage != Message.default ? mainMessage : backupMessage

_ = PresentAlert(message: finalMessage)
}.cancel()
}
}
}
}
13 changes: 13 additions & 0 deletions validation-test/compiler_crashers_2_fixed/sr13727.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// RUN: %target-swift-frontend -emit-ir %s

protocol Projection {
associatedtype Root
associatedtype Path: PartialKeyPath<Root>
static var path: Path { get }
}

struct ProjectKey<Key, Value>: Projection {
typealias Root = (Key, Value)
typealias Path = KeyPath<(Key, Value), Key>
static var path: KeyPath<(Key, Value), Key> { \.0 }
}