Skip to content

Commit e34196d

Browse files
committed
Fix tests that depended on availability for lazy vars.
1 parent 093b8d3 commit e34196d

File tree

2 files changed

+11
-27
lines changed

2 files changed

+11
-27
lines changed

test/Sema/availability_versions.swift

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ class ClassWithUnavailableProperties {
324324
@available(OSX, introduced: 10.9)
325325
lazy var availableOn10_9Stored: Int = 9
326326

327-
@available(OSX, introduced: 10.51)
327+
@available(OSX, introduced: 10.51) // expected-error {{stored properties cannot be marked potentially unavailable with '@available'}}
328328
lazy var availableOn10_51Stored : Int = 10
329329

330330
@available(OSX, introduced: 10.9)
@@ -418,7 +418,6 @@ class ClassWithReferencesInInitializers {
418418
lazy var lazyPropWithInitializer10_51: Int = globalFuncAvailableOn10_51()
419419

420420
lazy var lazyPropWithInitializer10_52: Int = globalFuncAvailableOn10_52() // expected-error {{'globalFuncAvailableOn10_52()' is only available in macOS 10.52 or newer}}
421-
// expected-note@-1 {{add @available attribute to enclosing property}}
422421
}
423422

424423
func accessUnavailableProperties(_ o: ClassWithUnavailableProperties) {
@@ -716,21 +715,9 @@ class ClassWithDeclarationsOfUnavailableClasses {
716715
// expected-note@-1 5{{add @available attribute to enclosing class}}
717716

718717
@available(OSX, introduced: 10.51)
719-
init() {
720-
unavailablePropertyOfUnavailableType = ClassAvailableOn10_51()
721-
unavailablePropertyOfUnavailableType = ClassAvailableOn10_51()
722-
}
718+
init() {}
723719

724720
var propertyOfUnavailableType: ClassAvailableOn10_51 // expected-error {{'ClassAvailableOn10_51' is only available in macOS 10.51 or newer}}
725-
726-
@available(OSX, introduced: 10.51)
727-
lazy var unavailablePropertyOfUnavailableType: ClassAvailableOn10_51 = ClassAvailableOn10_51()
728-
729-
@available(OSX, introduced: 10.51)
730-
lazy var unavailablePropertyOfOptionalUnavailableType: ClassAvailableOn10_51? = nil
731-
732-
@available(OSX, introduced: 10.51)
733-
lazy var unavailablePropertyOfUnavailableTypeWithInitializer: ClassAvailableOn10_51 = ClassAvailableOn10_51()
734721

735722
@available(OSX, introduced: 10.51)
736723
static var unavailableStaticPropertyOfUnavailableType: ClassAvailableOn10_51 = ClassAvailableOn10_51()
@@ -1294,15 +1281,12 @@ class ClassForFixit {
12941281

12951282
lazy var fixitForReferenceInLazyPropertyType: ClassAvailableOn10_51? = nil
12961283
// expected-error@-1 {{'ClassAvailableOn10_51' is only available in macOS 10.51 or newer}}
1297-
// expected-note@-2 {{add @available attribute to enclosing property}} {{3-3=@available(macOS 10.51, *)\n }}
12981284

12991285
private lazy var fixitForReferenceInPrivateLazyPropertyType: ClassAvailableOn10_51? = nil
13001286
// expected-error@-1 {{'ClassAvailableOn10_51' is only available in macOS 10.51 or newer}}
1301-
// expected-note@-2 {{add @available attribute to enclosing property}} {{3-3=@available(macOS 10.51, *)\n }}
13021287

13031288
lazy private var fixitForReferenceInLazyPrivatePropertyType: ClassAvailableOn10_51? = nil
13041289
// expected-error@-1 {{'ClassAvailableOn10_51' is only available in macOS 10.51 or newer}}
1305-
// expected-note@-2 {{add @available attribute to enclosing property}} {{3-3=@available(macOS 10.51, *)\n }}
13061290

13071291
static var fixitForReferenceInStaticPropertyType: ClassAvailableOn10_51? = nil
13081292
// expected-error@-1 {{'ClassAvailableOn10_51' is only available in macOS 10.51 or newer}}

test/stdlib/CodableTests.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ class TestCodable : TestCodableSuper {
434434

435435
// MARK: - DateInterval
436436
@available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *)
437-
lazy var dateIntervalValues: [Int : DateInterval] = [
437+
static let dateIntervalValues: [Int : DateInterval] = [
438438
#line : DateInterval(),
439439
#line : DateInterval(start: Date.distantPast, end: Date()),
440440
#line : DateInterval(start: Date(), end: Date.distantFuture),
@@ -443,14 +443,14 @@ class TestCodable : TestCodableSuper {
443443

444444
@available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *)
445445
func test_DateInterval_JSON() {
446-
for (testLine, interval) in dateIntervalValues {
446+
for (testLine, interval) in Self.dateIntervalValues {
447447
expectRoundTripEqualityThroughJSON(for: interval, lineNumber: testLine)
448448
}
449449
}
450450

451451
@available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *)
452452
func test_DateInterval_Plist() {
453-
for (testLine, interval) in dateIntervalValues {
453+
for (testLine, interval) in Self.dateIntervalValues {
454454
expectRoundTripEqualityThroughPlist(for: interval, lineNumber: testLine)
455455
}
456456
}
@@ -641,15 +641,15 @@ class TestCodable : TestCodableSuper {
641641

642642
// MARK: - Measurement
643643
@available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *)
644-
lazy var unitValues: [Int : Dimension] = [
644+
static let unitValues: [Int : Dimension] = [
645645
#line : UnitAcceleration.metersPerSecondSquared,
646646
#line : UnitMass.kilograms,
647647
#line : UnitLength.miles
648648
]
649649

650650
@available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *)
651651
func test_Measurement_JSON() {
652-
for (testLine, unit) in unitValues {
652+
for (testLine, unit) in Self.unitValues {
653653
// FIXME: <rdar://problem/49026133>
654654
// Terminating due to uncaught exception NSInvalidArgumentException:
655655
// *** You must override baseUnit in your class NSDimension to define its base unit.
@@ -660,7 +660,7 @@ class TestCodable : TestCodableSuper {
660660

661661
@available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *)
662662
func test_Measurement_Plist() {
663-
for (testLine, unit) in unitValues {
663+
for (testLine, unit) in Self.unitValues {
664664
// FIXME: <rdar://problem/49026133>
665665
// Terminating due to uncaught exception NSInvalidArgumentException:
666666
// *** You must override baseUnit in your class NSDimension to define its base unit.
@@ -741,22 +741,22 @@ class TestCodable : TestCodableSuper {
741741

742742
// MARK: - PersonNameComponents
743743
@available(macOS 10.11, iOS 9.0, watchOS 2.0, tvOS 9.0, *)
744-
lazy var personNameComponentsValues: [Int : PersonNameComponents] = [
744+
static let personNameComponentsValues: [Int : PersonNameComponents] = [
745745
#line : makePersonNameComponents(givenName: "John", familyName: "Appleseed"),
746746
#line : makePersonNameComponents(givenName: "John", familyName: "Appleseed", nickname: "Johnny"),
747747
#line : makePersonNameComponents(namePrefix: "Dr.", givenName: "Jane", middleName: "A.", familyName: "Appleseed", nameSuffix: "Esq.", nickname: "Janie")
748748
]
749749

750750
@available(macOS 10.11, iOS 9.0, watchOS 2.0, tvOS 9.0, *)
751751
func test_PersonNameComponents_JSON() {
752-
for (testLine, components) in personNameComponentsValues {
752+
for (testLine, components) in Self.personNameComponentsValues {
753753
expectRoundTripEqualityThroughJSON(for: components, lineNumber: testLine)
754754
}
755755
}
756756

757757
@available(macOS 10.11, iOS 9.0, watchOS 2.0, tvOS 9.0, *)
758758
func test_PersonNameComponents_Plist() {
759-
for (testLine, components) in personNameComponentsValues {
759+
for (testLine, components) in Self.personNameComponentsValues {
760760
expectRoundTripEqualityThroughPlist(for: components, lineNumber: testLine)
761761
}
762762
}

0 commit comments

Comments
 (0)