Files
swift-mirror/test/Constraints/class.swift
Doug Gregor 793b3326af Implement the new rules for argument label defaults.
The rule changes are as follows:
  * All functions (introduced with the 'func' keyword) have argument
  labels for arguments beyond the first, by default. Methods are no
  longer special in this regard.
  * The presence of a default argument no longer implies an argument
  label.

The actual changes to the parser and printer are fairly simple; the
rest of the noise is updating the standard library, overlays, tests,
etc.

With the standard library, this change is intended to be API neutral:
I've added/removed #'s and _'s as appropriate to keep the user
interface the same. If we want to separately consider using argument
labels for more free functions now that the defaults in the language
have shifted, we can tackle that separately.

Fixes rdar://problem/17218256.

Swift SVN r27704
2015-04-24 19:03:30 +00:00

42 lines
698 B
Swift

// RUN: %target-parse-verify-swift
class A { }
class B : A { }
class C : B { }
class D : B { }
class E<T> : D { }
class F<T> : E<[T]> { }
var a : A
var b : B
var c : C
var d : D
var ef : E<Float>
var fi : F<Int>
func f0(b : B) {}
func ternary<T>(cond: Bool,
@autoclosure _ ifTrue: () -> T,
@autoclosure _ ifFalse: () -> T) -> T {}
f0(c)
f0(a) // expected-error{{cannot invoke 'f0' with an argument list of type '(A)'}} expected-note {{expected an argument list of type '(B)'}}
f0(ef)
f0(fi)
// FIXME: Test subtyping of class metatypes.
ternary(true, ef, c)
class X {
init() {}
init(x:Int, y:UnicodeScalar) {}
}
var x0 = X()
var x1 = X(x: 1, y: "2")