mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
NFC: Fix tests that mistakenly rely on unavailable stored properties.
Preparation for rdar://107449845
This commit is contained in:
@@ -12,10 +12,12 @@
|
||||
|
||||
SPI_AVAILABLE(macos(10.7))
|
||||
@interface SPIInterface1
|
||||
- (instancetype)init;
|
||||
@end
|
||||
|
||||
__SPI_AVAILABLE(macos(10.7))
|
||||
@interface SPIInterface2
|
||||
- (instancetype)init;
|
||||
@end
|
||||
|
||||
@interface SharedInterface
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
// REQUIRES: OS=macosx
|
||||
// RUN: %target-swift-frontend -typecheck %s -F %S/Inputs/frameworks -verify -DNOT_UNDERLYING -library-level api
|
||||
// RUN: %target-swift-frontend -typecheck %s -F %S/Inputs/frameworks -module-name SPIContainer -import-underlying-module -verify -library-level api
|
||||
// RUN: %target-swift-frontend -typecheck %s -F %S/Inputs/frameworks -verify -DNOT_UNDERLYING -library-level api -parse-as-library -require-explicit-availability=ignore
|
||||
// RUN: %target-swift-frontend -typecheck %s -F %S/Inputs/frameworks -module-name SPIContainer -import-underlying-module -verify -library-level api -parse-as-library -require-explicit-availability=ignore
|
||||
|
||||
#if NOT_UNDERLYING
|
||||
import SPIContainer
|
||||
#endif
|
||||
|
||||
@_spi(a) public let a: SPIInterface1
|
||||
@_spi(a) public let b: SPIInterface2
|
||||
@_spi(a) public let a: SPIInterface1 = .init()
|
||||
@_spi(a) public let b: SPIInterface2 = .init()
|
||||
|
||||
public let c: SPIInterface1 // expected-error{{cannot use class 'SPIInterface1' here; it is an SPI imported from 'SPIContainer'}}
|
||||
public let d: SPIInterface2 // expected-error{{cannot use class 'SPIInterface2' here; it is an SPI imported from 'SPIContainer'}}
|
||||
public let c: SPIInterface1 = .init() // expected-error{{cannot use class 'SPIInterface1' here; it is an SPI imported from 'SPIContainer'}}
|
||||
public let d: SPIInterface2 = .init() // expected-error{{cannot use class 'SPIInterface2' here; it is an SPI imported from 'SPIContainer'}}
|
||||
|
||||
@inlinable
|
||||
public func inlinableUsingSPI() { // expected-warning{{public declarations should have an availability attribute with an introduction version}}
|
||||
public func inlinableUsingSPI() {
|
||||
SharedInterface.foo() // expected-error{{class method 'foo()' cannot be used in an '@inlinable' function because it is an SPI imported from 'SPIContainer'}}
|
||||
}
|
||||
|
||||
@available(macOS, unavailable)
|
||||
public let e: SPIInterface2
|
||||
public let e: SPIInterface2 = .init()
|
||||
|
||||
@available(iOS, unavailable)
|
||||
public let f: SPIInterface2 // expected-error{{cannot use class 'SPIInterface2' here; it is an SPI imported from 'SPIContainer'}}
|
||||
public let f: SPIInterface2 = .init() // expected-error{{cannot use class 'SPIInterface2' here; it is an SPI imported from 'SPIContainer'}}
|
||||
|
||||
@inlinable
|
||||
@available(macOS, unavailable)
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
// REQUIRES: OS=macosx
|
||||
|
||||
// RUN: %target-swift-frontend -typecheck %s -F %S/Inputs/frameworks -verify -DNOT_UNDERLYING
|
||||
// RUN: %target-swift-frontend -typecheck %s -F %S/Inputs/frameworks -verify -DNOT_UNDERLYING -library-level spi
|
||||
// RUN: %target-swift-frontend -typecheck %s -F %S/Inputs/frameworks -verify -DNOT_UNDERLYING -parse-as-library -require-explicit-availability=ignore
|
||||
// RUN: %target-swift-frontend -typecheck %s -F %S/Inputs/frameworks -verify -DNOT_UNDERLYING -library-level spi -parse-as-library -require-explicit-availability=ignore
|
||||
|
||||
// RUN: %target-swift-frontend -typecheck %s -F %S/Inputs/frameworks -module-name SPIContainer -import-underlying-module -verify
|
||||
// RUN: %target-swift-frontend -typecheck %s -F %S/Inputs/frameworks -module-name SPIContainer -import-underlying-module -verify -library-level spi
|
||||
// RUN: %target-swift-frontend -typecheck %s -F %S/Inputs/frameworks -module-name SPIContainer -import-underlying-module -verify -parse-as-library -require-explicit-availability=ignore
|
||||
// RUN: %target-swift-frontend -typecheck %s -F %S/Inputs/frameworks -module-name SPIContainer -import-underlying-module -verify -library-level spi -parse-as-library -require-explicit-availability=ignore
|
||||
|
||||
|
||||
#if NOT_UNDERLYING
|
||||
import SPIContainer
|
||||
#endif
|
||||
|
||||
@_spi(a) public let a: SPIInterface1
|
||||
@_spi(a) public let b: SPIInterface2
|
||||
@_spi(a) public let a: SPIInterface1 = .init()
|
||||
@_spi(a) public let b: SPIInterface2 = .init()
|
||||
|
||||
public let c: SPIInterface1
|
||||
public let d: SPIInterface2
|
||||
public let c: SPIInterface1 = .init()
|
||||
public let d: SPIInterface2 = .init()
|
||||
|
||||
@inlinable
|
||||
public func inlinableUsingSPI() {
|
||||
@@ -23,10 +23,10 @@ public func inlinableUsingSPI() {
|
||||
}
|
||||
|
||||
@available(macOS, unavailable)
|
||||
public let e: SPIInterface2
|
||||
public let e: SPIInterface2 = .init()
|
||||
|
||||
@available(iOS, unavailable)
|
||||
public let f: SPIInterface2
|
||||
public let f: SPIInterface2 = .init()
|
||||
|
||||
@inlinable
|
||||
@available(macOS, unavailable)
|
||||
|
||||
@@ -5,10 +5,12 @@
|
||||
// REQUIRES: CPU=x86_64
|
||||
// UNSUPPORTED: use_os_stdlib
|
||||
|
||||
@available(macOS 11, *)
|
||||
public struct Float16Wrapper {
|
||||
@available(macOS, unavailable)
|
||||
var x: Float16
|
||||
@inline(never)
|
||||
func blackHole<T>(_ t: T.Type) {}
|
||||
|
||||
@available(macOS, unavailable)
|
||||
public func useFloat16() {
|
||||
blackHole(Float16.self)
|
||||
}
|
||||
|
||||
// CHECK-LABEL: @"$ss7Float16VMn" = extern_weak global %swift.type_descriptor
|
||||
// CHECK-LABEL: @"$ss7Float16VN" = extern_weak global %swift.type
|
||||
|
||||
@@ -10,7 +10,11 @@ public class AvailableClass<T> {
|
||||
// CHECK-STRIP-NOT: s4Test14AvailableClassC19unavailablePropertyxvs
|
||||
// CHECK-STRIP-NOT: s4Test14AvailableClassC19unavailablePropertyxvM
|
||||
@available(*, unavailable)
|
||||
public var unavailableProperty: T
|
||||
public var unavailableProperty: T {
|
||||
get { fatalError() }
|
||||
set { fatalError() }
|
||||
_modify { fatalError() }
|
||||
}
|
||||
|
||||
// CHECK-NO-STRIP: s4Test14AvailableClassCyACyxGxcfC
|
||||
// CHECK-NO-STRIP: s4Test14AvailableClassCyACyxGxcfc
|
||||
|
||||
@@ -15,7 +15,11 @@ public struct AvailableStruct<T> {
|
||||
// CHECK-STRIP-NOT: s4Test15AvailableStructV19unavailablePropertyxvs
|
||||
// CHECK-STRIP-NOT: s4Test15AvailableStructV19unavailablePropertyxvM
|
||||
@available(*, unavailable)
|
||||
public var unavailableProperty: T
|
||||
public var unavailableProperty: T {
|
||||
get { fatalError() }
|
||||
set { fatalError() }
|
||||
_modify { fatalError() }
|
||||
}
|
||||
|
||||
// CHECK-NO-STRIP: s4Test15AvailableStructVyACyxGxcfC
|
||||
// CHECK-STRIP-NOT: s4Test15AvailableStructVyACyxGxcfC
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: not %target-swift-frontend -typecheck -update-code -primary-file %s -emit-migrated-file-path %t/double_fixit_ok.result -swift-version 4
|
||||
// RUN: not %target-swift-frontend -typecheck -update-code -primary-file %s -emit-migrated-file-path %t/double_fixit_ok.result -swift-version 4 -parse-as-library
|
||||
// RUN: %diff -u %s.expected %t/double_fixit_ok.result
|
||||
// RUN: %target-swift-frontend -typecheck %s.expected -swift-version 5
|
||||
// RUN: %target-swift-frontend -typecheck %s.expected -swift-version 5 -parse-as-library
|
||||
|
||||
@available(swift, obsoleted: 4, renamed: "Thing.constant___renamed")
|
||||
let ThingConstantGotRenamed = 1
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: not %target-swift-frontend -typecheck -update-code -primary-file %s -emit-migrated-file-path %t/double_fixit_ok.result -swift-version 4
|
||||
// RUN: not %target-swift-frontend -typecheck -update-code -primary-file %s -emit-migrated-file-path %t/double_fixit_ok.result -swift-version 4 -parse-as-library
|
||||
// RUN: %diff -u %s.expected %t/double_fixit_ok.result
|
||||
// RUN: %target-swift-frontend -typecheck %s.expected -swift-version 5
|
||||
// RUN: %target-swift-frontend -typecheck %s.expected -swift-version 5 -parse-as-library
|
||||
|
||||
@available(swift, obsoleted: 4, renamed: "Thing.constant___renamed")
|
||||
let ThingConstantGotRenamed = 1
|
||||
|
||||
@@ -88,7 +88,11 @@ public struct S<T> {
|
||||
// CHECK-STRIP-NOT: s4Test1SV19unavailablePropertyxvs
|
||||
// CHECK-STRIP-NOT: s4Test1SV19unavailablePropertyxvM
|
||||
@available(*, unavailable)
|
||||
public var unavailableProperty: T
|
||||
public var unavailableProperty: T {
|
||||
get { fatalError() }
|
||||
set { fatalError() }
|
||||
_modify { fatalError() }
|
||||
}
|
||||
|
||||
// CHECK-NO-STRIP: s4Test1SVyACyxGxcfC
|
||||
// CHECK-STRIP-NOT: s4Test1SVyACyxGxcfC
|
||||
@@ -128,7 +132,11 @@ public class C<T> {
|
||||
// CHECK-STRIP-NOT: s4Test1CC19unavailablePropertyxvs
|
||||
// CHECK-STRIP-NOT: s4Test1CC19unavailablePropertyxvM
|
||||
@available(*, unavailable)
|
||||
public var unavailableProperty: T
|
||||
public var unavailableProperty: T {
|
||||
get { fatalError() }
|
||||
set { fatalError() }
|
||||
_modify { fatalError() }
|
||||
}
|
||||
|
||||
// CHECK-NO-STRIP: s4Test1CCyACyxGxcfC
|
||||
// CHECK-NO-STRIP: s4Test1CCyACyxGxcfc
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %target-typecheck-verify-swift -module-name MyModule
|
||||
// RUN: %target-typecheck-verify-swift -parse-as-library -module-name MyModule
|
||||
|
||||
// REQUIRES: OS=macosx
|
||||
|
||||
@@ -175,7 +175,10 @@ func testPlatforms() {
|
||||
|
||||
struct VarToFunc {
|
||||
@available(*, unavailable, renamed: "function()")
|
||||
var variable: Int // expected-note 2 {{explicitly marked unavailable here}}
|
||||
var variable: Int { // expected-note 2 {{explicitly marked unavailable here}}
|
||||
get { 0 }
|
||||
set {}
|
||||
}
|
||||
|
||||
@available(*, unavailable, renamed: "function()")
|
||||
func oldFunction() -> Int { return 42 } // expected-note 2 {{explicitly marked unavailable here}}
|
||||
|
||||
@@ -136,7 +136,10 @@ func testButtNested(x: inout Butt.Nested) { // expected-error {{'Nested' is unav
|
||||
extension Butt {
|
||||
struct NestedInSPIAvailableExtension {
|
||||
@available(macOS, unavailable)
|
||||
public var unavailable: Int // expected-note {{'unavailable' has been explicitly marked unavailable here}}
|
||||
public var unavailable: Int {// expected-note {{'unavailable' has been explicitly marked unavailable here}}
|
||||
get { 0 }
|
||||
set {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -52,8 +52,6 @@ public struct fixedLayoutStruct {
|
||||
public var a = 1
|
||||
private var b = 2 { didSet {} willSet(value) {} }
|
||||
var c = 3
|
||||
@available(*, unavailable)
|
||||
public let unavailableProperty = 1
|
||||
}
|
||||
|
||||
extension Int: P1 { public func bar() {} }
|
||||
|
||||
@@ -920,55 +920,6 @@
|
||||
],
|
||||
"fixedbinaryorder": 2,
|
||||
"hasStorage": true
|
||||
},
|
||||
{
|
||||
"kind": "Var",
|
||||
"name": "unavailableProperty",
|
||||
"printedName": "unavailableProperty",
|
||||
"children": [
|
||||
{
|
||||
"kind": "TypeNominal",
|
||||
"name": "Int",
|
||||
"printedName": "Swift.Int",
|
||||
"usr": "s:Si"
|
||||
}
|
||||
],
|
||||
"declKind": "Var",
|
||||
"usr": "s:4cake17fixedLayoutStructV19unavailablePropertySivp",
|
||||
"mangledName": "$s4cake17fixedLayoutStructV19unavailablePropertySivp",
|
||||
"moduleName": "cake",
|
||||
"declAttributes": [
|
||||
"HasInitialValue",
|
||||
"Available",
|
||||
"HasStorage"
|
||||
],
|
||||
"fixedbinaryorder": 3,
|
||||
"isLet": true,
|
||||
"hasStorage": true,
|
||||
"accessors": [
|
||||
{
|
||||
"kind": "Accessor",
|
||||
"name": "Get",
|
||||
"printedName": "Get()",
|
||||
"children": [
|
||||
{
|
||||
"kind": "TypeNominal",
|
||||
"name": "Int",
|
||||
"printedName": "Swift.Int",
|
||||
"usr": "s:Si"
|
||||
}
|
||||
],
|
||||
"declKind": "Accessor",
|
||||
"usr": "s:4cake17fixedLayoutStructV19unavailablePropertySivg",
|
||||
"mangledName": "$s4cake17fixedLayoutStructV19unavailablePropertySivg",
|
||||
"moduleName": "cake",
|
||||
"implicit": true,
|
||||
"declAttributes": [
|
||||
"Transparent"
|
||||
],
|
||||
"accessorKind": "get"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"declKind": "Struct",
|
||||
|
||||
@@ -54,46 +54,43 @@ var osx_extension_inner_init_osx = { let inner_var = osx() } // expected-error {
|
||||
|
||||
struct Outer {
|
||||
@available(OSX, unavailable)
|
||||
var osx_init_osx = osx() // OK
|
||||
|
||||
@available(OSX, unavailable)
|
||||
lazy var osx_lazy_osx = osx() // OK
|
||||
static var osx_init_osx = osx() // OK
|
||||
|
||||
@available(OSXApplicationExtension, unavailable)
|
||||
var osx_extension_init_osx = osx() // expected-error {{'osx()' is unavailable}}
|
||||
static var osx_extension_init_osx = osx() // expected-error {{'osx()' is unavailable}}
|
||||
|
||||
@available(OSXApplicationExtension, unavailable)
|
||||
var osx_extension_lazy_osx = osx() // expected-error {{'osx()' is unavailable}}
|
||||
static var osx_extension_lazy_osx = osx() // expected-error {{'osx()' is unavailable}}
|
||||
|
||||
@available(OSX, unavailable)
|
||||
var osx_init_multi1_osx = osx(), osx_init_multi2_osx = osx() // OK
|
||||
static var osx_init_multi1_osx = osx(), osx_init_multi2_osx = osx() // OK
|
||||
|
||||
@available(OSXApplicationExtension, unavailable)
|
||||
var osx_extension_init_multi1_osx = osx(), osx_extension_init_multi2_osx = osx() // expected-error 2 {{'osx()' is unavailable}}
|
||||
static var osx_extension_init_multi1_osx = osx(), osx_extension_init_multi2_osx = osx() // expected-error 2 {{'osx()' is unavailable}}
|
||||
|
||||
@available(OSX, unavailable)
|
||||
var (osx_init_deconstruct1_osx, osx_init_deconstruct2_osx) = osx_pair() // OK
|
||||
static var (osx_init_deconstruct1_osx, osx_init_deconstruct2_osx) = osx_pair() // OK
|
||||
|
||||
@available(OSXApplicationExtension, unavailable)
|
||||
var (osx_extension_init_deconstruct1_osx, osx_extension_init_deconstruct2_osx) = osx_pair() // expected-error {{'osx_pair()' is unavailable}}
|
||||
static var (osx_extension_init_deconstruct1_osx, osx_extension_init_deconstruct2_osx) = osx_pair() // expected-error {{'osx_pair()' is unavailable}}
|
||||
|
||||
@available(OSX, unavailable)
|
||||
var (_, osx_init_deconstruct2_only_osx) = osx_pair() // OK
|
||||
static var (_, osx_init_deconstruct2_only_osx) = osx_pair() // OK
|
||||
|
||||
@available(OSXApplicationExtension, unavailable)
|
||||
var (_, osx_extension_init_deconstruct2_only_osx) = osx_pair() // expected-error {{'osx_pair()' is unavailable}}
|
||||
static var (_, osx_extension_init_deconstruct2_only_osx) = osx_pair() // expected-error {{'osx_pair()' is unavailable}}
|
||||
|
||||
@available(OSX, unavailable)
|
||||
var (osx_init_deconstruct1_only_osx, _) = osx_pair() // OK
|
||||
static var (osx_init_deconstruct1_only_osx, _) = osx_pair() // OK
|
||||
|
||||
@available(OSXApplicationExtension, unavailable)
|
||||
var (osx_extension_init_deconstruct1_only_osx, _) = osx_pair() // expected-error {{'osx_pair()' is unavailable}}
|
||||
static var (osx_extension_init_deconstruct1_only_osx, _) = osx_pair() // expected-error {{'osx_pair()' is unavailable}}
|
||||
|
||||
@available(OSX, unavailable)
|
||||
var osx_inner_init_osx = { let inner_var = osx() } // OK
|
||||
static var osx_inner_init_osx = { let inner_var = osx() } // OK
|
||||
|
||||
@available(OSXApplicationExtension, unavailable)
|
||||
var osx_extension_inner_init_osx = { let inner_var = osx() } // expected-error {{'osx()' is unavailable}}
|
||||
static var osx_extension_inner_init_osx = { let inner_var = osx() } // expected-error {{'osx()' is unavailable}}
|
||||
}
|
||||
|
||||
extension Outer {
|
||||
|
||||
@@ -46,7 +46,7 @@ struct C<T> { // expected-note 4 {{'T' declared as parameter to type 'C'}}
|
||||
|
||||
struct Unavailable {
|
||||
@available(*, unavailable)
|
||||
var unavailableProperty: Int
|
||||
var unavailableProperty: Int { 0 }
|
||||
// expected-note@-1 {{'unavailableProperty' has been explicitly marked unavailable here}}
|
||||
|
||||
@available(*, unavailable)
|
||||
|
||||
Reference in New Issue
Block a user