File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -917,6 +917,7 @@ namespace {
917
917
class ConstraintGenerator : public ExprVisitor <ConstraintGenerator, Type> {
918
918
ConstraintSystem &CS;
919
919
DeclContext *CurDC;
920
+ ConstraintSystemPhase CurrPhase;
920
921
SmallVector<DeclContext*, 4 > DCStack;
921
922
922
923
static const unsigned numEditorPlaceholderVariables = 2 ;
@@ -1108,9 +1109,16 @@ namespace {
1108
1109
1109
1110
public:
1110
1111
ConstraintGenerator (ConstraintSystem &CS, DeclContext *DC)
1111
- : CS(CS), CurDC(DC ? DC : CS.DC) { }
1112
+ : CS(CS), CurDC(DC ? DC : CS.DC), CurrPhase(CS.getPhase()) {
1113
+ // Although constraint system is initialized in `constraint
1114
+ // generation` phase, we have to set it here manually because e.g.
1115
+ // function builders could generate constraints for its body
1116
+ // in the middle of the solving.
1117
+ CS.setPhase (ConstraintSystemPhase::ConstraintGeneration);
1118
+ }
1112
1119
1113
1120
virtual ~ConstraintGenerator () {
1121
+ CS.setPhase (CurrPhase);
1114
1122
// We really ought to have this assertion:
1115
1123
// assert(DCStack.empty() && CurDC == CS.DC);
1116
1124
// Unfortunately, ASTWalker is really bad at letting us establish
Original file line number Diff line number Diff line change @@ -1536,16 +1536,24 @@ class ConstraintSystem {
1536
1536
};
1537
1537
1538
1538
public:
1539
+ ConstraintSystemPhase getPhase () const { return Phase; }
1540
+
1539
1541
// / Move constraint system to a new phase of its lifetime.
1540
1542
void setPhase (ConstraintSystemPhase newPhase) {
1543
+ if (Phase == newPhase)
1544
+ return ;
1545
+
1541
1546
#ifndef NDEBUG
1542
1547
switch (Phase) {
1543
1548
case ConstraintSystemPhase::ConstraintGeneration:
1544
1549
assert (newPhase == ConstraintSystemPhase::Solving);
1545
1550
break ;
1546
1551
1547
1552
case ConstraintSystemPhase::Solving:
1548
- assert (newPhase == ConstraintSystemPhase::Diagnostics ||
1553
+ // We can come back to constraint generation phase while
1554
+ // processing function builder body.
1555
+ assert (newPhase == ConstraintSystemPhase::ConstraintGeneration ||
1556
+ newPhase == ConstraintSystemPhase::Diagnostics ||
1549
1557
newPhase == ConstraintSystemPhase::Finalization);
1550
1558
break ;
1551
1559
You can’t perform that action at this time.
0 commit comments