File tree Expand file tree Collapse file tree 2 files changed +27
-7
lines changed
test/Serialization/Inputs Expand file tree Collapse file tree 2 files changed +27
-7
lines changed Original file line number Diff line number Diff line change @@ -3041,13 +3041,22 @@ class OpaqueUnderlyingTypeChecker : public ASTWalker {
3041
3041
3042
3042
SmallVector<AvailabilityCondition, 4 > conditions;
3043
3043
3044
- llvm::transform (availabilityContext->getCond (),
3045
- std::back_inserter (conditions),
3046
- [&](const StmtConditionElement &elt) {
3047
- auto condition = elt.getAvailability ();
3048
- return std::make_pair (condition->getAvailableRange (),
3049
- condition->isUnavailability ());
3050
- });
3044
+ for (const auto &elt : availabilityContext->getCond ()) {
3045
+ auto condition = elt.getAvailability ();
3046
+
3047
+ auto availabilityRange = condition->getAvailableRange ();
3048
+ // If there is no lower endpoint it means that the
3049
+ // current platform is unrelated to this condition
3050
+ // and we can ignore it.
3051
+ if (!availabilityRange.hasLowerEndpoint ())
3052
+ continue ;
3053
+
3054
+ conditions.push_back (
3055
+ {availabilityRange, condition->isUnavailability ()});
3056
+ }
3057
+
3058
+ if (conditions.empty ())
3059
+ continue ;
3051
3060
3052
3061
conditionalSubstitutions.push_back (
3053
3062
OpaqueTypeDecl::ConditionallyAvailableSubstitutions::get (
Original file line number Diff line number Diff line change @@ -67,3 +67,14 @@ public func test_return_from_conditional() -> some P {
67
67
68
68
return Tuple < ( String , Int ) > ( ( " " , 0 ) )
69
69
}
70
+
71
+ // This used to crash during serialization because
72
+ // @available negates availability condition.
73
+ @available ( macOS, unavailable)
74
+ public func testUnusable( ) -> some P {
75
+ if #available( iOS 50 , * ) {
76
+ return Named ( )
77
+ }
78
+
79
+ return Tuple < ( String , Int ) > ( ( " " , 0 ) )
80
+ }
You can’t perform that action at this time.
0 commit comments