Skip to content

Commit 09bf38c

Browse files
committed
Add a test for the SIL type equality assert failures due to opaque return types
This is the test part of #70865 which was fixed by the commit 8d649a2
1 parent 3ed0932 commit 09bf38c

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
public protocol Reducer<State> {
2+
associatedtype State
3+
}
4+
5+
public class WindowData {}
6+
7+
public struct CR<State, R: Reducer>: Reducer
8+
where State == R.State {
9+
}
10+
11+
internal struct SidebarContextMenu<WindowState: WindowData>: Reducer {
12+
typealias State = WindowState
13+
}
14+
15+
public protocol Factory {
16+
associatedtype X: Reducer<WindowData>
17+
func build() -> X
18+
}
19+
20+
public struct MyFactory<WindowState: WindowData>: Factory {
21+
public typealias State = WindowData
22+
public init() {}
23+
public func build() -> some Reducer<WindowData> {
24+
CR<WindowData, SidebarContextMenu<WindowData>>()
25+
}
26+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-swift-frontend -swift-version 5 -disable-availability-checking -c %S/Inputs/opaque_return_type_equality_input.swift -emit-module-path %t/opaque_return_type_equality_input.swiftmodule -I %t -O -module-name opaque_return_type_equality_input -o %t/opaque_return_type_equality_input.o
3+
// RUN: %target-swift-frontend -swift-version 5 -disable-availability-checking -c %S/opaque_return_type_equality.swift -emit-module-path %t/opaque_return_type_equality.swiftmodule -I %t -O -module-name opaque_return_type_equality -o %t/opaque_return_type_equality.o
4+
5+
// Check that the SIL type equality check asserts don't fail between the opaque return types and their underlying types.
6+
7+
import opaque_return_type_equality_input
8+
9+
public func build<F: Factory>(f: F) -> any Reducer<WindowData> {
10+
return f.build()
11+
}
12+
13+
build(f: MyFactory())

0 commit comments

Comments
 (0)