Files
swift-mirror/test/Generics/unavailable_conformances.swift
Slava Pestov bd46bdaaaa AST: Narrow the filtering of unavailable conformances to Sendable only
Remove the allowUnavailable parameter to lookupConformance(), and instead
explicitly check the result for hasUnavailableConformance() in the places
where we used to pass 'false'.

Also, narrow down this check in those places to the Sendable protocol
only, fixing a regression with Hashable conformance synthesis.

Fixes rdar://problem/94460143.
2022-06-14 21:24:08 -04:00

53 lines
1.1 KiB
Swift

// RUN: %target-typecheck-verify-swift
protocol P { }
struct X { }
@available(*, unavailable)
extension X: P { }
struct Y<T: P> { }
@available(*, unavailable)
extension Y {
// Okay, because the unavailable conformance is used within an
// unavailable context.
init() where T == X { }
}
// A more elaborate setup that hits the conformance check in property map
// construction rather than concrete contraction.
protocol AssocP {}
@available(*, unavailable)
struct ConcreteP {}
@available(*, unavailable)
extension ConcreteP: AssocP {}
protocol Base {
associatedtype T : AssocP
}
@available(*, unavailable)
extension Base where T == ConcreteP {}
// Hashable conformance synthesis ran into problems if the conformance was
// unavailable (which is legal if the type is unavailable also).
@available(*, unavailable)
struct Foo {
class Bar {}
}
@available(*, unavailable)
extension Foo.Bar: Equatable {
static func == (lhs: Foo.Bar, rhs: Foo.Bar) -> Bool { return false }
}
@available(*, unavailable)
extension Foo.Bar: Hashable {
func hash(into hasher: inout Hasher) {}
}