Files
swift-mirror/test/expr/postfix/call/call-suffix.swift
Doug Gregor 32ca12e39c Revert r4994 "Remove the least liked of the message-send syntaxes".
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
2014-02-12 03:35:03 +00:00

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'}}
}