Files
swift-mirror/test/Constraints/sr10595.swift
Pavel Yaskevich 96441c1129 [CSFix] Account for nested structural errors related to function argument mismatches
When it comes to contextual mismatches `ContextualType` is not guaranteed
to be the last element in the patch since contextual type could be a function
too which could would have `contextual type -> function argument` path.
2020-02-06 09:30:19 -08:00

21 lines
670 B
Swift

// RUN: %target-swift-frontend -typecheck -verify %s
protocol Nested {
associatedtype U // expected-note {{protocol requires nested type 'U'; do you want to add it?}}
}
class A<M> {
func f<T : Nested>(_ t: T, _ keyPath: WritableKeyPath<M, T.U>) {}
}
class B<Y> : Nested { // expected-error {{type 'B<Y>' does not conform to protocol 'Nested'}}
var i: Y?
}
class C<M> {
func cFunc(_ a: A<M>) {
let function: (B<Int>, ReferenceWritableKeyPath<M, Int>) -> Void = a.f // expected-error {{cannot convert value of type '(B<Int>, WritableKeyPath<M, B<Int>.U>) -> ()' to specified type '(B<Int>, ReferenceWritableKeyPath<M, Int>) -> Void'}}
}
}