Skip to content

Commit 95dca81

Browse files
authored
Merge pull request #78729 from rjmccall/isolated-sending-results-compiler-fix
Assorted fixes for runtime metadata mangling and demangling
2 parents 4b595b1 + a4853f8 commit 95dca81

File tree

10 files changed

+646
-149
lines changed

10 files changed

+646
-149
lines changed

include/swift/AST/RuntimeVersions.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ RUNTIME_VERSION(
135135
PLATFORM(macOS, (14, 4, 0))
136136
PLATFORM(iOS, (17, 4, 0))
137137
PLATFORM(watchOS, (10, 4, 0))
138-
PLATFORM(xrOS, (1, 0, 0))
138+
PLATFORM(visionOS,(1, 0, 0))
139139
)
140140

141141
END_MAJOR_VERSION(5)
@@ -147,7 +147,7 @@ RUNTIME_VERSION(
147147
PLATFORM(macOS, (15, 0, 0))
148148
PLATFORM(iOS, (18, 0, 0))
149149
PLATFORM(watchOS, (11, 0, 0))
150-
PLATFORM(xrOS, (2, 0, 0))
150+
PLATFORM(visionOS,(2, 0, 0))
151151
)
152152

153153
RUNTIME_VERSION(

include/swift/Basic/Pack.h

Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
//===--- Pack.h - Helpers for wording with class template packs -*- C++ -*-===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#ifndef SWIFT_BASIC_PACKS_H
14+
#define SWIFT_BASIC_PACKS_H
15+
16+
namespace swift {
17+
namespace packs {
18+
19+
/// A pack of types.
20+
template <class...>
21+
struct Pack;
22+
23+
/// A trait indicating whether the given type is a specialization
24+
/// of Pack<...>.
25+
template <class>
26+
struct IsPack {
27+
static constexpr bool value = false;
28+
};
29+
30+
template <class... Components>
31+
struct IsPack<Pack<Components...>> {
32+
static constexpr bool value = true;
33+
};
34+
35+
/// Transform a variadic list of types using the given transform, a class
36+
/// template which is expected to define a `result` type providing the
37+
/// result of the transform.
38+
///
39+
/// template <class Arg, class Component>
40+
/// class Transform {
41+
/// using result = ...;
42+
/// };
43+
///
44+
/// In principle, this would be cleaner as a member template, but that
45+
/// works out poorly because in practice the member template must be
46+
/// partially specialized in order to destructure it.
47+
template <template <class, class> class Transform,
48+
class TransformArg, class... Values>
49+
struct PackMapComponents {
50+
using result = Pack<typename Transform<TransformArg, Values>::result...>;
51+
};
52+
53+
/// Transform the components of a pack using the given transform, a class
54+
/// template which is expected to define a `result` type providing the
55+
/// result of the transform.
56+
///
57+
/// template <class Arg, class Component>
58+
/// class Transform {
59+
/// using result = ...;
60+
/// };
61+
template <template <class, class> class Transform, class TransformArg,
62+
class P>
63+
struct PackMap;
64+
65+
template <template <class, class> class Transform, class TransformArg,
66+
class... Components>
67+
struct PackMap<Transform, TransformArg, Pack<Components...>>
68+
: PackMapComponents<Transform, TransformArg, Components...> {};
69+
70+
/// Concatenate the components of a variadic list of packs.
71+
template <class... Packs>
72+
struct PackConcat;
73+
74+
template <>
75+
struct PackConcat<> {
76+
using result = Pack<>;
77+
};
78+
79+
template <class First>
80+
struct PackConcat<First> {
81+
static_assert(IsPack<First>::value, "argument is not a pack");
82+
using result = First;
83+
};
84+
85+
template <class... FirstComponents, class... SecondComponents>
86+
struct PackConcat<Pack<FirstComponents...>, Pack<SecondComponents...>> {
87+
using result = Pack<FirstComponents..., SecondComponents...>;
88+
};
89+
90+
template <class Head, class... Tail>
91+
struct PackConcat<Head, Tail...>
92+
: PackConcat<Head, typename PackConcat<Tail...>::result> {};
93+
94+
/// Flatten a pack of packs by concatenating their components.
95+
template <class>
96+
struct PackFlatten;
97+
98+
template <class... PackComponents>
99+
struct PackFlatten<Pack<PackComponents...>>
100+
: PackConcat<PackComponents...> {};
101+
102+
/// Apply the given pack-producing transform to each component of a pack,
103+
/// then concatenate the results.
104+
///
105+
/// For example, if we start with Pack<A, B, C>, and the transform turns:
106+
/// A => Pack<X, Y>
107+
/// B => Pack<>
108+
/// C => Pack<Z>
109+
/// then the result will be Pack<X, Y, Z>.
110+
template <template <class, class> class Transform, class TransformArg, class P>
111+
struct PackFlatMap
112+
: PackFlatten<typename PackMap<Transform, TransformArg, P>::result> {};
113+
114+
/// Reverse a variadic list of types.
115+
template <class... PackComponents>
116+
struct PackReverseComponents;
117+
118+
template <>
119+
struct PackReverseComponents<> {
120+
using result = Pack<>;
121+
};
122+
123+
template <class Head>
124+
struct PackReverseComponents<Head> {
125+
using result = Pack<Head>;
126+
};
127+
128+
template <class Head, class... Tail>
129+
struct PackReverseComponents<Head, Tail...>
130+
: PackConcat<typename PackReverseComponents<Tail...>::result,
131+
Pack<Head>> {};
132+
133+
134+
/// Reverse a pack.
135+
template <class>
136+
struct PackReverse;
137+
138+
template <class... PackComponents>
139+
struct PackReverse<Pack<PackComponents...>>
140+
: PackReverseComponents<PackComponents...> {};
141+
142+
/// Determine whether the given pack is transitively ordered according to
143+
/// the given predicate:
144+
///
145+
/// template <class First, class Second>
146+
/// struct IsOrdered {
147+
/// static constexpr bool value;
148+
/// };
149+
template <template <class, class> class IsOrdered,
150+
class... Components>
151+
struct PackComponentsAreOrdered;
152+
153+
template <template <class, class> class IsOrdered>
154+
struct PackComponentsAreOrdered<IsOrdered> {
155+
static constexpr bool value = true;
156+
};
157+
158+
template <template <class, class> class IsOrdered,
159+
class A>
160+
struct PackComponentsAreOrdered<IsOrdered, A> {
161+
static constexpr bool value = true;
162+
};
163+
164+
template <template <class, class> class IsOrdered,
165+
class A, class B>
166+
struct PackComponentsAreOrdered<IsOrdered, A, B> : IsOrdered<A, B> {};
167+
168+
template <template <class, class> class IsOrdered,
169+
class A, class B, class... C>
170+
struct PackComponentsAreOrdered<IsOrdered, A, B, C...> {
171+
static constexpr bool value =
172+
IsOrdered<A, B>::value &&
173+
PackComponentsAreOrdered<IsOrdered, B, C...>::value;
174+
};
175+
176+
/// Determine whether the given pack is well-ordered according to the given
177+
/// predicate:
178+
///
179+
/// template <class First, class Second>
180+
/// struct IsOrdered {
181+
/// static constexpr bool value;
182+
/// };
183+
template <template <class, class> class IsOrdered,
184+
class P>
185+
struct PackIsOrdered;
186+
187+
template <template <class, class> class IsOrdered,
188+
class... Components>
189+
struct PackIsOrdered<IsOrdered, Pack<Components...>>
190+
: PackComponentsAreOrdered<IsOrdered, Components...> {};
191+
192+
} // end namespace packs
193+
} // end namespace swift
194+
195+
#endif

lib/AST/Availability.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,7 @@ AvailabilityRange ASTContext::getSwiftAvailability(unsigned major,
880880
#define PLATFORM_TEST_macOS target.isMacOSX()
881881
#define PLATFORM_TEST_iOS target.isiOS()
882882
#define PLATFORM_TEST_watchOS target.isWatchOS()
883-
#define PLATFORM_TEST_xrOS target.isXROS()
883+
#define PLATFORM_TEST_visionOS target.isXROS()
884884

885885
#define _SECOND(A, B) B
886886
#define SECOND(T) _SECOND T
@@ -895,7 +895,7 @@ AvailabilityRange ASTContext::getSwiftAvailability(unsigned major,
895895
#undef PLATFORM_TEST_macOS
896896
#undef PLATFORM_TEST_iOS
897897
#undef PLATFORM_TEST_watchOS
898-
#undef PLATFORM_TEST_xrOS
898+
#undef PLATFORM_TEST_visionOS
899899
#undef _SECOND
900900
#undef SECOND
901901

0 commit comments

Comments
 (0)