Skip to content

Commit 97ecb94

Browse files
committed
[ASTScope] Always skip implicit attributes.
ASTScope only cares about attributes when lookup can be done inside of the attribute, which isn't the case for implicit attributes because they're typically built fully type-checked. This also avoids a crash when an implicit attribute does not have a source range.
1 parent 95f8ed8 commit 97ecb94

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

lib/AST/ASTScopeCreation.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -506,10 +506,11 @@ void ScopeCreator::addChildrenForKnownAttributes(ValueDecl *decl,
506506
SmallVector<DeclAttribute *, 2> relevantAttrs;
507507

508508
for (auto *attr : decl->getAttrs()) {
509-
if (isa<DifferentiableAttr>(attr)) {
510-
if (!attr->isImplicit())
511-
relevantAttrs.push_back(attr);
512-
}
509+
if (attr->isImplicit())
510+
continue;
511+
512+
if (isa<DifferentiableAttr>(attr))
513+
relevantAttrs.push_back(attr);
513514

514515
if (isa<SpecializeAttr>(attr))
515516
relevantAttrs.push_back(attr);

test/Concurrency/global_actor_inference.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,17 @@ struct WrapperOnActor<Wrapped> {
282282
}
283283
}
284284

285+
@MainActor
286+
@propertyWrapper
287+
public struct WrapperOnMainActor<Wrapped> {
288+
// Make sure inference of @MainActor on wrappedValue doesn't crash.
289+
public var wrappedValue: Wrapped
290+
291+
public init(wrappedValue: Wrapped) {
292+
self.wrappedValue = wrappedValue
293+
}
294+
}
295+
285296
@propertyWrapper
286297
actor WrapperActor<Wrapped> {
287298
@actorIndependent(unsafe) var storage: Wrapped

0 commit comments

Comments
 (0)