AST: Trigger IsDynamicRequest when retrieving semantic attributes.

This commit is contained in:
Allan Shortlidge
2023-11-02 21:55:44 -07:00
parent 7a61cdfcb0
commit c6e966157a
4 changed files with 33 additions and 0 deletions

View File

@@ -2076,6 +2076,7 @@ DeclAttributes SemanticDeclAttrsRequest::evaluate(Evaluator &evaluator,
// Trigger requests that cause additional semantic attributes to be added.
if (auto vd = dyn_cast<ValueDecl>(decl)) {
(void)vd->isDynamic();
(void)vd->isFinal();
}
if (auto afd = dyn_cast<AbstractFunctionDecl>(decl)) {

View File

@@ -131,6 +131,7 @@ public struct PublicStruct {
@_transparent public var publicTransparentProperty: Int {
get { return 1 }
}
public dynamic var publicDynamicProperty: Int = 5
public init(x: Int) {
self.publicProperty = 1

View File

@@ -40,12 +40,18 @@ func testPublicStructs() {
let _: Double = s.publicWrappedProperty
let _: Double = s.$publicWrappedProperty.wrappedValue
let _: Int = s.publicTransparentProperty
let _: Int = s.publicDynamicProperty
PublicStruct.publicStaticMethod()
PublicStruct.activeMethod()
let _ = FrozenPublicStruct(1)
}
extension PublicStruct {
@_dynamicReplacement(for: publicDynamicProperty)
var replacementVar: Int
}
func testPublicClasses() {
let c = PublicClass(x: 2)
let _: Int = c.publicMethod()

View File

@@ -0,0 +1,25 @@
// RUN: %empty-directory(%t)
// RUN: %empty-directory(%t/baseline)
// RUN: %empty-directory(%t/lazy)
// RUN: %target-swift-emit-module-interface(%t/baseline/Test.swiftinterface) -module-name Test %s -disable-objc-attr-requires-foundation-module
// RUN: %target-swift-typecheck-module-from-interface(%t/baseline/Test.swiftinterface) -module-name Test
// RUN: %target-swift-emit-module-interface(%t/lazy/Test.swiftinterface) -module-name Test %s -disable-objc-attr-requires-foundation-module -experimental-lazy-typecheck
// RUN: %target-swift-typecheck-module-from-interface(%t/lazy/Test.swiftinterface) -module-name Test
// RUN: diff -u %t/baseline/Test.swiftinterface %t/lazy/Test.swiftinterface
// REQUIRES: objc_interop
@objc open class ObjCClass {
public var publicVar: Int = 0
@NSManaged public var managedVar: Int
open func method() {}
}
public final class FinalClass {
@objc public dynamic var publicDynamicVar: Int {
get { return 0 }
set {}
}
}