You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: proposals/0379-opt-in-reflection-metadata.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,11 +28,11 @@ Currently, there is no way to selectively enable the emission of reflectable met
28
28
Moreover, compiler's flags exist that allow to completely disable emission.
29
29
30
30
A developer has two ways right now - either
31
-
1. To just in case enable Reflection in full.
32
-
2. To try to guess which used APIs consume Reflection, and enable it only for modules that are users of such APIs.
31
+
1. To enable Reflection in full just in case.
32
+
2. To try to guess which used APIs consume Reflection, and enable it only for modules that use such APIs.
33
33
34
34
Both of those options have flaws. The first one leads to excessive contribution of reflection metadata to binary size and might affects the secrecy of generated code.
35
-
The second one isn't safe because many APIs are black boxes if the guess is wrong, an app might behave not as expected at runtime.
35
+
The second one isn't safe because many APIs are black boxes. If the developer's guess is wrong, an app might behave not as expected at runtime.
36
36
37
37
Furthermore, APIs can use Reflection Metadata differently. Some like `print`, `debugPrint`, and `dump` will still work with disabled reflection, but the output will be limited.
38
38
Others, like SwiftUI, rely on it and won't work correctly if the reflection metadata is missing.
@@ -131,7 +131,7 @@ Library authors will have to prepare their APIs for Swift 6 and introduce generi
131
131
We also propose to deprecate the compiler's options that can lead to missing reflection - `-reflection-metadata-for-debugger-only` and `-disable-reflection-metadata` and starting with Swift 6, ignore these arguments in favor of the default opt-in mode.
132
132
133
133
134
-
### Stdlib behavior changes
134
+
### No stdlib behavior changes
135
135
136
136
In Swift `Mirror(reflecting:)` is the only official way to access Reflection metadata, all other APIs are using it under the hood.
137
137
We intentionally do not propose adding a Reflectable constraint on Mirror type, because it would impose restrictions on those developers who still don't want to require it and consume Reflection optionally.
0 commit comments