Skip to content

Commit e338a50

Browse files
committed
SIL: Stored property initializers get the linkage of their containing type
This allows inlineble initializers to be defined on types that have stored property initializers. This is not the final behavior we want; in Swift 4 mode, we want to give these shared linkage and make them fragile, and enforce that stored property initializer expressions only reference other public and versioned symbols. This will match the behavior of default argument expressions in Swift 4 mode, and I'll implement it when I do those.
1 parent 5ce8406 commit e338a50

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

lib/SIL/SILDeclRef.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -438,11 +438,6 @@ SILLinkage SILDeclRef::getLinkage(ForDefinition_t forDefinition) const {
438438
if (isEnumElement())
439439
return SILLinkage::Shared;
440440

441-
// Stored property initializers have hidden linkage, since they are
442-
// not meant to be used from outside of their module.
443-
if (isStoredPropertyInitializer())
444-
return (forDefinition ? SILLinkage::Hidden : SILLinkage::HiddenExternal);
445-
446441
// Declarations imported from Clang modules have shared linkage.
447442
const SILLinkage ClangLinkage = SILLinkage::Shared;
448443

test/SILGen/inlineable_attribute.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,11 @@ public class MyCls {
3636
@_inlineable public func referencesMyEnum() {
3737
_ = MyEnum.c
3838
}
39+
40+
// CHECK-LABEL: sil [transparent] @_T020inlineable_attribute15HasInitializersV1xSivfi : $@convention(thin) () -> Int
41+
42+
public struct HasInitializers {
43+
public let x = 1234
44+
45+
@_inlineable public init() {}
46+
}

0 commit comments

Comments
 (0)