Skip to content

Commit 6ddfb6d

Browse files
committed
correct indent handling for requirement stubs
1 parent 1aa12bb commit 6ddfb6d

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

lib/Sema/TypeCheckDistributed.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,6 @@ static bool checkAdHocRequirementAccessControl(
211211
return true;
212212

213213
// === check access control
214-
// TODO(distributed): this is for ad-hoc requirements and is likely too naive
215214
if (func->getEffectiveAccess() == decl->getEffectiveAccess()) {
216215
return false;
217216
}
@@ -236,6 +235,8 @@ static bool diagnoseMissingAdHocProtocolRequirement(ASTContext &C, Identifier id
236235
llvm::raw_svector_ostream OS(Text);
237236
ExtraIndentStreamPrinter Printer(OS, CurrentIndent);
238237

238+
Printer.printNewline();
239+
Printer.printIndent();
239240
Printer << (decl->getFormalAccess() == AccessLevel::Public ? "public " : "");
240241

241242
if (identifier == C.Id_remoteCall) {
@@ -275,7 +276,9 @@ static bool diagnoseMissingAdHocProtocolRequirement(ASTContext &C, Identifier id
275276
/// Print the "{ <#code#> }" placeholder body
276277
Printer << " {\n";
277278
Printer << ExtraIndent << getCodePlaceholder();
278-
Printer << "\n}\n";
279+
Printer.printNewline();
280+
Printer.printIndent();
281+
Printer << "}\n";
279282

280283
decl->diagnose(
281284
diag::distributed_actor_system_conformance_missing_adhoc_requirement,

test/Distributed/distributed_actor_system_missing_adhoc_requirement_fixits.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import Distributed
88

99
struct MissingRemoteCall: DistributedActorSystem {
1010
// expected-error@-1{{struct 'MissingRemoteCall' is missing witness for protocol requirement 'remoteCall'}}
11-
// expected-note@-2{{add stubs for conformance}}{{51-51=func remoteCall<Act, Err, Res>(on actor: Act, target: RemoteCallTarget, invocation: inout InvocationEncoder, throwing: Err.Type, returning: Res.Type) async throws -> Res where Act: DistributedActor, Act.ID == ActorID, Err: Error, Res: SerializationRequirement {\n <#code#>\n}\n}}
11+
// expected-note@-2{{add stubs for conformance}}{{51-51=\nfunc remoteCall<Act, Err, Res>(on actor: Act, target: RemoteCallTarget, invocation: inout InvocationEncoder, throwing: Err.Type, returning: Res.Type) async throws -> Res where Act: DistributedActor, Act.ID == ActorID, Err: Error, Res: SerializationRequirement {\n <#code#>\n}\n}}
1212

1313
// expected-error@-4{{struct 'MissingRemoteCall' is missing witness for protocol requirement 'remoteCallVoid'}}
14-
// expected-note@-5{{add stubs for conformance}}{{51-51=func remoteCallVoid<Act, Err>(on actor: Act, target: RemoteCallTarget, invocation: inout InvocationEncoder, throwing: Err.Type) async throws where Act: DistributedActor, Act.ID == ActorID, Err: Error {\n <#code#>\n}\n}}
14+
// expected-note@-5{{add stubs for conformance}}{{51-51=\nfunc remoteCallVoid<Act, Err>(on actor: Act, target: RemoteCallTarget, invocation: inout InvocationEncoder, throwing: Err.Type) async throws where Act: DistributedActor, Act.ID == ActorID, Err: Error {\n <#code#>\n}\n}}
1515

1616
typealias ActorID = ActorAddress
1717
typealias InvocationDecoder = FakeInvocationDecoder
@@ -43,10 +43,10 @@ struct MissingRemoteCall: DistributedActorSystem {
4343

4444
public struct PublicMissingRemoteCall: DistributedActorSystem {
4545
// expected-error@-1{{struct 'PublicMissingRemoteCall' is missing witness for protocol requirement 'remoteCall'}}
46-
// expected-note@-2{{add stubs for conformance}}{{64-64=public func remoteCall<Act, Err, Res>(on actor: Act, target: RemoteCallTarget, invocation: inout InvocationEncoder, throwing: Err.Type, returning: Res.Type) async throws -> Res where Act: DistributedActor, Act.ID == ActorID, Err: Error, Res: SerializationRequirement {\n <#code#>\n}\n}}
46+
// expected-note@-2{{add stubs for conformance}}{{64-64=\npublic func remoteCall<Act, Err, Res>(on actor: Act, target: RemoteCallTarget, invocation: inout InvocationEncoder, throwing: Err.Type, returning: Res.Type) async throws -> Res where Act: DistributedActor, Act.ID == ActorID, Err: Error, Res: SerializationRequirement {\n <#code#>\n}\n}}
4747

4848
// expected-error@-4{{struct 'PublicMissingRemoteCall' is missing witness for protocol requirement 'remoteCallVoid'}}
49-
// expected-note@-5{{add stubs for conformance}}{{64-64=public func remoteCallVoid<Act, Err>(on actor: Act, target: RemoteCallTarget, invocation: inout InvocationEncoder, throwing: Err.Type) async throws where Act: DistributedActor, Act.ID == ActorID, Err: Error {\n <#code#>\n}\n}}
49+
// expected-note@-5{{add stubs for conformance}}{{64-64=\npublic func remoteCallVoid<Act, Err>(on actor: Act, target: RemoteCallTarget, invocation: inout InvocationEncoder, throwing: Err.Type) async throws where Act: DistributedActor, Act.ID == ActorID, Err: Error {\n <#code#>\n}\n}}
5050

5151

5252
public typealias ActorID = ActorAddress

test/Distributed/distributed_actor_system_missing_adhoc_requirement_impls.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,7 @@ struct LargeSerializationReqFakeInvocationResultHandler: DistributedTargetInvoca
870870

871871
struct BadResultHandler_missingOnReturn: DistributedTargetInvocationResultHandler {
872872
// expected-error@-1{{struct 'BadResultHandler_missingOnReturn' is missing witness for protocol requirement 'onReturn'}}
873-
// expected-note@-2{{add stubs for conformance}}{{84-84=func onReturn<Success: SerializationRequirement>(value: Success) async throws {\n <#code#>\n\}\n}}
873+
// expected-note@-2{{add stubs for conformance}}{{84-84=\nfunc onReturn<Success: SerializationRequirement>(value: Success) async throws {\n <#code#>\n\}\n}}
874874
typealias SerializationRequirement = Codable
875875

876876
// func onReturn<Res: SerializationRequirement>(value: Res) async throws {} // MISSING

0 commit comments

Comments
 (0)