Skip to content

Commit 0b3747d

Browse files
committed
Revert "[CS] Record fix when encountering decl reference with placeholder type"
This reverts commit 8102e39.
1 parent 6279849 commit 0b3747d

File tree

4 files changed

+0
-71
lines changed

4 files changed

+0
-71
lines changed

include/swift/Sema/CSFix.h

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -362,9 +362,6 @@ enum class FixKind : uint8_t {
362362
/// resolved.
363363
SpecifyTypeForPlaceholder,
364364

365-
/// Ignore an invalid placeholder in a decl's interface type.
366-
IgnoreInvalidPlaceholderInDeclRef,
367-
368365
/// Allow Swift -> C pointer conversion in an argument position
369366
/// of a Swift function.
370367
AllowSwiftToCPointerConversion,
@@ -3194,30 +3191,6 @@ class SpecifyTypeForPlaceholder final : public ConstraintFix {
31943191
}
31953192
};
31963193

3197-
class IgnoreInvalidPlaceholderInDeclRef final : public ConstraintFix {
3198-
IgnoreInvalidPlaceholderInDeclRef(ConstraintSystem &cs,
3199-
ConstraintLocator *locator)
3200-
: ConstraintFix(cs, FixKind::IgnoreInvalidPlaceholderInDeclRef, locator) {}
3201-
3202-
public:
3203-
std::string getName() const override {
3204-
return "ignore invalid placeholder in decl ref";
3205-
}
3206-
3207-
bool diagnose(const Solution &solution, bool asNote = false) const override;
3208-
3209-
bool diagnoseForAmbiguity(CommonFixesArray commonFixes) const override {
3210-
return diagnose(*commonFixes.front().first);
3211-
}
3212-
3213-
static IgnoreInvalidPlaceholderInDeclRef *create(ConstraintSystem &cs,
3214-
ConstraintLocator *locator);
3215-
3216-
static bool classof(const ConstraintFix *fix) {
3217-
return fix->getKind() == FixKind::IgnoreInvalidPlaceholderInDeclRef;
3218-
}
3219-
};
3220-
32213194
class AllowRefToInvalidDecl final : public ConstraintFix {
32223195
AllowRefToInvalidDecl(ConstraintSystem &cs, ConstraintLocator *locator)
32233196
: ConstraintFix(cs, FixKind::AllowRefToInvalidDecl, locator) {}

lib/Sema/CSFix.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2264,20 +2264,6 @@ SpecifyTypeForPlaceholder::create(ConstraintSystem &cs,
22642264
return new (cs.getAllocator()) SpecifyTypeForPlaceholder(cs, locator);
22652265
}
22662266

2267-
IgnoreInvalidPlaceholderInDeclRef *
2268-
IgnoreInvalidPlaceholderInDeclRef::create(ConstraintSystem &cs, ConstraintLocator *locator) {
2269-
return new (cs.getAllocator()) IgnoreInvalidPlaceholderInDeclRef(cs, locator);
2270-
}
2271-
2272-
bool
2273-
IgnoreInvalidPlaceholderInDeclRef::diagnose(const Solution &solution,
2274-
bool asNote) const {
2275-
// These are diagnosed separately. Unfortunately we can't enforce that a
2276-
// diagnostic has already been emitted since their diagnosis depends on e.g
2277-
// type-checking a function body for a placeholder result of a function.
2278-
return true;
2279-
}
2280-
22812267
bool AllowRefToInvalidDecl::diagnose(const Solution &solution,
22822268
bool asNote) const {
22832269
ReferenceToInvalidDeclaration failure(solution, getLocator());

lib/Sema/CSSimplify.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16099,7 +16099,6 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyFixConstraint(
1609916099
case FixKind::AllowValueExpansionWithoutPackReferences:
1610016100
case FixKind::IgnoreInvalidPatternInExpr:
1610116101
case FixKind::IgnoreInvalidPlaceholder:
16102-
case FixKind::IgnoreInvalidPlaceholderInDeclRef:
1610316102
case FixKind::IgnoreOutOfPlaceThenStmt:
1610416103
case FixKind::IgnoreMissingEachKeyword:
1610516104
case FixKind::AllowInlineArrayLiteralCountMismatch:

lib/Sema/TypeOfReference.cpp

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,31 +1084,6 @@ static Type replaceParamErrorTypeByPlaceholder(Type type, ValueDecl *value, bool
10841084
funcType->getExtInfo());
10851085
}
10861086

1087-
/// We allow placeholder types in interface types in certain cases to allow
1088-
/// better recovery since we can suggest the inferred type as a replacement.
1089-
/// When referencing those decls though we need to make sure we record a fix
1090-
/// since we cannot form a valid solution with them.
1091-
static void
1092-
recordFixIfNeededForPlaceholderInDecl(ConstraintSystem &cs, ValueDecl *D,
1093-
ConstraintLocatorBuilder locator) {
1094-
auto mayHavePlaceholder = [&]() -> bool {
1095-
// Parameters with types may have placeholders, since this allows us to
1096-
// suggest an inferred type from a default argument. Match the logic in
1097-
// `getUnopenedTypeOfReference` and only query the interface type if we have
1098-
// one already.
1099-
if (auto *PD = dyn_cast<ParamDecl>(D))
1100-
return PD->hasInterfaceType();
1101-
1102-
// Therefore decls with parameter lists may also have placeholders.
1103-
return D->getParameterList();
1104-
};
1105-
if (!mayHavePlaceholder() || !D->getInterfaceType()->hasPlaceholder())
1106-
return;
1107-
1108-
auto *loc = cs.getConstraintLocator(locator);
1109-
cs.recordFix(IgnoreInvalidPlaceholderInDeclRef::create(cs, loc));
1110-
}
1111-
11121087
std::pair<Type, Type>
11131088
ConstraintSystem::getTypeOfReferencePre(OverloadChoice choice,
11141089
DeclContext *useDC,
@@ -1118,8 +1093,6 @@ ConstraintSystem::getTypeOfReferencePre(OverloadChoice choice,
11181093

11191094
ASSERT(!!preparedOverload == PreparingOverload);
11201095

1121-
recordFixIfNeededForPlaceholderInDecl(*this, value, locator);
1122-
11231096
if (value->getDeclContext()->isTypeContext() && isa<FuncDecl>(value)) {
11241097
// Unqualified lookup can find operator names within nominal types.
11251098
auto func = cast<FuncDecl>(value);
@@ -1877,8 +1850,6 @@ ConstraintSystem::getTypeOfMemberReferencePre(
18771850
auto *value = choice.getDecl();
18781851
auto functionRefInfo = choice.getFunctionRefInfo();
18791852

1880-
recordFixIfNeededForPlaceholderInDecl(*this, value, locator);
1881-
18821853
// Figure out the instance type used for the base.
18831854
auto baseTy = choice.getBaseType();
18841855
Type baseRValueTy = baseTy->getRValueType();

0 commit comments

Comments
 (0)