Skip to content

Commit

Permalink
[Diagnostics] NFC: Add more test-cases for subscript refs with uninte…
Browse files Browse the repository at this point in the history
…nded property unwrap
  • Loading branch information
xedin committed Jul 5, 2019
1 parent 626b93c commit c195fdc
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion test/decl/var/property_wrappers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,16 @@ struct Foo<T> { // expected-note {{arguments to generic parameter 'T' ('W' and '
get { return 42 }
set { }
}

subscript(x x: Int) -> Int {
get { return 42 }
set { }
}

subscript(q q: String, a: Int) -> Bool {
get { return false }
set { }
}
}

@propertyWrapper
Expand Down Expand Up @@ -1021,13 +1031,19 @@ struct MissingPropertyWrapperUnwrap {

self.x["ultimate question"] // expected-error {{referencing subscript 'subscript(_:)' requires wrapper 'Foo<Int>'}} {{10-10=_}}
self.x["ultimate question"] = 42 // expected-error {{referencing subscript 'subscript(_:)' requires wrapper 'Foo<Int>'}} {{10-10=_}}

self.x[x: 42] // expected-error {{referencing subscript 'subscript(x:)' requires wrapper 'Foo<Int>'}} {{10-10=_}}
self.x[x: 42] = 0 // expected-error {{referencing subscript 'subscript(x:)' requires wrapper 'Foo<Int>'}} {{10-10=_}}

self.x[q: "ultimate question", 42] // expected-error {{referencing subscript 'subscript(q:_:)' requires wrapper 'Foo<Int>'}} {{10-10=_}}
self.x[q: "ultimate question", 42] = true // expected-error {{referencing subscript 'subscript(q:_:)' requires wrapper 'Foo<Int>'}} {{10-10=_}}
}
}

struct InvalidPropertyDelegateUse {
@Foo var x: Int = 42 // expected-error {{extra argument 'initialValue' in call}}

func test() {
self.x.foo() // expected-error {{alue of type 'Int' has no member 'foo'}}
self.x.foo() // expected-error {{value of type 'Int' has no member 'foo'}}
}
}

0 comments on commit c195fdc

Please sign in to comment.