Files
swift-mirror/validation-test/compiler_crashers_2_fixed/0119-rdar33613329.swift
Pavel Yaskevich 9d9a6c6231 [Diagnostics] Restore inout ParamDecl types properly after type-check
We are currently in process of removing `InOutType`
so `VarDecl::get{Interface}Type` is going to wrap base
type into `InOutType` if its flag indicates that it's
an `inout` parameter declaration. But such type can't
be restored directly using `VarDecl::set{Interface}Type`
caller needs additional logic to extract base type.

Resolves: rdar://problem/33613329
2017-09-25 17:38:28 -07:00

46 lines
978 B
Swift

// RUN: %target-typecheck-verify-swift %s
precedencegroup BindingPrecedence {
higherThan: DefaultPrecedence
}
infix operator ~>
infix operator > : BindingPrecedence
struct M<L : P, R> {
let f: L
let b: (inout L.B) -> R
init(f: L, b: @escaping (inout L.B) -> R) {
self.f = f
self.b = b
}
}
protocol P {
associatedtype A
associatedtype B
func `in`<R>(_ a: inout A, apply body: (inout B) -> R) -> R
static func ~> (_: A, _: Self) -> B
}
extension P {
static func > <R>(f: Self, b: @escaping (inout B) -> R) -> M<Self, R> {}
}
extension WritableKeyPath : P {
typealias A = Root
typealias B = Value
func `in`<R>(_ a: inout A, apply body: (inout B) -> R) -> R {}
static func ~> (a: A, path: WritableKeyPath) -> B {}
}
struct X { var y: Int = 0 }
var x = X()
x ~> \X.y > { a in a += 1; return 3 }
// expected-error@-1 {{cannot convert call result type 'M<WritableKeyPath<X, Int>, _>' to expected type 'WritableKeyPath<_, _>'}}