File tree Expand file tree Collapse file tree 3 files changed +22
-4
lines changed Expand file tree Collapse file tree 3 files changed +22
-4
lines changed Original file line number Diff line number Diff line change @@ -1545,6 +1545,10 @@ class Solution {
1545
1545
// / Retrieve the fixed score of this solution
1546
1546
Score &getFixedScore () { return FixedScore; }
1547
1547
1548
+ // / Check whether this solution has a fixed binding for the given type
1549
+ // / variable.
1550
+ bool hasFixedType (TypeVariableType *typeVar) const ;
1551
+
1548
1552
// / Retrieve the fixed type for the given type variable.
1549
1553
Type getFixedType (TypeVariableType *typeVar) const ;
1550
1554
Original file line number Diff line number Diff line change 53
53
using namespace swift ;
54
54
using namespace constraints ;
55
55
56
+ bool Solution::hasFixedType (TypeVariableType *typeVar) const {
57
+ auto knownBinding = typeBindings.find (typeVar);
58
+ return knownBinding != typeBindings.end ();
59
+ }
60
+
56
61
// / Retrieve the fixed type for the given type variable.
57
62
Type Solution::getFixedType (TypeVariableType *typeVar) const {
58
63
auto knownBinding = typeBindings.find (typeVar);
Original file line number Diff line number Diff line change @@ -1362,10 +1362,19 @@ void Solution::dump(raw_ostream &out) const {
1362
1362
Type (opened.first ).print (out, PO);
1363
1363
out << " )" ;
1364
1364
out << " -> " ;
1365
- out << getFixedType (opened.second );
1366
- out << " [from " ;
1367
- Type (opened.second ).print (out, PO);
1368
- out << " ]" ;
1365
+ // Let's check whether the type variable has been bound.
1366
+ // This is important when solver is working on result
1367
+ // builder transformed code, because dependent sub-components
1368
+ // would not have parent type variables but `OpenedTypes`
1369
+ // cannot be erased, so we'll just print them as unbound.
1370
+ if (hasFixedType (opened.second )) {
1371
+ out << getFixedType (opened.second );
1372
+ out << " [from " ;
1373
+ Type (opened.second ).print (out, PO);
1374
+ out << " ]" ;
1375
+ } else {
1376
+ Type (opened.second ).print (out, PO);
1377
+ }
1369
1378
},
1370
1379
[&]() { out << " , " ; });
1371
1380
out << " \n " ;
You can’t perform that action at this time.
0 commit comments