Files
swift-mirror/test/decl/overload_swift5.swift
Huon Wilson b96aedaf64 [Sema] Match Swift 4.0/4.1 overloading behaviour for properties in extensions of generic types.
The patch that nailed down our semantics here missed an additional case that
required a compatibility hack: a property on a generic type and a same-named one
in an (unconstrained) extension:

    struct Foo<T> {
        var x: Int { return 0 }
    }
    extension Foo {
        var x: Bool { return false }
    }

Fixes rdar://problem/40685642.
2018-06-22 08:43:34 +10:00

25 lines
999 B
Swift

// RUN: %target-typecheck-verify-swift -swift-version 5
struct SR7251<T> {
struct j {} // expected-note {{previously declared here}}
static var k: Int { return 0 } // expected-note {{previously declared here}}
}
extension SR7251 {
static var i: Int { return 0 } // expected-note {{previously declared here}}
struct i {} // expected-error{{invalid redeclaration of 'i'}}
static var j: Int { return 0 } // expected-error{{invalid redeclaration of 'j'}}
struct k {} // expected-error{{invalid redeclaration of 'k'}}
}
struct SR7249<T> {
var x: T { fatalError() } // expected-note {{previously declared}}
var y: Int // expected-note {{previously declared}}
var z: Int // expected-note {{previously declared}}
}
extension SR7249 {
var x: Int { fatalError() } // expected-error{{invalid redeclaration of 'x'}}
var y: T { fatalError() } // expected-error{{invalid redeclaration of 'y'}}
var z: Int { fatalError() } // expected-error{{invalid redeclaration of 'z'}}
}