Skip to content

Add a test for the SIL type equality assert failures due to opaque re… #71187

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
public protocol Reducer<State> {
associatedtype State
}

public class WindowData {}

public struct CR<State, R: Reducer>: Reducer
where State == R.State {
}

internal struct SidebarContextMenu<WindowState: WindowData>: Reducer {
typealias State = WindowState
}

public protocol Factory {
associatedtype X: Reducer<WindowData>
func build() -> X
}

public struct MyFactory<WindowState: WindowData>: Factory {
public typealias State = WindowData
public init() {}
public func build() -> some Reducer<WindowData> {
CR<WindowData, SidebarContextMenu<WindowData>>()
}
}
13 changes: 13 additions & 0 deletions test/SIL/Serialization/opaque_return_type_equality.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// RUN: %empty-directory(%t)
// 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
// 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

// Check that the SIL type equality check asserts don't fail between the opaque return types and their underlying types.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this not require an additional flag to be passed? Something along the lines of -enable-sil-verify-all or -sil-verify-all.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was able to trigger the assert failure without one.


import opaque_return_type_equality_input

public func build<F: Factory>(f: F) -> any Reducer<WindowData> {
return f.build()
}

build(f: MyFactory())