@@ -69,17 +69,16 @@ enum class ProtocolConformanceKind {
69
69
};
70
70
71
71
// / Describes the state of a protocol conformance, which may be complete,
72
- // / incomplete, or invalid .
72
+ // / incomplete, or currently being checked .
73
73
enum class ProtocolConformanceState {
74
- // / The conformance has been fully checked and is complete and well-formed .
74
+ // / The conformance has been fully checked.
75
75
Complete,
76
76
// / The conformance is known but is not yet complete.
77
77
Incomplete,
78
+ // / The conformance's type witnesses are currently being resolved.
79
+ CheckingTypeWitnesses,
78
80
// / The conformance is being checked.
79
81
Checking,
80
- // / The conformance has been found to be invalid and should not be
81
- // / used.
82
- Invalid
83
82
};
84
83
85
84
// / \brief Describes how a particular type conforms to a given protocol,
@@ -119,19 +118,18 @@ class ProtocolConformance {
119
118
// / Retrieve the state of this conformance.
120
119
ProtocolConformanceState getState () const ;
121
120
122
- // / Determine whether this conformance is complete and well-formed .
121
+ // / Determine whether this conformance is complete.
123
122
bool isComplete () const {
124
123
return getState () == ProtocolConformanceState::Complete;
125
124
}
126
125
127
126
// / Determine whether this conformance is invalid.
128
- bool isInvalid () const {
129
- return getState () == ProtocolConformanceState::Invalid;
130
- }
127
+ bool isInvalid () const ;
131
128
132
129
// / Determine whether this conformance is incomplete.
133
130
bool isIncomplete () const {
134
131
return getState () == ProtocolConformanceState::Incomplete ||
132
+ getState () == ProtocolConformanceState::CheckingTypeWitnesses ||
135
133
getState () == ProtocolConformanceState::Checking;
136
134
}
137
135
@@ -295,7 +293,9 @@ class NormalProtocolConformance : public ProtocolConformance,
295
293
296
294
// / The declaration context containing the ExtensionDecl or
297
295
// / NominalTypeDecl that declared the conformance.
298
- DeclContext *DC;
296
+ // /
297
+ // / Also stores the "invalid" bit.
298
+ llvm::PointerIntPair<DeclContext *, 1 , bool > DCAndInvalid;
299
299
300
300
// / \brief The mapping of individual requirements in the protocol over to
301
301
// / the declarations that satisfy those requirements.
@@ -319,7 +319,7 @@ class NormalProtocolConformance : public ProtocolConformance,
319
319
SourceLoc loc, DeclContext *dc,
320
320
ProtocolConformanceState state)
321
321
: ProtocolConformance(ProtocolConformanceKind::Normal, conformingType),
322
- ProtocolAndState (protocol, state), Loc(loc), DC (dc)
322
+ ProtocolAndState (protocol, state), Loc(loc), DCAndInvalid (dc, false )
323
323
{
324
324
}
325
325
@@ -332,7 +332,7 @@ class NormalProtocolConformance : public ProtocolConformance,
332
332
333
333
// / Get the declaration context that contains the conforming extension or
334
334
// / nominal type declaration.
335
- DeclContext *getDeclContext () const { return DC ; }
335
+ DeclContext *getDeclContext () const { return DCAndInvalid. getPointer () ; }
336
336
337
337
// / Retrieve the state of this conformance.
338
338
ProtocolConformanceState getState () const {
@@ -344,6 +344,12 @@ class NormalProtocolConformance : public ProtocolConformance,
344
344
ProtocolAndState.setInt (state);
345
345
}
346
346
347
+ // / Determine whether this conformance is invalid.
348
+ bool isInvalid () const { return DCAndInvalid.getInt (); }
349
+
350
+ // / Mark this conformance as invalid.
351
+ void setInvalid () { DCAndInvalid.setInt (true ); }
352
+
347
353
// / Retrieve the type witness substitution and type decl (if one exists)
348
354
// / for the given associated type.
349
355
std::pair<const Substitution &, TypeDecl *>
@@ -628,6 +634,10 @@ class InheritedProtocolConformance : public ProtocolConformance,
628
634
}
629
635
};
630
636
637
+ inline bool ProtocolConformance::isInvalid () const {
638
+ return getRootNormalConformance ()->isInvalid ();
639
+ }
640
+
631
641
} // end namespace swift
632
642
633
643
#endif // LLVM_SWIFT_AST_PROTOCOLCONFORMANCE_H
0 commit comments