Skip to content

Commit 7dc313f

Browse files
committed
NFC: Fix tests that mistakenly rely on unavailable stored properties.
Preparation for rdar://107449845
1 parent 387b73f commit 7dc313f

15 files changed

+75
-103
lines changed

test/ClangImporter/Inputs/frameworks/SPIContainer.framework/Headers/SPIContainer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@
1212

1313
SPI_AVAILABLE(macos(10.7))
1414
@interface SPIInterface1
15+
- (instancetype)init;
1516
@end
1617

1718
__SPI_AVAILABLE(macos(10.7))
1819
@interface SPIInterface2
20+
- (instancetype)init;
1921
@end
2022

2123
@interface SharedInterface

test/ClangImporter/availability_spi_as_unavailable.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
// REQUIRES: OS=macosx
2-
// RUN: %target-swift-frontend -typecheck %s -F %S/Inputs/frameworks -verify -DNOT_UNDERLYING -library-level api
3-
// RUN: %target-swift-frontend -typecheck %s -F %S/Inputs/frameworks -module-name SPIContainer -import-underlying-module -verify -library-level api
2+
// RUN: %target-swift-frontend -typecheck %s -F %S/Inputs/frameworks -verify -DNOT_UNDERLYING -library-level api -parse-as-library -require-explicit-availability=ignore
3+
// 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
44

55
#if NOT_UNDERLYING
66
import SPIContainer
77
#endif
88

9-
@_spi(a) public let a: SPIInterface1
10-
@_spi(a) public let b: SPIInterface2
9+
@_spi(a) public let a: SPIInterface1 = .init()
10+
@_spi(a) public let b: SPIInterface2 = .init()
1111

12-
public let c: SPIInterface1 // expected-error{{cannot use class 'SPIInterface1' here; it is an SPI imported from 'SPIContainer'}}
13-
public let d: SPIInterface2 // expected-error{{cannot use class 'SPIInterface2' here; it is an SPI imported from 'SPIContainer'}}
12+
public let c: SPIInterface1 = .init() // expected-error{{cannot use class 'SPIInterface1' here; it is an SPI imported from 'SPIContainer'}}
13+
public let d: SPIInterface2 = .init() // expected-error{{cannot use class 'SPIInterface2' here; it is an SPI imported from 'SPIContainer'}}
1414

1515
@inlinable
16-
public func inlinableUsingSPI() { // expected-warning{{public declarations should have an availability attribute with an introduction version}}
16+
public func inlinableUsingSPI() {
1717
SharedInterface.foo() // expected-error{{class method 'foo()' cannot be used in an '@inlinable' function because it is an SPI imported from 'SPIContainer'}}
1818
}
1919

2020
@available(macOS, unavailable)
21-
public let e: SPIInterface2
21+
public let e: SPIInterface2 = .init()
2222

2323
@available(iOS, unavailable)
24-
public let f: SPIInterface2 // expected-error{{cannot use class 'SPIInterface2' here; it is an SPI imported from 'SPIContainer'}}
24+
public let f: SPIInterface2 = .init() // expected-error{{cannot use class 'SPIInterface2' here; it is an SPI imported from 'SPIContainer'}}
2525

2626
@inlinable
2727
@available(macOS, unavailable)

test/ClangImporter/availability_spi_library_level_spi.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
// REQUIRES: OS=macosx
22

3-
// RUN: %target-swift-frontend -typecheck %s -F %S/Inputs/frameworks -verify -DNOT_UNDERLYING
4-
// RUN: %target-swift-frontend -typecheck %s -F %S/Inputs/frameworks -verify -DNOT_UNDERLYING -library-level spi
3+
// RUN: %target-swift-frontend -typecheck %s -F %S/Inputs/frameworks -verify -DNOT_UNDERLYING -parse-as-library -require-explicit-availability=ignore
4+
// RUN: %target-swift-frontend -typecheck %s -F %S/Inputs/frameworks -verify -DNOT_UNDERLYING -library-level spi -parse-as-library -require-explicit-availability=ignore
55

6-
// RUN: %target-swift-frontend -typecheck %s -F %S/Inputs/frameworks -module-name SPIContainer -import-underlying-module -verify
7-
// RUN: %target-swift-frontend -typecheck %s -F %S/Inputs/frameworks -module-name SPIContainer -import-underlying-module -verify -library-level spi
6+
// RUN: %target-swift-frontend -typecheck %s -F %S/Inputs/frameworks -module-name SPIContainer -import-underlying-module -verify -parse-as-library -require-explicit-availability=ignore
7+
// 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
88

99

1010
#if NOT_UNDERLYING
1111
import SPIContainer
1212
#endif
1313

14-
@_spi(a) public let a: SPIInterface1
15-
@_spi(a) public let b: SPIInterface2
14+
@_spi(a) public let a: SPIInterface1 = .init()
15+
@_spi(a) public let b: SPIInterface2 = .init()
1616

17-
public let c: SPIInterface1
18-
public let d: SPIInterface2
17+
public let c: SPIInterface1 = .init()
18+
public let d: SPIInterface2 = .init()
1919

2020
@inlinable
2121
public func inlinableUsingSPI() {
2222
SharedInterface.foo()
2323
}
2424

2525
@available(macOS, unavailable)
26-
public let e: SPIInterface2
26+
public let e: SPIInterface2 = .init()
2727

2828
@available(iOS, unavailable)
29-
public let f: SPIInterface2
29+
public let f: SPIInterface2 = .init()
3030

3131
@inlinable
3232
@available(macOS, unavailable)

test/IRGen/float16_macos.swift

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
// REQUIRES: CPU=x86_64
66
// UNSUPPORTED: use_os_stdlib
77

8-
@available(macOS 11, *)
9-
public struct Float16Wrapper {
10-
@available(macOS, unavailable)
11-
var x: Float16
8+
@inline(never)
9+
func blackHole<T>(_ t: T.Type) {}
10+
11+
@available(macOS, unavailable)
12+
public func useFloat16() {
13+
blackHole(Float16.self)
1214
}
1315

14-
// CHECK-LABEL: @"$ss7Float16VMn" = extern_weak global %swift.type_descriptor
16+
// CHECK-LABEL: @"$ss7Float16VN" = extern_weak global %swift.type

test/IRGen/unavailable_decl_optimization_class.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ public class AvailableClass<T> {
1010
// CHECK-STRIP-NOT: s4Test14AvailableClassC19unavailablePropertyxvs
1111
// CHECK-STRIP-NOT: s4Test14AvailableClassC19unavailablePropertyxvM
1212
@available(*, unavailable)
13-
public var unavailableProperty: T
13+
public var unavailableProperty: T {
14+
get { fatalError() }
15+
set { fatalError() }
16+
_modify { fatalError() }
17+
}
1418

1519
// CHECK-NO-STRIP: s4Test14AvailableClassCyACyxGxcfC
1620
// CHECK-NO-STRIP: s4Test14AvailableClassCyACyxGxcfc

test/IRGen/unavailable_decl_optimization_struct.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ public struct AvailableStruct<T> {
1515
// CHECK-STRIP-NOT: s4Test15AvailableStructV19unavailablePropertyxvs
1616
// CHECK-STRIP-NOT: s4Test15AvailableStructV19unavailablePropertyxvM
1717
@available(*, unavailable)
18-
public var unavailableProperty: T
18+
public var unavailableProperty: T {
19+
get { fatalError() }
20+
set { fatalError() }
21+
_modify { fatalError() }
22+
}
1923

2024
// CHECK-NO-STRIP: s4Test15AvailableStructVyACyxGxcfC
2125
// CHECK-STRIP-NOT: s4Test15AvailableStructVyACyxGxcfC

test/Migrator/double_fixit_ok.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %empty-directory(%t)
2-
// RUN: not %target-swift-frontend -typecheck -update-code -primary-file %s -emit-migrated-file-path %t/double_fixit_ok.result -swift-version 4
2+
// 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
33
// RUN: %diff -u %s.expected %t/double_fixit_ok.result
4-
// RUN: %target-swift-frontend -typecheck %s.expected -swift-version 5
4+
// RUN: %target-swift-frontend -typecheck %s.expected -swift-version 5 -parse-as-library
55

66
@available(swift, obsoleted: 4, renamed: "Thing.constant___renamed")
77
let ThingConstantGotRenamed = 1

test/Migrator/double_fixit_ok.swift.expected

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %empty-directory(%t)
2-
// RUN: not %target-swift-frontend -typecheck -update-code -primary-file %s -emit-migrated-file-path %t/double_fixit_ok.result -swift-version 4
2+
// 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
33
// RUN: %diff -u %s.expected %t/double_fixit_ok.result
4-
// RUN: %target-swift-frontend -typecheck %s.expected -swift-version 5
4+
// RUN: %target-swift-frontend -typecheck %s.expected -swift-version 5 -parse-as-library
55

66
@available(swift, obsoleted: 4, renamed: "Thing.constant___renamed")
77
let ThingConstantGotRenamed = 1

test/SILGen/unavailable_decl_optimization.swift

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,11 @@ public struct S<T> {
8888
// CHECK-STRIP-NOT: s4Test1SV19unavailablePropertyxvs
8989
// CHECK-STRIP-NOT: s4Test1SV19unavailablePropertyxvM
9090
@available(*, unavailable)
91-
public var unavailableProperty: T
91+
public var unavailableProperty: T {
92+
get { fatalError() }
93+
set { fatalError() }
94+
_modify { fatalError() }
95+
}
9296

9397
// CHECK-NO-STRIP: s4Test1SVyACyxGxcfC
9498
// CHECK-STRIP-NOT: s4Test1SVyACyxGxcfC
@@ -128,7 +132,11 @@ public class C<T> {
128132
// CHECK-STRIP-NOT: s4Test1CC19unavailablePropertyxvs
129133
// CHECK-STRIP-NOT: s4Test1CC19unavailablePropertyxvM
130134
@available(*, unavailable)
131-
public var unavailableProperty: T
135+
public var unavailableProperty: T {
136+
get { fatalError() }
137+
set { fatalError() }
138+
_modify { fatalError() }
139+
}
132140

133141
// CHECK-NO-STRIP: s4Test1CCyACyxGxcfC
134142
// CHECK-NO-STRIP: s4Test1CCyACyxGxcfc

test/Sema/availability.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-typecheck-verify-swift -module-name MyModule
1+
// RUN: %target-typecheck-verify-swift -parse-as-library -module-name MyModule
22

33
// REQUIRES: OS=macosx
44

@@ -175,7 +175,10 @@ func testPlatforms() {
175175

176176
struct VarToFunc {
177177
@available(*, unavailable, renamed: "function()")
178-
var variable: Int // expected-note 2 {{explicitly marked unavailable here}}
178+
var variable: Int { // expected-note 2 {{explicitly marked unavailable here}}
179+
get { 0 }
180+
set {}
181+
}
179182

180183
@available(*, unavailable, renamed: "function()")
181184
func oldFunction() -> Int { return 42 } // expected-note 2 {{explicitly marked unavailable here}}

test/Sema/generalized_accessors_availability.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,10 @@ func testButtNested(x: inout Butt.Nested) { // expected-error {{'Nested' is unav
136136
extension Butt {
137137
struct NestedInSPIAvailableExtension {
138138
@available(macOS, unavailable)
139-
public var unavailable: Int // expected-note {{'unavailable' has been explicitly marked unavailable here}}
139+
public var unavailable: Int {// expected-note {{'unavailable' has been explicitly marked unavailable here}}
140+
get { 0 }
141+
set {}
142+
}
140143
}
141144
}
142145

test/api-digester/Inputs/cake.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ public struct fixedLayoutStruct {
5252
public var a = 1
5353
private var b = 2 { didSet {} willSet(value) {} }
5454
var c = 3
55-
@available(*, unavailable)
56-
public let unavailableProperty = 1
5755
}
5856

5957
extension Int: P1 { public func bar() {} }

test/api-digester/Outputs/cake-abi.json

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -920,55 +920,6 @@
920920
],
921921
"fixedbinaryorder": 2,
922922
"hasStorage": true
923-
},
924-
{
925-
"kind": "Var",
926-
"name": "unavailableProperty",
927-
"printedName": "unavailableProperty",
928-
"children": [
929-
{
930-
"kind": "TypeNominal",
931-
"name": "Int",
932-
"printedName": "Swift.Int",
933-
"usr": "s:Si"
934-
}
935-
],
936-
"declKind": "Var",
937-
"usr": "s:4cake17fixedLayoutStructV19unavailablePropertySivp",
938-
"mangledName": "$s4cake17fixedLayoutStructV19unavailablePropertySivp",
939-
"moduleName": "cake",
940-
"declAttributes": [
941-
"HasInitialValue",
942-
"Available",
943-
"HasStorage"
944-
],
945-
"fixedbinaryorder": 3,
946-
"isLet": true,
947-
"hasStorage": true,
948-
"accessors": [
949-
{
950-
"kind": "Accessor",
951-
"name": "Get",
952-
"printedName": "Get()",
953-
"children": [
954-
{
955-
"kind": "TypeNominal",
956-
"name": "Int",
957-
"printedName": "Swift.Int",
958-
"usr": "s:Si"
959-
}
960-
],
961-
"declKind": "Accessor",
962-
"usr": "s:4cake17fixedLayoutStructV19unavailablePropertySivg",
963-
"mangledName": "$s4cake17fixedLayoutStructV19unavailablePropertySivg",
964-
"moduleName": "cake",
965-
"implicit": true,
966-
"declAttributes": [
967-
"Transparent"
968-
],
969-
"accessorKind": "get"
970-
}
971-
]
972923
}
973924
],
974925
"declKind": "Struct",

test/attr/attr_availability_transitive_osx.swift

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -54,46 +54,43 @@ var osx_extension_inner_init_osx = { let inner_var = osx() } // expected-error {
5454

5555
struct Outer {
5656
@available(OSX, unavailable)
57-
var osx_init_osx = osx() // OK
58-
59-
@available(OSX, unavailable)
60-
lazy var osx_lazy_osx = osx() // OK
57+
static var osx_init_osx = osx() // OK
6158

6259
@available(OSXApplicationExtension, unavailable)
63-
var osx_extension_init_osx = osx() // expected-error {{'osx()' is unavailable}}
60+
static var osx_extension_init_osx = osx() // expected-error {{'osx()' is unavailable}}
6461

6562
@available(OSXApplicationExtension, unavailable)
66-
var osx_extension_lazy_osx = osx() // expected-error {{'osx()' is unavailable}}
63+
static var osx_extension_lazy_osx = osx() // expected-error {{'osx()' is unavailable}}
6764

6865
@available(OSX, unavailable)
69-
var osx_init_multi1_osx = osx(), osx_init_multi2_osx = osx() // OK
66+
static var osx_init_multi1_osx = osx(), osx_init_multi2_osx = osx() // OK
7067

7168
@available(OSXApplicationExtension, unavailable)
72-
var osx_extension_init_multi1_osx = osx(), osx_extension_init_multi2_osx = osx() // expected-error 2 {{'osx()' is unavailable}}
69+
static var osx_extension_init_multi1_osx = osx(), osx_extension_init_multi2_osx = osx() // expected-error 2 {{'osx()' is unavailable}}
7370

7471
@available(OSX, unavailable)
75-
var (osx_init_deconstruct1_osx, osx_init_deconstruct2_osx) = osx_pair() // OK
72+
static var (osx_init_deconstruct1_osx, osx_init_deconstruct2_osx) = osx_pair() // OK
7673

7774
@available(OSXApplicationExtension, unavailable)
78-
var (osx_extension_init_deconstruct1_osx, osx_extension_init_deconstruct2_osx) = osx_pair() // expected-error {{'osx_pair()' is unavailable}}
75+
static var (osx_extension_init_deconstruct1_osx, osx_extension_init_deconstruct2_osx) = osx_pair() // expected-error {{'osx_pair()' is unavailable}}
7976

8077
@available(OSX, unavailable)
81-
var (_, osx_init_deconstruct2_only_osx) = osx_pair() // OK
78+
static var (_, osx_init_deconstruct2_only_osx) = osx_pair() // OK
8279

8380
@available(OSXApplicationExtension, unavailable)
84-
var (_, osx_extension_init_deconstruct2_only_osx) = osx_pair() // expected-error {{'osx_pair()' is unavailable}}
81+
static var (_, osx_extension_init_deconstruct2_only_osx) = osx_pair() // expected-error {{'osx_pair()' is unavailable}}
8582

8683
@available(OSX, unavailable)
87-
var (osx_init_deconstruct1_only_osx, _) = osx_pair() // OK
84+
static var (osx_init_deconstruct1_only_osx, _) = osx_pair() // OK
8885

8986
@available(OSXApplicationExtension, unavailable)
90-
var (osx_extension_init_deconstruct1_only_osx, _) = osx_pair() // expected-error {{'osx_pair()' is unavailable}}
87+
static var (osx_extension_init_deconstruct1_only_osx, _) = osx_pair() // expected-error {{'osx_pair()' is unavailable}}
9188

9289
@available(OSX, unavailable)
93-
var osx_inner_init_osx = { let inner_var = osx() } // OK
90+
static var osx_inner_init_osx = { let inner_var = osx() } // OK
9491

9592
@available(OSXApplicationExtension, unavailable)
96-
var osx_extension_inner_init_osx = { let inner_var = osx() } // expected-error {{'osx()' is unavailable}}
93+
static var osx_extension_inner_init_osx = { let inner_var = osx() } // expected-error {{'osx()' is unavailable}}
9794
}
9895

9996
extension Outer {

test/expr/unary/keypath/keypath.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ struct C<T> { // expected-note 4 {{'T' declared as parameter to type 'C'}}
4646

4747
struct Unavailable {
4848
@available(*, unavailable)
49-
var unavailableProperty: Int
49+
var unavailableProperty: Int { 0 }
5050
// expected-note@-1 {{'unavailableProperty' has been explicitly marked unavailable here}}
5151

5252
@available(*, unavailable)

0 commit comments

Comments
 (0)