Skip to content

Commit 8ea9e65

Browse files
authored
Merge pull request #69567 from tshortli/module-interface-lazy-typecheck-transparent-attr
AST: Expand @_transparent in SemanticDeclAttrsRequest
2 parents 30cdd3c + dea6dfd commit 8ea9e65

File tree

5 files changed

+13
-2
lines changed

5 files changed

+13
-2
lines changed

lib/AST/TypeCheckRequests.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2069,9 +2069,15 @@ void ExpandPeerMacroRequest::noteCycleStep(DiagnosticEngine &diags) const {
20692069

20702070
DeclAttributes SemanticDeclAttrsRequest::evaluate(Evaluator &evaluator,
20712071
const Decl *decl) const {
2072+
// Expand attributes contributed by attached macros.
20722073
auto mutableDecl = const_cast<Decl *>(decl);
20732074
(void)evaluateOrDefault(evaluator, ExpandMemberAttributeMacros{mutableDecl},
20742075
{});
2076+
2077+
// Trigger requests that cause additional semantic attributes to be added.
2078+
if (auto afd = dyn_cast<AbstractFunctionDecl>(decl)) {
2079+
(void)afd->isTransparent();
2080+
}
20752081
return decl->getAttrs();
20762082
}
20772083

lib/Sema/TypeCheckStorage.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,7 @@ static bool doesAccessorHaveBody(AccessorDecl *accessor) {
821821
auto *storage = accessor->getStorage();
822822

823823
// NSManaged getters and setters don't have bodies.
824-
if (storage->getAttrs().hasAttribute<NSManagedAttr>())
824+
if (storage->getAttrs().hasAttribute<NSManagedAttr>(/*AllowInvalid=*/true))
825825
if (accessor->isGetterOrSetter())
826826
return false;
827827

test/Inputs/lazy_typecheck.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ public struct PublicStruct {
128128
public var publicProperty: Int
129129
public var publicPropertyInferredType = ""
130130
@PublicWrapper public var publicWrappedProperty = 3.14
131+
@_transparent public var publicTransparentProperty: Int {
132+
get { return 1 }
133+
}
131134

132135
public init(x: Int) {
133136
self.publicProperty = 1

test/Inputs/lazy_typecheck_client.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ func testPublicStruct() {
3939
let _: String = s.publicPropertyInferredType
4040
let _: Double = s.publicWrappedProperty
4141
let _: Double = s.$publicWrappedProperty.wrappedValue
42+
let _: Int = s.publicTransparentProperty
4243
PublicStruct.publicStaticMethod()
4344
PublicStruct.activeMethod()
4445
}

test/ModuleInterface/stored-properties.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ public struct HasStoredProperties {
3838

3939
// CHECK: @_hasStorage public var storedWithObservers: Swift.Bool {
4040
// RESILIENT: {{^}} public var storedWithObservers: Swift.Bool {
41-
// COMMON-NEXT: {{^}} get
41+
// CHECK-NEXT: {{^}} @_transparent get
42+
// RESILIENT-NEXT: {{^}} get
4243
// COMMON-NEXT: {{^}} set
4344
// COMMON-NEXT: {{^}} }
4445
public var storedWithObservers: Bool {

0 commit comments

Comments
 (0)