Skip to content

Commit 06d2d4c

Browse files
committed
Serialization: Recover from missing raw types on an enum
Recover from a raw type hidden behind an internal or implementation-only import by dropping the whole enum when the raw type is unavailable. This scenario should happen only when looking at non-public decl for indexing or debugging, or if dependencies somehow changed and left behind a stale swiftmodule file. rdar://147091863
1 parent 6358cb9 commit 06d2d4c

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

lib/Serialization/Deserialization.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5037,7 +5037,9 @@ class DeclDeserializer {
50375037
theEnum->setImplicit();
50385038
theEnum->setIsObjC(isObjC);
50395039

5040-
theEnum->setRawType(MF.getType(rawTypeID));
5040+
Type rawType;
5041+
SET_OR_RETURN_ERROR(rawType, MF.getTypeChecked(rawTypeID));
5042+
theEnum->setRawType(rawType);
50415043

50425044
handleInherited(theEnum, inheritedIDs);
50435045

test/Serialization/Recovery/implementation-only-missing.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,24 @@ public protocol HiddenProtocolWithOverride {
6363

6464
public class HiddenClass {}
6565

66+
public struct HiddenRawType: ExpressibleByStringLiteral, Equatable, CustomStringConvertible {
67+
68+
fileprivate var staticValue: String
69+
70+
public init(stringLiteral value: String) {
71+
self.init(value)
72+
}
73+
74+
public init(_ value: String) {
75+
self.staticValue = value
76+
}
77+
78+
public static func == (lhs: HiddenRawType, rhs: HiddenRawType) -> Bool {
79+
return lhs.staticValue == rhs.staticValue
80+
}
81+
82+
public var description: String { self.staticValue }
83+
}
6684

6785
//--- PublicLib.swift
6886

@@ -125,6 +143,10 @@ struct StructInheritingFromComposition : CompositionMemberInheriting & Compositi
125143
class ClassInheritingFromComposition : CompositionMemberInheriting & CompositionMemberSimple {}
126144
protocol InheritingFromCompositionDirect : CompositionMemberSimple & HiddenProtocol2 {}
127145

146+
// rdar://147091863
147+
enum InternalEnumWithRawType: HiddenRawType {
148+
case a
149+
}
128150

129151
//--- Client.swift
130152

0 commit comments

Comments
 (0)