Skip to content

Commit a15a905

Browse files
committed
[Property wrappers] Expand testing for backing initializer linkage change.
1 parent 8621a52 commit a15a905

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed
Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
// RUN: %empty-directory(%t)
22
// RUN: %target-swift-frontend -emit-module -o %t -enable-library-evolution %S/Inputs/property_wrapper_defs.swift
3-
// RUN: %target-swift-emit-silgen -primary-file %s -I %t -enable-library-evolution
3+
// RUN: %target-swift-emit-silgen -primary-file %s -I %t -enable-library-evolution | %FileCheck %s
44
import property_wrapper_defs
55

66
// rdar://problem/55995892
77
// This is a crash that occurs only with -enable-library-evolution.
88

99
public enum E { case a }
1010
struct M { @MyPublished private var e = E.a }
11+
12+
// Ensure that the backing initializer is serialized.
13+
@frozen
14+
public struct StructUsesPublishedAsPrivate {
15+
public var integer: Int = 17
16+
17+
// CHECK: sil non_abi [serialized] [ossa] @$s35property_wrappers_library_evolution28StructUsesPublishedAsPrivateV6stringSSvpfP : $@convention(thin) (@owned String) -> @out MyPublished<String>
18+
@MyPublished var string: String = "Hello"
19+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// RUN: %target-swift-frontend -typecheck %s -verify -enable-library-evolution
2+
3+
@propertyWrapper
4+
public struct ResilientWrapper<T> {
5+
public var wrappedValue: T
6+
7+
public init(wrappedValue: T, description: String) {
8+
self.wrappedValue = wrappedValue
9+
}
10+
}
11+
12+
func getHello() -> String { return "hello" } // expected-note 2 {{global function 'getHello()' is not '@usableFromInline' or public}}
13+
14+
@frozen
15+
public struct StructUsesPublishedAsPrivate {
16+
public var integer: Int = 17
17+
18+
@ResilientWrapper(description: getHello()) // expected-error 2 {{global function 'getHello()' is internal and cannot be referenced from a property initializer in a '@frozen' type}}
19+
var otherString: String = "World"
20+
}

0 commit comments

Comments
 (0)