Skip to content

Commit c6e9661

Browse files
committed
AST: Trigger IsDynamicRequest when retrieving semantic attributes.
1 parent 7a61cdf commit c6e9661

File tree

4 files changed

+33
-0
lines changed

4 files changed

+33
-0
lines changed

lib/AST/TypeCheckRequests.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2076,6 +2076,7 @@ DeclAttributes SemanticDeclAttrsRequest::evaluate(Evaluator &evaluator,
20762076

20772077
// Trigger requests that cause additional semantic attributes to be added.
20782078
if (auto vd = dyn_cast<ValueDecl>(decl)) {
2079+
(void)vd->isDynamic();
20792080
(void)vd->isFinal();
20802081
}
20812082
if (auto afd = dyn_cast<AbstractFunctionDecl>(decl)) {

test/Inputs/lazy_typecheck.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ public struct PublicStruct {
131131
@_transparent public var publicTransparentProperty: Int {
132132
get { return 1 }
133133
}
134+
public dynamic var publicDynamicProperty: Int = 5
134135

135136
public init(x: Int) {
136137
self.publicProperty = 1

test/Inputs/lazy_typecheck_client.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,18 @@ func testPublicStructs() {
4040
let _: Double = s.publicWrappedProperty
4141
let _: Double = s.$publicWrappedProperty.wrappedValue
4242
let _: Int = s.publicTransparentProperty
43+
let _: Int = s.publicDynamicProperty
4344
PublicStruct.publicStaticMethod()
4445
PublicStruct.activeMethod()
4546

4647
let _ = FrozenPublicStruct(1)
4748
}
4849

50+
extension PublicStruct {
51+
@_dynamicReplacement(for: publicDynamicProperty)
52+
var replacementVar: Int
53+
}
54+
4955
func testPublicClasses() {
5056
let c = PublicClass(x: 2)
5157
let _: Int = c.publicMethod()
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %empty-directory(%t/baseline)
3+
// RUN: %empty-directory(%t/lazy)
4+
5+
// RUN: %target-swift-emit-module-interface(%t/baseline/Test.swiftinterface) -module-name Test %s -disable-objc-attr-requires-foundation-module
6+
// RUN: %target-swift-typecheck-module-from-interface(%t/baseline/Test.swiftinterface) -module-name Test
7+
8+
// RUN: %target-swift-emit-module-interface(%t/lazy/Test.swiftinterface) -module-name Test %s -disable-objc-attr-requires-foundation-module -experimental-lazy-typecheck
9+
// RUN: %target-swift-typecheck-module-from-interface(%t/lazy/Test.swiftinterface) -module-name Test
10+
// RUN: diff -u %t/baseline/Test.swiftinterface %t/lazy/Test.swiftinterface
11+
12+
// REQUIRES: objc_interop
13+
14+
@objc open class ObjCClass {
15+
public var publicVar: Int = 0
16+
@NSManaged public var managedVar: Int
17+
open func method() {}
18+
}
19+
20+
public final class FinalClass {
21+
@objc public dynamic var publicDynamicVar: Int {
22+
get { return 0 }
23+
set {}
24+
}
25+
}

0 commit comments

Comments
 (0)