mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Sema: Refactor evaluateMembersRequest() to not call TypeChecker::checkConformance()
This commit is contained in:
@@ -3057,33 +3057,27 @@ static ArrayRef<Decl *> evaluateMembersRequest(
|
||||
|
||||
// Force any conformances that may introduce more members.
|
||||
for (auto conformance : idc->getLocalConformances()) {
|
||||
auto *normal = dyn_cast<NormalProtocolConformance>(
|
||||
conformance->getRootConformance());
|
||||
if (normal == nullptr)
|
||||
continue;
|
||||
|
||||
auto proto = conformance->getProtocol();
|
||||
bool isDerivable =
|
||||
conformance->getState() == ProtocolConformanceState::Incomplete &&
|
||||
proto->getKnownDerivableProtocolKind();
|
||||
bool isDerivable = proto->getKnownDerivableProtocolKind().has_value();
|
||||
|
||||
switch (kind) {
|
||||
case MembersRequestKind::ABI:
|
||||
// Force any derivable conformances in this context.
|
||||
if (isDerivable)
|
||||
break;
|
||||
|
||||
continue;
|
||||
|
||||
case MembersRequestKind::All:
|
||||
// Force any derivable conformances.
|
||||
if (isDerivable)
|
||||
break;
|
||||
|
||||
// If there are any associated types in the protocol, they might add
|
||||
// type aliases here.
|
||||
if (!proto->getAssociatedTypeMembers().empty())
|
||||
break;
|
||||
|
||||
continue;
|
||||
if (kind == MembersRequestKind::All &&
|
||||
!proto->getAssociatedTypeMembers().empty()) {
|
||||
evaluateOrDefault(ctx.evaluator,
|
||||
ResolveTypeWitnessesRequest{normal},
|
||||
evaluator::SideEffect());
|
||||
}
|
||||
|
||||
TypeChecker::checkConformance(conformance->getRootNormalConformance());
|
||||
if (isDerivable) {
|
||||
evaluateOrDefault(ctx.evaluator,
|
||||
ResolveValueWitnessesRequest{normal},
|
||||
evaluator::SideEffect());
|
||||
}
|
||||
}
|
||||
|
||||
if (nominal) {
|
||||
|
||||
@@ -432,9 +432,7 @@ final class TangentVectorWB: DummyAdditiveArithmetic, Differentiable {
|
||||
self.b = b
|
||||
}
|
||||
}
|
||||
// expected-error @+3 {{'Differentiable' requires the types 'VectorSpaceTypeAlias.TangentVector' (aka 'TangentVectorWB') and 'TangentVectorWB.TangentVector' be equivalent}}
|
||||
// expected-note @+2 {{requirement specified as 'Self.TangentVector' == 'Self.TangentVector.TangentVector' [with Self = VectorSpaceTypeAlias]}}
|
||||
// expected-error @+1 2 {{type 'VectorSpaceTypeAlias' does not conform to protocol 'Differentiable'}} FIXME: Duplicate error
|
||||
// expected-error @+1 {{type 'VectorSpaceTypeAlias' does not conform to protocol 'Differentiable'}}
|
||||
final class VectorSpaceTypeAlias: DummyAdditiveArithmetic, Differentiable {
|
||||
var w: Float
|
||||
var b: Float
|
||||
|
||||
@@ -48,8 +48,6 @@ actor A2: DistributedActor {
|
||||
// FIXME(distributed): error reporting is a bit whacky here; needs cleanup
|
||||
// expected-error@-2{{actor type 'A2' cannot conform to the 'DistributedActor' protocol. Isolation rules of these actor types are not interchangeable.}}
|
||||
// expected-error@-3{{actor type 'A2' cannot conform to the 'DistributedActor' protocol. Isolation rules of these actor types are not interchangeable.}}
|
||||
// expected-error@-4{{'DistributedActor' requires the types 'ObjectIdentifier' and 'FakeActorSystem.ActorID' (aka 'ActorAddress') be equivalent}}
|
||||
// expected-note@-5{{requirement specified as 'Self.ID' == 'Self.ActorSystem.ActorID' [with Self = A2]}}
|
||||
nonisolated var id: ID {
|
||||
fatalError()
|
||||
}
|
||||
|
||||
@@ -8,12 +8,13 @@ import Distributed
|
||||
|
||||
distributed actor DA {
|
||||
// expected-error@-1{{distributed actor 'DA' does not declare ActorSystem it can be used with}}
|
||||
// expected-error@-2 {{type 'DA' does not conform to protocol 'DistributedActor'}}
|
||||
|
||||
// Since synthesis would have failed due to the missing ActorSystem:
|
||||
// expected-error@-4{{type 'DA' does not conform to protocol 'Encodable'}}
|
||||
// expected-error@-5{{type 'DA' does not conform to protocol 'Decodable'}}
|
||||
// expected-error@-5{{type 'DA' does not conform to protocol 'Encodable'}}
|
||||
// expected-error@-6{{type 'DA' does not conform to protocol 'Decodable'}}
|
||||
|
||||
// expected-note@-7{{you can provide a module-wide default actor system by declaring:}}
|
||||
// expected-note@-8{{you can provide a module-wide default actor system by declaring:}}
|
||||
|
||||
// Note to add the typealias is diagnosed on the protocol:
|
||||
// _Distributed.DistributedActor:3:20: note: diagnostic produced elsewhere: protocol requires nested type 'ActorSystem'; do you want to add it?
|
||||
@@ -24,9 +25,10 @@ distributed actor DA {
|
||||
//
|
||||
// Test case for: https://github.com/apple/swift/issues/58663
|
||||
distributed actor Server { // expected-error 2 {{distributed actor 'Server' does not declare ActorSystem it can be used with}}
|
||||
// expected-note@-1{{you can provide a module-wide default actor system by declaring:}}
|
||||
// expected-error@-2{{type 'Server' does not conform to protocol 'Encodable'}}
|
||||
// expected-error@-3{{type 'Server' does not conform to protocol 'Decodable'}}
|
||||
// expected-error@-1 {{type 'Server' does not conform to protocol 'DistributedActor'}}
|
||||
// expected-note@-2{{you can provide a module-wide default actor system by declaring:}}
|
||||
// expected-error@-3{{type 'Server' does not conform to protocol 'Encodable'}}
|
||||
// expected-error@-4{{type 'Server' does not conform to protocol 'Decodable'}}
|
||||
typealias ActorSystem = DoesNotExistDataSystem
|
||||
// expected-error@-1{{cannot find type 'DoesNotExistDataSystem' in scope}}
|
||||
typealias SerializationRequirement = any Codable
|
||||
|
||||
@@ -10,9 +10,10 @@ import Distributed
|
||||
distributed actor Fish {
|
||||
// expected-error@-1{{distributed actor 'Fish' does not declare ActorSystem it can be used with}}
|
||||
// expected-error@-2{{distributed actor 'Fish' does not declare ActorSystem it can be used with}}
|
||||
// expected-note@-3{{you can provide a module-wide default actor system by declaring:\ntypealias DefaultDistributedActorSystem = <#ConcreteActorSystem#>}}
|
||||
// expected-error@-4{{type 'Fish' does not conform to protocol 'Encodable'}}
|
||||
// expected-error@-5{{type 'Fish' does not conform to protocol 'Decodable'}}
|
||||
// expected-error@-3{{type 'Fish' does not conform to protocol 'DistributedActor'}}
|
||||
// expected-note@-4{{you can provide a module-wide default actor system by declaring:\ntypealias DefaultDistributedActorSystem = <#ConcreteActorSystem#>}}
|
||||
// expected-error@-5{{type 'Fish' does not conform to protocol 'Encodable'}}
|
||||
// expected-error@-6{{type 'Fish' does not conform to protocol 'Decodable'}}
|
||||
|
||||
distributed func tell(_ text: String, by: Fish) {
|
||||
// What would the fish say, if it could talk?
|
||||
|
||||
@@ -29,6 +29,7 @@ public final class CompletelyHollowActorSystem: DistributedActorSystem {
|
||||
}
|
||||
|
||||
public struct Decoder: InvocationDecoder {
|
||||
// expected-error@-1 {{inheritance from non-protocol type 'CompletelyHollowActorSystem.InvocationDecoder' (aka 'CompletelyHollowActorSystem.Decoder')}}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -52,8 +52,9 @@ distributed actor ProtocolWithChecksSeqReqDA_MissingSystem: ProtocolWithChecksSe
|
||||
//
|
||||
// expected-error@-4{{distributed actor 'ProtocolWithChecksSeqReqDA_MissingSystem' does not declare ActorSystem it can be used with}}
|
||||
//
|
||||
// expected-error@-6{{type 'ProtocolWithChecksSeqReqDA_MissingSystem' does not conform to protocol 'Encodable'}}
|
||||
// expected-error@-7{{type 'ProtocolWithChecksSeqReqDA_MissingSystem' does not conform to protocol 'Decodable'}}
|
||||
// expected-error@-6{{type 'ProtocolWithChecksSeqReqDA_MissingSystem' does not conform to protocol 'DistributedActor'}}
|
||||
// expected-error@-7{{type 'ProtocolWithChecksSeqReqDA_MissingSystem' does not conform to protocol 'Encodable'}}
|
||||
// expected-error@-8{{type 'ProtocolWithChecksSeqReqDA_MissingSystem' does not conform to protocol 'Decodable'}}
|
||||
|
||||
// Entire conformance is doomed, so we didn't proceed to checking the functions; that's fine
|
||||
distributed func testAT() async throws -> NotCodable { .init() }
|
||||
|
||||
Reference in New Issue
Block a user