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}}

0 commit comments

Comments
 (0)