Files
swift-mirror/validation-test/compiler_crashers_2_fixed/issue-57241.swift
Pavel Yaskevich e3b1f341f0 [CSDiagnostics] Adjust conformance failure diagnostic to check for locatable types
If conformance failure is associated with a `LocatableType`, use
its location to anchor the failure.
2024-11-21 14:13:16 -08:00

33 lines
974 B
Swift

// RUN: %target-swift-frontend -typecheck -verify %s
// https://github.com/apple/swift/issues/57241
struct S {
private let data: [[String]]
private func f() {}
func test() {
ForEach(data) { group in
ForEach(group) { month in
self.f()
// expected-error@-1 {{type '()' cannot conform to 'View'}}
// expected-note@-2 {{only concrete types such as structs, enums and classes can conform to protocols}}
}
}
}
}
struct Wrapper<T> {}
protocol View {}
@resultBuilder struct Builder {
// expected-note@+1 {{required by static method 'buildBlock' where 'Content' = '()'}}
static func buildBlock<Content: View>(_ content: Content) -> Content { fatalError() }
}
struct ForEach<Data, Content> where Data : RandomAccessCollection {
init<C>(_ data: Wrapper<C>, @Builder content: (Wrapper<C.Element>) -> Content) where C : MutableCollection {}
init(_ data: Data, @Builder content: @escaping (Data.Element) -> Content) {}
}