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 {
15451545 // / Retrieve the fixed score of this solution
15461546 Score &getFixedScore () { return FixedScore; }
15471547
1548+ // / Check whether this solution has a fixed binding for the given type
1549+ // / variable.
1550+ bool hasFixedType (TypeVariableType *typeVar) const ;
1551+
15481552 // / Retrieve the fixed type for the given type variable.
15491553 Type getFixedType (TypeVariableType *typeVar) const ;
15501554
Original file line number Diff line number Diff line change 5353using namespace swift ;
5454using namespace constraints ;
5555
56+ bool Solution::hasFixedType (TypeVariableType *typeVar) const {
57+ auto knownBinding = typeBindings.find (typeVar);
58+ return knownBinding != typeBindings.end ();
59+ }
60+
5661// / Retrieve the fixed type for the given type variable.
5762Type Solution::getFixedType (TypeVariableType *typeVar) const {
5863 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 {
13621362 Type (opened.first ).print (out, PO);
13631363 out << " )" ;
13641364 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+ }
13691378 },
13701379 [&]() { out << " , " ; });
13711380 out << " \n " ;
You can’t perform that action at this time.
0 commit comments