mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Set an upper bound on the number of chained lookups we attempt to avoid spinning while trying to recursively apply the same dynamic member lookup to itself. rdar://157288911
22 lines
625 B
Swift
22 lines
625 B
Swift
// RUN: %target-typecheck-verify-swift -dynamic-member-lookup-depth-limit=2
|
|
|
|
@dynamicMemberLookup
|
|
struct Lens<T> {
|
|
init() {}
|
|
subscript<U>(dynamicMember kp: KeyPath<T, U>) -> U {
|
|
fatalError()
|
|
}
|
|
}
|
|
|
|
struct S {
|
|
var x: Int
|
|
}
|
|
|
|
_ = \Lens<S>.x // Fine
|
|
_ = \Lens<Lens<S>>.x // Also fine
|
|
_ = \Lens<Lens<Lens<S>>>.x // expected-error {{could not find member 'x'; exceeded the maximum number of nested dynamic member lookups}}
|
|
|
|
_ = Lens<S>().x // Fine
|
|
_ = Lens<Lens<S>>().x // Also fine
|
|
_ = Lens<Lens<Lens<S>>>().x // expected-error {{could not find member 'x'; exceeded the maximum number of nested dynamic member lookups}}
|