Skip to content

Commit 2776c51

Browse files
authored
Merge pull request #69266 from kubamracek/embedded-dynamic-self
[embedded] Allow metadata for DynamicSelfType to support using Self in classes
2 parents 251becb + 943e052 commit 2776c51

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

include/swift/IRGen/Linking.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ inline bool isEmbedded(CanType t) {
9090
}
9191

9292
inline bool isMetadataAllowedInEmbedded(CanType t) {
93-
return isa<ClassType>(t) || isa<BoundGenericClassType>(t);
93+
return isa<ClassType>(t) || isa<BoundGenericClassType>(t) ||
94+
isa<DynamicSelfType>(t);
9495
}
9596

9697
inline bool isEmbedded(Decl *d) {

test/embedded/dynamic-self.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// RUN: %target-swift-emit-ir %s -enable-experimental-feature Embedded -parse-as-library -module-name main | %FileCheck %s
2+
3+
// REQUIRES: swift_in_compiler
4+
// REQUIRES: VENDOR=apple
5+
// REQUIRES: OS=macosx
6+
7+
class MyClass {
8+
init() {
9+
Self.static_foo()
10+
}
11+
12+
static func static_foo() {}
13+
}
14+
15+
@main
16+
struct Main {
17+
static func main() {
18+
_ = MyClass()
19+
}
20+
}
21+
22+
// CHECK: define {{.*}}@main(

0 commit comments

Comments
 (0)