|
| 1 | +// RUN: %target-typecheck-verify-swift |
| 2 | + |
| 3 | +// This is a variation of `ownership_modifiers.swift` with the expected error |
| 4 | +// lines removed, so that the file is parsed by the SwiftSyntax parser |
| 5 | +// and we validate that both parsers correctly handle this file. |
| 6 | + |
| 7 | +struct borrowing {} |
| 8 | +struct consuming {} |
| 9 | + |
| 10 | +struct Foo {} |
| 11 | + |
| 12 | +func foo(x: borrowing Foo) {} |
| 13 | +func bar(x: consuming Foo) {} |
| 14 | +func baz(x: (borrowing Foo, consuming Foo) -> ()) {} |
| 15 | + |
| 16 | +// `borrowing` and `consuming` are contextual keywords, so they should also |
| 17 | +// continue working as type and/or parameter names |
| 18 | + |
| 19 | +func zim(x: borrowing) {} |
| 20 | +func zang(x: consuming) {} |
| 21 | +func zung(x: borrowing consuming) {} |
| 22 | +func zip(x: consuming borrowing) {} |
| 23 | +func zap(x: (borrowing, consuming) -> ()) {} |
| 24 | +func zoop(x: (borrowing consuming, consuming borrowing) -> ()) {} |
| 25 | + |
| 26 | +// Parameter specifier names are regular identifiers in other positions, |
| 27 | +// including argument labels. |
| 28 | + |
| 29 | +func argumentLabel(borrowing consuming: Int) {} |
| 30 | +func argumentLabel(consuming borrowing: Int) {} |
| 31 | +func argumentLabel(__shared __owned: Int) {} |
| 32 | +func argumentLabel(__owned __shared: Int) {} |
| 33 | + |
| 34 | +// We should parse them as argument labels in function types, even though that |
| 35 | + |
| 36 | +// isn't currently supported. |
| 37 | + |
| 38 | +func argumentLabel(anonBorrowingInClosure: (_ borrowing: Int) -> ()) {} |
| 39 | +func argumentLabel(anonConsumingInClosure: (_ consuming: Int) -> ()) {} |
| 40 | +func argumentLabel(anonSharedInClosure: (_ __shared: Int) -> ()) {} |
| 41 | +func argumentLabel(anonOwnedInClosure: (_ __owned: Int) -> ()) {} |
0 commit comments