Skip to content

Commit dd9431a

Browse files
authored
Merge pull request #80215 from tshortli/lazy-serialization-available-attribute-crash
Serialization: Skip invalid `@available` attributes during lazy serialization
2 parents e2718f3 + 3af72e4 commit dd9431a

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lib/Serialization/Serialization.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -3093,7 +3093,11 @@ class Serializer::DeclSerializer : public DeclVisitor<DeclSerializer> {
30933093

30943094
case DeclAttrKind::Available: {
30953095
auto theAttr = D->getSemanticAvailableAttr(cast<AvailableAttr>(DA));
3096-
assert(theAttr);
3096+
3097+
// In lazy typechecking mode, it's possible that we just discovered that
3098+
// the attribute is invalid.
3099+
if (!theAttr)
3100+
return;
30973101

30983102
ENCODE_VER_TUPLE(Introduced, theAttr->getIntroduced())
30993103
ENCODE_VER_TUPLE(Deprecated, theAttr->getDeprecated())
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %target-swift-frontend -swift-version 5 %s -module-name lazy_typecheck -enable-library-evolution -parse-as-library -emit-module -emit-module-path /dev/null -experimental-lazy-typecheck -experimental-skip-non-inlinable-function-bodies -experimental-skip-non-exportable-decls
2+
3+
public protocol P {
4+
func req()
5+
}
6+
7+
@available(macOS, renamed: "P")
8+
@available(iOS, renamed: "P")
9+
@available(tvOS, renamed: "P")
10+
@available(watchOS, renamed: "P")
11+
@available(visionOS, renamed: "P")
12+
public typealias Q = P

0 commit comments

Comments
 (0)