mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Set up constraints and solution application for SuperConstructorRefCallExpr. Swift SVN r3916
51 lines
929 B
Swift
51 lines
929 B
Swift
// RUN: %swift %s -constraint-checker -parse-as-library -verify
|
|
|
|
struct S {
|
|
constructor() {
|
|
super.constructor() // expected-error{{'super.constructor' cannot be called in a constructor for a non-class type}}
|
|
}
|
|
}
|
|
|
|
class D : B {
|
|
func foo() {
|
|
super.constructor() // expected-error{{'super.constructor' cannot be called outside of a constructor}}
|
|
}
|
|
|
|
constructor(a:Int) {
|
|
super.constructor()
|
|
}
|
|
|
|
constructor(e:Int) {
|
|
super.constructor('x') // expected-error{{}}
|
|
}
|
|
|
|
constructor(f:Int) {
|
|
super.constructor(a='x')
|
|
}
|
|
|
|
constructor(g:Int) {
|
|
super.constructor("aoeu") // expected-error{{}}
|
|
}
|
|
}
|
|
|
|
class B {
|
|
var foo : (bar:Int)
|
|
func bar() {}
|
|
|
|
constructor() {
|
|
}
|
|
|
|
constructor(x:Int) {
|
|
}
|
|
|
|
constructor(a:Char) {
|
|
}
|
|
constructor(b:Char) {
|
|
}
|
|
|
|
constructor(z:Float) {
|
|
super.constructor() // expected-error{{'super.constructor' cannot be called in a root class constructor}}
|
|
}
|
|
}
|
|
|