mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
In other words, provide basic parsing support for selector arguments
on a single line, i.e.,
a.foo(1) bar(2.5) wibble("hello")
Swift SVN r13806
47 lines
1.5 KiB
Swift
47 lines
1.5 KiB
Swift
// RUN: %swift -parse %s -verify
|
|
|
|
class A {
|
|
func foo(i: Int) bar(Double) { }
|
|
func foo(i: Int) bar(Double) wibble(String) -> String { return "" }
|
|
}
|
|
|
|
func global(i: Int) printer(s: String) { }
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// Test multi-piece selector calls on a single line
|
|
// -----------------------------------------------------------------------------
|
|
|
|
func testMethodCallSingleLine(a: A, i: Int, d: Double, s: String) {
|
|
var x = a.foo(i) bar(d) wibble(s)
|
|
x = "hello"
|
|
|
|
// Line break ends the current call-suffix
|
|
a.foo(i) bar(d)
|
|
wibble(s) // expected-error{{use of unresolved identifier 'wibble'}}
|
|
}
|
|
|
|
func testGlobalCallSingleLine(i: Int, s: String) {
|
|
global(i) printer(s)
|
|
}
|
|
|
|
extension A {
|
|
func testImplicitSelfCallSingleLine(i: Int, d: Double, s: String) {
|
|
var x = foo(i) bar(d) wibble(s)
|
|
x = "hello"
|
|
}
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// Test multi-piece selector calls that chain
|
|
// -----------------------------------------------------------------------------
|
|
func testMethodCallSingleLineChaining(a: A, i: Int, d: Double, s: String) {
|
|
var x = a.foo(i) bar(d) wibble(s).codeUnits
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// Test parser recovery
|
|
// -----------------------------------------------------------------------------
|
|
func testIllFormed(a: A, i: Int, d: Double, s: String) {
|
|
var x = a.foo(i) bar // expected-error{{expected '(' following selector piece 'bar'}}
|
|
}
|