Files
swift-mirror/test/Constraints/super_constructor.swift
Chris Lattner 72c5c3e4fe Two changes:
- Enhance the branch new argument label overload diagnostic to just
   print the argument labels that are the problem, instead of printing
   the types inferred at the argument context.  This can lead to confusion
   particularly when an argument label is missing.  For example before:

error: argument labels '(Int)' do not match any available overloads
note: overloads for 'TestOverloadSets.init' exist with these partially matching parameter lists: (a: Z0), (value: Int), (value: Double)

after:

error: argument labels '(_:)' do not match any available overloads
note: overloads for 'TestOverloadSets.init' exist with these partially matching parameter lists: (a: Z0), (value: Int), (value: Double)


Second, fix <rdar://problem/22451001> QoI: incorrect diagnostic when argument to print has the wrong type
by specifically diagnosing the problem when you pass in an argument to a nullary function.  Before:

error: cannot convert value of type 'Int' to expected argument type '()'

after:
error: argument passed to call that takes no arguments
print(r22451001(5))
                ^




Swift SVN r31795
2015-09-09 00:26:37 +00:00

56 lines
1.1 KiB
Swift

// RUN: %target-parse-verify-swift -parse-as-library
struct S {
init() {
super.init() // expected-error{{'super' cannot be used outside of class members}}
}
}
class D : B {
func foo() {
super.init() // expected-error{{'super.init' cannot be called outside of an initializer}}
}
init(a:Int) {
super.init()
}
init(f:Int) {
super.init(a: "x")
}
init(g:Int) {
super.init("aoeu") // expected-error{{argument labels '(_:)' do not match any available overloads}}
// expected-note @-1 {{overloads for 'B.init' exist with these partially matching parameter lists: (x: Int), (a: UnicodeScalar), (b: UnicodeScalar), (z: Float)}}
}
init(h:Int) {
var _ : B = super.init() // expected-error{{cannot convert value of type '()' to specified type 'B'}}
}
init(d:Double) {
super.init()
}
}
class B {
var foo : Int
func bar() {}
init() {
}
init(x:Int) {
}
init(a:UnicodeScalar) {
}
init(b:UnicodeScalar) {
}
init(z:Float) {
super.init() // expected-error{{'super' members cannot be referenced in a root class}}
}
}