Skip to content

Commit a109736

Browse files
committed
Make sure that imported @mainactor shows up in the interface.
... but don't show the (unsafe) part outside of Swift interfaces, because it's messy and we don't want people to use it.
1 parent 172e136 commit a109736

File tree

3 files changed

+3
-5
lines changed

3 files changed

+3
-5
lines changed

lib/AST/Attr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1020,7 +1020,7 @@ bool DeclAttribute::printImpl(ASTPrinter &Printer, const PrintOptions &Options,
10201020
type.print(Printer, Options);
10211021
else
10221022
attr->getTypeRepr()->print(Printer, Options);
1023-
if (attr->isArgUnsafe())
1023+
if (attr->isArgUnsafe() && Options.IsForSwiftInterface)
10241024
Printer << "(unsafe)";
10251025
Printer.printNamePost(PrintNameContext::Attribute);
10261026
break;

lib/ClangImporter/ImportDecl.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8188,8 +8188,6 @@ void ClangImporter::Implementation::importAttributes(
81888188
auto typeExpr = TypeExpr::createImplicit(mainActorType, SwiftContext);
81898189
auto attr = CustomAttr::create(SwiftContext, SourceLoc(), typeExpr);
81908190
attr->setArgIsUnsafe(isUnsafe);
8191-
if (isUnsafe)
8192-
attr->setImplicit();
81938191
MappedDecl->getAttrs().add(attr);
81948192
}
81958193

test/IDE/print_clang_objc_async.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ import _Concurrency
3939
// CHECK-LABEL: protocol ProtocolWithSwiftAttributes {
4040
// CHECK-NEXT: @actorIndependent func independentMethod()
4141
// CHECK-NEXT: @asyncHandler func asyncHandlerMethod()
42-
// CHECK-NEXT: {{^}} func mainActorMethod()
43-
// CHECK-NEXT: {{^}} func uiActorMethod()
42+
// CHECK-NEXT: {{^}} @MainActor func mainActorMethod()
43+
// CHECK-NEXT: {{^}} @MainActor func uiActorMethod()
4444
// CHECK-NEXT: {{^}} optional func missingAtAttributeMethod()
4545
// CHECK-NEXT: {{^[}]$}}
4646

0 commit comments

Comments
 (0)