Skip to content

Commit f93e400

Browse files
committed
[Dynamic Casting] Use old boxing semantics for pre-Fall-2023 apps
For Apple platforms, enable the new stricter boxing semantics only for apps built against the Fall 2023 or later SDK. This avoids breaking apps that relied on the old behavior and have not been updated since then.
1 parent 7b0a8a2 commit f93e400

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

stdlib/public/runtime/Bincompat.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ static enum sdk_test isAppAtLeastSpring2021() {
6161
const dyld_build_version_t spring_2021_os_versions = {0xffffffff, 0x007e50301};
6262
return isAppAtLeast(spring_2021_os_versions);
6363
}
64+
65+
static enum sdk_test isAppAtLeastFall2023() {
66+
const dyld_build_version_t fall_2023_os_versions = {0xffffffff, 0x007e70901};
67+
return isAppAtLeast(fall_2023_os_versions);
68+
}
6469
#endif
6570

6671
static _SwiftStdlibVersion binCompatVersionOverride = { 0 };
@@ -189,7 +194,11 @@ bool useLegacyOptionalNilInjectionInCasting() {
189194
// by that protocol.
190195
bool useLegacyObjCBoxingInCasting() {
191196
#if BINARY_COMPATIBILITY_APPLE
192-
return false; // For now, always use the new behavior on Apple OSes
197+
switch (isAppAtLeastFall2023()) {
198+
case oldOS: return true; // Legacy behavior on old OS
199+
case oldApp: return true; // Legacy behavior for old apps
200+
case newApp: return false; // New behavior for new apps
201+
}
193202
#else
194203
return false; // Always use the new behavior on non-Apple OSes
195204
#endif
@@ -209,7 +218,11 @@ bool useLegacyObjCBoxingInCasting() {
209218

210219
bool useLegacySwiftValueUnboxingInCasting() {
211220
#if BINARY_COMPATIBILITY_APPLE
212-
return false; // For now, always use the new behavior on Apple OSes
221+
switch (isAppAtLeastFall2023()) {
222+
case oldOS: return true; // Legacy behavior on old OS
223+
case oldApp: return true; // Legacy behavior for old apps
224+
case newApp: return false; // New behavior for new apps
225+
}
213226
#else
214227
return false; // Always use the new behavior on non-Apple OSes
215228
#endif

0 commit comments

Comments
 (0)