Files
swift-mirror/test/Constraints/rdar46544601.swift
Pavel Yaskevich 09cb803e79 [CSDiag] Always attempt to erase open existentials after re-typecheck
All of the open existentials should be removed, along with their
opaque value expressions, after sub-expression type-check. Because
diagnostics might pick next sub-expression from constraint and its
anchor could point to sub-expression which has only opaque value
without enclosing open existential, which is going to trip up sanitizer.

Resolves: rdar://problem/46544601
2018-12-21 00:34:27 -08:00

35 lines
1.0 KiB
Swift

// RUN: %target-typecheck-verify-swift
struct D {}
class Future<T> {
func then<U>(_ fn: @escaping (T) -> Future<U>) -> Future<U> { fatalError() }
func thenThrowing<U>(_ fn: @escaping (T) throws -> U) -> Future<U> { fatalError() }
func whenFailure(_ fn: @escaping (Error) -> Void) {}
func and<U>(result: U) -> Future<(T,U)> { fatalError() }
}
protocol P {
func foo(arr: [D], data: ArraySlice<UInt8>) -> Future<D>
// expected-note@-1 {{found this candidate}}
func bar(root: D, from: P) -> Future<D>
}
extension P {
func foo(arr: [D] = [], data: [UInt8]) -> Future<D> { fatalError() }
// expected-note@-1 {{found this candidate}}
}
func crash(_ p: P, payload: [UInt8]) throws {
p.foo(data: payload).then { _ in
return Future<(D, [D])>()
}.then { (id, arr) in
p.foo(arr: arr, data: []).and(result: (id, arr))
// expected-error@-1 {{mbiguous reference to member 'foo(arr:data:)'}}
}.then { args0 in
let (parentID, args1) = args0
p.bar(root: parentID, from: p).and(args1)
}.whenFailure { _ in }
}