1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend -emit-module-path %t/availability_overloads_other.swiftmodule -emit-module -primary-file %S/Inputs/availability_overloads_other.swift
// RUN: %target-swift-emit-silgen -swift-version 4 -I %t -primary-file %s
// RUN: %target-swift-emit-ir -swift-version 4 -I %t %s
// RUN: %target-swift-emit-silgen -swift-version 5 -I %t -primary-file %s
// RUN: %target-swift-emit-ir -swift-version 5 -I %t %s
// RUN: %target-swift-frontend -swift-version 4 -I %t -emit-module -emit-module-path /dev/null -primary-file %s
// RUN: %target-swift-frontend -swift-version 5 -I %t -emit-module -emit-module-path /dev/null -primary-file %s
// This is a "don't crash with duplicate definition errors" test.
// We care about being able to express each of these "redeclarations" when the
// availability doesn't overlap.
import availability_overloads_other
// FIXME: What about method overrides and protocol witnesses?
public class BeforeAndAfter {
@available(swift, obsoleted: 4.0)
public init(foo: ()) {}
@available(swift 4.0)
public init?(foo: ()) {}
@available(swift, obsoleted: 4.0)
public init() {}
@available(swift 4.0)
public init() throws {}
@available(swift, obsoleted: 4.0)
public static func foo() {}
@available(swift 4.0)
public static func foo() throws {}
@available(swift 4.0)
public var computed: Int16 { get { return 0 } set { } }
@available(swift, obsoleted: 4.0)
public var computed: Int8 { get { return 0 } set { } }
@available(swift 4.0)
public static var computed: Int16 { get { return 0 } set { } }
@available(swift, obsoleted: 4.0)
public static var computed: Int8 { get { return 0 } set { } }
}
// Make sure we can generate calls to these overloads, too
_ = BeforeAndAfter(foo: ())
_ = try BeforeAndAfter()
_ = try BeforeAndAfter.foo()
_ = BeforeAndAfter.computed
BeforeAndAfter.computed = 10
_ = try BeforeAndAfter().computed
try BeforeAndAfter().computed = 10
// Same thing but in a different module
_ = BeforeAndAfterOther(foo: ())
_ = try BeforeAndAfterOther()
_ = try BeforeAndAfterOther.foo()
_ = BeforeAndAfterOther.computed
BeforeAndAfterOther.computed = 10
_ = try BeforeAndAfterOther().computed
try BeforeAndAfterOther().computed = 10
|