@@ -2793,34 +2793,6 @@ class OpaqueTypeDecl final :
2793
2793
class ConditionallyAvailableSubstitutions ;
2794
2794
2795
2795
private:
2796
- // / A container to keep a set of conditional available underlying type
2797
- // / substitutions with their availability conditions.
2798
- class ConditionalAlternatives final
2799
- : private llvm::TrailingObjects<ConditionalAlternatives,
2800
- ConditionallyAvailableSubstitutions *> {
2801
- friend TrailingObjects;
2802
-
2803
- unsigned NumAlternatives;
2804
-
2805
- ConditionalAlternatives (
2806
- ArrayRef<ConditionallyAvailableSubstitutions *> underlyingTypes)
2807
- : NumAlternatives(underlyingTypes.size()) {
2808
- std::uninitialized_copy (
2809
- underlyingTypes.begin (), underlyingTypes.end (),
2810
- getTrailingObjects<ConditionallyAvailableSubstitutions *>());
2811
- }
2812
-
2813
- public:
2814
- ArrayRef<ConditionallyAvailableSubstitutions *> getAlternatives () const {
2815
- return {getTrailingObjects<ConditionallyAvailableSubstitutions *>(),
2816
- NumAlternatives};
2817
- }
2818
-
2819
- static ConditionalAlternatives *
2820
- get (ASTContext &ctx,
2821
- ArrayRef<ConditionallyAvailableSubstitutions *> underlyingTypes);
2822
- };
2823
-
2824
2796
// / The original declaration that "names" the opaque type. Although a specific
2825
2797
// / opaque type cannot be explicitly named, oapque types can propagate
2826
2798
// / arbitrarily through expressions, so we need to know *which* opaque type is
@@ -2845,7 +2817,11 @@ class OpaqueTypeDecl final :
2845
2817
// / A set of substitutions which are used based on the availability
2846
2818
// / checks performed at runtime. This set of only populated if there
2847
2819
// / is no single unique underlying type for this opaque type declaration.
2848
- ConditionalAlternatives *ConditionallyAvailableTypes = nullptr ;
2820
+ // /
2821
+ // / It always contains one or more conditionally available substitutions
2822
+ // / followed by a universally available type used as a fallback.
2823
+ Optional<MutableArrayRef<ConditionallyAvailableSubstitutions *>>
2824
+ ConditionallyAvailableTypes = None;
2849
2825
2850
2826
mutable Identifier OpaqueReturnTypeIdentifier;
2851
2827
@@ -2932,14 +2908,15 @@ class OpaqueTypeDecl final :
2932
2908
UniqueUnderlyingType = subs;
2933
2909
}
2934
2910
2935
- void setConditionallyAvailableSubstitutions (
2936
- ArrayRef<ConditionallyAvailableSubstitutions *> substitutions) {
2937
- assert (!ConditionallyAvailableTypes &&
2938
- " resetting conditional substitutions?!" );
2939
- ConditionallyAvailableTypes =
2940
- ConditionalAlternatives::get (getASTContext (), substitutions);
2911
+ ArrayRef<ConditionallyAvailableSubstitutions *>
2912
+ getConditionallyAvailableSubstitutions () const {
2913
+ assert (ConditionallyAvailableTypes);
2914
+ return ConditionallyAvailableTypes.getValue ();
2941
2915
}
2942
2916
2917
+ void setConditionallyAvailableSubstitutions (
2918
+ ArrayRef<ConditionallyAvailableSubstitutions *> substitutions);
2919
+
2943
2920
// Opaque type decls are currently always implicit
2944
2921
SourceRange getSourceRange () const { return SourceRange (); }
2945
2922
0 commit comments