Skip to content

Commit 5e1721d

Browse files
committed
[embedded] Make Mirror present but unavailable
1 parent 9a4bc35 commit 5e1721d

File tree

5 files changed

+22
-6
lines changed

5 files changed

+22
-6
lines changed

stdlib/public/core/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ split_embedded_sources(
9898
EMBEDDED Integers.swift
9999
NORMAL Join.swift
100100
EMBEDDED KeyPath.swift
101-
NORMAL KeyValuePairs.swift
101+
EMBEDDED KeyValuePairs.swift
102102
EMBEDDED LazyCollection.swift
103103
EMBEDDED LazySequence.swift
104104
NORMAL LegacyABI.swift
@@ -227,7 +227,7 @@ split_embedded_sources(
227227
EMBEDDED FloatingPointRandom.swift
228228
EMBEDDED Instant.swift
229229
EMBEDDED Int128.swift
230-
NORMAL Mirror.swift
230+
EMBEDDED Mirror.swift
231231
NORMAL PlaygroundDisplay.swift
232232
NORMAL CommandLine.swift
233233
EMBEDDED SliceBuffer.swift

stdlib/public/core/EmbeddedStubs.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@ import SwiftShims
1515
/// String
1616

1717
@_unavailableInEmbedded
18-
extension String {
19-
public init<Subject>(describing instance: Subject) { fatalError() }
20-
public init<Subject>(reflecting instance: Subject) { fatalError() }
21-
}
18+
internal func _print_unlocked<T>(_ value: T, _ target: inout String) { fatalError() }
19+
@_unavailableInEmbedded
20+
public func _debugPrint_unlocked<T>(_ value: T, _ target: inout String) { fatalError() }
2221

2322
/// Codable
2423

stdlib/public/core/KeyValuePairs.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,15 @@ extension KeyValuePairs: RandomAccessCollection {
125125
}
126126
}
127127

128+
@_unavailableInEmbedded
128129
extension KeyValuePairs: CustomStringConvertible {
129130
/// A string that represents the contents of the dictionary.
130131
public var description: String {
131132
return _makeKeyValuePairDescription()
132133
}
133134
}
134135

136+
@_unavailableInEmbedded
135137
extension KeyValuePairs: CustomDebugStringConvertible {
136138
/// A string that represents the contents of the dictionary, suitable for
137139
/// debugging.

stdlib/public/core/Mirror.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,7 @@ extension Mirror {
538538

539539
//===--- General Utilities ------------------------------------------------===//
540540

541+
@_unavailableInEmbedded
541542
extension String {
542543
/// Creates a string representing the given value.
543544
///

test/embedded/mirror.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// RUN: %target-swift-emit-ir -verify %s -enable-experimental-feature Embedded -wmo
2+
3+
// REQUIRES: swift_in_compiler
4+
// REQUIRES: optimized_stdlib
5+
// REQUIRES: OS=macosx || OS=linux-gnu
6+
7+
public struct MyStruct {
8+
var a, b, c: Int
9+
}
10+
11+
public func foo(s: MyStruct) {
12+
let mirror = Mirror(reflecting: s) // expected-error {{'Mirror' is unavailable}}
13+
_ = mirror.children
14+
}

0 commit comments

Comments
 (0)