mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
AST: Expand defaults in InheritedProtocolsRequest::evaluate()
This commit is contained in:
@@ -3290,7 +3290,34 @@ InheritedProtocolsRequest::evaluate(Evaluator &evaluator,
|
||||
inherited.insert(proto);
|
||||
}
|
||||
|
||||
// FIXME: Apply inverses
|
||||
// Apply inverses.
|
||||
if (ctx.LangOpts.hasFeature(Feature::NoncopyableGenerics)) {
|
||||
bool skipInverses = false;
|
||||
|
||||
// ... except for these protocols, so that Copyable does not have to
|
||||
// inherit ~Copyable, etc.
|
||||
if (auto kp = PD->getKnownProtocolKind()) {
|
||||
switch (*kp) {
|
||||
case KnownProtocolKind::Sendable:
|
||||
case KnownProtocolKind::Copyable:
|
||||
case KnownProtocolKind::Escapable:
|
||||
skipInverses = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!skipInverses) {
|
||||
for (auto ip : InvertibleProtocolSet::full()) {
|
||||
// Unless the user wrote ~P in the syntactic inheritance clause, the
|
||||
// semantic inherited list includes P.
|
||||
if (!inverses.contains(ip))
|
||||
inherited.insert(ctx.getProtocol(getKnownProtocolKind(ip)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ctx.AllocateCopy(inherited.getArrayRef());
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
// RUN: %target-swift-frontend -typecheck %s -debug-generic-signatures 2>&1 | %FileCheck %s
|
||||
// RUN: %target-swift-frontend -typecheck %s -debug-generic-signatures -disable-requirement-machine-reuse 2>&1 | %FileCheck %s
|
||||
|
||||
// XFAIL: noncopyable_generics
|
||||
|
||||
// CHECK-LABEL: .NonEmptyProtocol@
|
||||
// CHECK-NEXT: Requirement signature: <Self where Self : Collection, Self.[NonEmptyProtocol]C : Collection, Self.[Sequence]Element == Self.[NonEmptyProtocol]C.[Sequence]Element, Self.[Collection]Index == Self.[NonEmptyProtocol]C.[Collection]Index>
|
||||
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
// RUN: %target-swift-frontend -typecheck %s -debug-generic-signatures 2>&1 | %FileCheck %s
|
||||
// RUN: %target-swift-frontend -typecheck %s -debug-generic-signatures -disable-requirement-machine-reuse 2>&1 | %FileCheck %s
|
||||
|
||||
// XFAIL: noncopyable_generics
|
||||
|
||||
// CHECK-LABEL: .NonEmptyProtocol@
|
||||
// CHECK-NEXT: Requirement signature: <Self where Self : Collection, Self.[NonEmptyProtocol]C : Collection, Self.[Sequence]Element == Self.[NonEmptyProtocol]C.[Sequence]Element, Self.[Collection]Index == Self.[NonEmptyProtocol]C.[Collection]Index>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user