Skip to content

Commit e598f61

Browse files
[ConstraintSystem] Improve check for record SpecifyObjectLiteralTypeImport and fix string description
1 parent f07e21b commit e598f61

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

lib/Sema/CSBindings.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,13 +1045,6 @@ bool TypeVariableBinding::attempt(ConstraintSystem &cs) const {
10451045
cs.DefaultedConstraints.push_back(srcLocator);
10461046

10471047
if (type->isHole()) {
1048-
if (auto * OLE = dyn_cast<ObjectLiteralExpr>(srcLocator->getAnchor())) {
1049-
auto *fix = SpecifyObjectLiteralTypeImport::create(
1050-
cs, TypeVar->getImpl().getLocator());
1051-
if (cs.recordFix(fix))
1052-
return true;
1053-
}
1054-
10551048
if (auto *GP = TypeVar->getImpl().getGenericParameter()) {
10561049
auto path = dstLocator->getPath();
10571050
// Drop `generic parameter` locator element so that all missing
@@ -1066,6 +1059,12 @@ bool TypeVariableBinding::attempt(ConstraintSystem &cs) const {
10661059
cs, TypeVar->getImpl().getLocator());
10671060
if (cs.recordFix(fix))
10681061
return true;
1062+
} else if (auto *OLE = dyn_cast_or_null<ObjectLiteralExpr>(
1063+
srcLocator->getAnchor())) {
1064+
auto *fix = SpecifyObjectLiteralTypeImport::create(
1065+
cs, TypeVar->getImpl().getLocator());
1066+
if (cs.recordFix(fix))
1067+
return true;
10691068
}
10701069
}
10711070
}

lib/Sema/CSFix.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1645,7 +1645,7 @@ class SpecifyObjectLiteralTypeImport final : public ConstraintFix {
16451645

16461646
public:
16471647
std::string getName() const {
1648-
return "specify object literal protocol type import";
1648+
return "import required module to gain access to a default literal type";
16491649
}
16501650

16511651
bool diagnose(bool asNote = false) const;

0 commit comments

Comments
 (0)