Skip to content

Commit c823974

Browse files
committed
Fix add_conformance evolution tests to pass with optimized builds
Even dynamically casting a generic parameter to a protocol type is only guaranteed to succeed for conformances available at build time. Since we can't express conditional availability of conformances yet, this part of the test is useless, so redo it.
1 parent dee6daf commit c823974

File tree

4 files changed

+26
-34
lines changed

4 files changed

+26
-34
lines changed

validation-test/Evolution/Inputs/struct_fixed_layout_add_conformance.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,11 @@ public protocol Point3DLike {
3838
extension AddConformance : PointLike {}
3939
extension AddConformance : Point3DLike {}
4040
#endif
41+
42+
public func workWithPointLike<T>(t: T) -> Int {
43+
if let p = t as? PointLike {
44+
return p.x * p.y
45+
} else {
46+
return 0
47+
}
48+
}

validation-test/Evolution/Inputs/struct_resilient_add_conformance.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,11 @@ public protocol Point3DLike {
3838
extension AddConformance : PointLike {}
3939
extension AddConformance : Point3DLike {}
4040
#endif
41+
42+
public func workWithPointLike<T>(t: T) -> Int {
43+
if let p = t as? PointLike {
44+
return p.x * p.y
45+
} else {
46+
return 0
47+
}
48+
}

validation-test/Evolution/test_struct_fixed_layout_add_conformance.swift

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,12 @@
2020
// RUN: %target-run %t/after_after
2121

2222
// REQUIRES: executable_test
23-
// REQUIRES: swift_test_mode_optimize_none
2423

2524
import StdlibUnittest
2625
import struct_fixed_layout_add_conformance
2726

2827
var StructFixedLayoutAddConformanceTest = TestSuite("StructFixedLayoutAddConformance")
2928

30-
// FIXME: Once we have availability information for conformances, we can
31-
// make this non-generic as long as we're careful to never directly
32-
// reference an unavailable conformance table symbol
33-
@inline(never) func workWithPointLike<T>(t: T) {
34-
if getVersion() > 0 {
35-
var p = t as! PointLike
36-
p.x = 30
37-
p.y = 40
38-
expectEqual(p.x, 30)
39-
expectEqual(p.y, 40)
40-
} else {
41-
expectEqual(t is PointLike, false)
42-
}
43-
}
44-
4529
StructFixedLayoutAddConformanceTest.test("AddConformance") {
4630
var t = AddConformance()
4731

@@ -52,7 +36,11 @@ StructFixedLayoutAddConformanceTest.test("AddConformance") {
5236
expectEqual(t.y, 20)
5337
}
5438

55-
workWithPointLike(t)
39+
if (getVersion() == 0) {
40+
expectEqual(workWithPointLike(t), 0)
41+
} else {
42+
expectEqual(workWithPointLike(t), 200)
43+
}
5644
}
5745

5846
#if AFTER

validation-test/Evolution/test_struct_resilient_add_conformance.swift

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,12 @@
2020
// RUN: %target-run %t/after_after
2121

2222
// REQUIRES: executable_test
23-
// REQUIRES: swift_test_mode_optimize_none
2423

2524
import StdlibUnittest
2625
import struct_resilient_add_conformance
2726

2827
var StructResilientAddConformanceTest = TestSuite("StructResilientAddConformance")
2928

30-
// FIXME: Once we have availability information for conformances, we can
31-
// make this non-generic as long as we're careful to never directly
32-
// reference an unavailable conformance table symbol
33-
@inline(never) func workWithPointLike<T>(t: T) {
34-
if getVersion() > 0 {
35-
var p = t as! PointLike
36-
p.x = 30
37-
p.y = 40
38-
expectEqual(p.x, 30)
39-
expectEqual(p.y, 40)
40-
} else {
41-
expectEqual(t is PointLike, false)
42-
}
43-
}
44-
4529
StructResilientAddConformanceTest.test("AddConformance") {
4630
var t = AddConformance()
4731

@@ -52,7 +36,11 @@ StructResilientAddConformanceTest.test("AddConformance") {
5236
expectEqual(t.y, 20)
5337
}
5438

55-
workWithPointLike(t)
39+
if (getVersion() == 0) {
40+
expectEqual(workWithPointLike(t), 0)
41+
} else {
42+
expectEqual(workWithPointLike(t), 200)
43+
}
5644
}
5745

5846
#if AFTER

0 commit comments

Comments
 (0)