Files
swift-mirror/test/Constraints/rdar85263844_swift6.swift
Henrik G. Olsson cbc0ec3b88 Add -verify-ignore-unrelated where necessary (NFC)
These are tests that fail in the next commit without this flag. This
does not add -verify-ignore-unrelated to all tests with -verify, only
the ones that would fail without it. This is NFC since this flag is
currently a no-op.
2025-10-04 14:19:52 -07:00

34 lines
1.3 KiB
Swift

// RUN: %target-typecheck-verify-swift -verify-ignore-unrelated -swift-version 6
// rdar://85263844 - initializer 'init(_:)' requires the types be equivalent
func rdar85263844(arr: [(q: String, a: Int)]) -> AnySequence<(question: String, answer: Int)> {
AnySequence(arr.map { $0 })
// expected-error@-1 {{initializer 'init(_:)' requires the types '(question: String, answer: Int)' and '(q: String, a: Int)' be equivalent}}
}
// Another case for rdar://85263844
protocol P {
associatedtype Element
}
extension Array : P {}
public struct S4<T> {
init<S : P>(_ x: S) where S.Element == T {}
init(_ x: Int) {}
}
extension S4 where T == (outer: Int, y: Int) {
init(arr: [Int]) {
// FIXME: This ideally shouldn't compile either, but because of the way we
// generate constraints for it, it continues to compile. We should fix
// tuple subtyping for Swift 6 mode to not accept label mismatches.
self.init(arr.map { (inner: $0, y: $0) })
// expected-warning@-1 {{tuple conversion from '(inner: Int, y: Int)' to '(outer: Int, y: Int)' mismatches labels}}
}
}
public func rdar85263844_2(_ x: [Int]) -> S4<(outer: Int, y: Int)> {
// FIXME: Bad error message.
S4(x.map { (inner: $0, y: $0) }) // expected-error {{failed to produce diagnostic for expression}}
}