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 @@ -3068,13 +3068,22 @@ class OpaqueUnderlyingTypeChecker : public ASTWalker {
30683068
30693069 SmallVector<AvailabilityCondition, 4 > conditions;
30703070
3071- llvm::transform (availabilityContext->getCond (),
3072- std::back_inserter (conditions),
3073- [&](const StmtConditionElement &elt) {
3074- auto condition = elt.getAvailability ();
3075- return std::make_pair (condition->getAvailableRange (),
3076- condition->isUnavailability ());
3077- });
3071+ for (const auto &elt : availabilityContext->getCond ()) {
3072+ auto condition = elt.getAvailability ();
3073+
3074+ auto availabilityRange = condition->getAvailableRange ();
3075+ // If there is no lower endpoint it means that the
3076+ // current platform is unrelated to this condition
3077+ // and we can ignore it.
3078+ if (!availabilityRange.hasLowerEndpoint ())
3079+ continue ;
3080+
3081+ conditions.push_back (
3082+ {availabilityRange, condition->isUnavailability ()});
3083+ }
3084+
3085+ if (conditions.empty ())
3086+ continue ;
30783087
30793088 conditionalSubstitutions.push_back (
30803089 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 {
6767
6868 return Tuple < ( String , Int ) > ( ( " " , 0 ) )
6969}
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