Skip to content

Commit b938f96

Browse files
committed
[Diagnostics] NFC: Rename a fix/diagnostic for missing .rawValue reference
1 parent 0f6665c commit b938f96

File tree

5 files changed

+23
-30
lines changed

5 files changed

+23
-30
lines changed

lib/Sema/CSDiagnostics.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6359,8 +6359,7 @@ void MissingRawRepresentableInitFailure::fixIt(
63596359
}
63606360
}
63616361

6362-
void UseOfRawRepresentableInsteadOfItsRawValueFailure::fixIt(
6363-
InFlightDiagnostic &diagnostic) const {
6362+
void MissingRawValueFailure::fixIt(InFlightDiagnostic &diagnostic) const {
63646363
auto *E = getAsExpr(getAnchor());
63656364
if (!E)
63666365
return;

lib/Sema/CSDiagnostics.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2149,13 +2149,10 @@ class MissingRawRepresentableInitFailure final
21492149
/// ```
21502150
///
21512151
/// `E.one` has to use `.rawValue` to match `Int` expected by pattern binding.
2152-
class UseOfRawRepresentableInsteadOfItsRawValueFailure final
2153-
: public AbstractRawRepresentableFailure {
2152+
class MissingRawValueFailure final : public AbstractRawRepresentableFailure {
21542153
public:
2155-
UseOfRawRepresentableInsteadOfItsRawValueFailure(const Solution &solution,
2156-
Type rawReprType,
2157-
Type expectedType,
2158-
ConstraintLocator *locator)
2154+
MissingRawValueFailure(const Solution &solution, Type rawReprType,
2155+
Type expectedType, ConstraintLocator *locator)
21592156
: AbstractRawRepresentableFailure(solution, rawReprType, expectedType,
21602157
locator) {}
21612158

lib/Sema/CSFix.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,19 +1137,17 @@ ExplicitlyConstructRawRepresentable::create(ConstraintSystem &cs,
11371137
cs, rawReprType, expectedType, locator);
11381138
}
11391139

1140-
bool UseValueTypeOfRawRepresentative::diagnose(const Solution &solution,
1141-
bool asNote) const {
1142-
UseOfRawRepresentableInsteadOfItsRawValueFailure failure(
1143-
solution, RawReprType, ExpectedType, getLocator());
1140+
bool UseRawValue::diagnose(const Solution &solution, bool asNote) const {
1141+
MissingRawValueFailure failure(solution, RawReprType, ExpectedType,
1142+
getLocator());
11441143
return failure.diagnose(asNote);
11451144
}
11461145

1147-
UseValueTypeOfRawRepresentative *
1148-
UseValueTypeOfRawRepresentative::create(ConstraintSystem &cs, Type rawReprType,
1149-
Type expectedType,
1150-
ConstraintLocator *locator) {
1146+
UseRawValue *UseRawValue::create(ConstraintSystem &cs, Type rawReprType,
1147+
Type expectedType,
1148+
ConstraintLocator *locator) {
11511149
return new (cs.getAllocator())
1152-
UseValueTypeOfRawRepresentative(cs, rawReprType, expectedType, locator);
1150+
UseRawValue(cs, rawReprType, expectedType, locator);
11531151
}
11541152

11551153
unsigned AllowArgumentMismatch::getParamIdx() const {

lib/Sema/CSFix.h

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,10 @@ enum class FixKind : uint8_t {
213213
/// via forming `Foo(rawValue:)` instead of using its `RawValue` directly.
214214
ExplicitlyConstructRawRepresentable,
215215

216-
/// Use raw value type associated with raw representative accessible
216+
/// Use raw value type associated with raw representable, accessible
217217
/// using `.rawValue` member.
218-
UseValueTypeOfRawRepresentative,
218+
UseRawValue,
219+
219220
/// If an array was passed to a variadic argument, give a specific diagnostic
220221
/// and offer to drop the brackets if it's a literal.
221222
ExpandArrayIntoVarargs,
@@ -264,7 +265,7 @@ enum class FixKind : uint8_t {
264265

265266
/// Allow key path to be bound to a function type with more than 1 argument
266267
AllowMultiArgFuncKeyPathMismatch,
267-
268+
268269
/// Specify key path root type when it cannot be infered from context.
269270
SpecifyKeyPathRootType,
270271

@@ -1617,13 +1618,13 @@ class ExplicitlyConstructRawRepresentable final : public ConstraintFix {
16171618
ConstraintLocator *locator);
16181619
};
16191620

1620-
class UseValueTypeOfRawRepresentative final : public ConstraintFix {
1621+
class UseRawValue final : public ConstraintFix {
16211622
Type RawReprType;
16221623
Type ExpectedType;
16231624

1624-
UseValueTypeOfRawRepresentative(ConstraintSystem &cs, Type rawReprType,
1625-
Type expectedType, ConstraintLocator *locator)
1626-
: ConstraintFix(cs, FixKind::UseValueTypeOfRawRepresentative, locator),
1625+
UseRawValue(ConstraintSystem &cs, Type rawReprType, Type expectedType,
1626+
ConstraintLocator *locator)
1627+
: ConstraintFix(cs, FixKind::UseRawValue, locator),
16271628
RawReprType(rawReprType), ExpectedType(expectedType) {}
16281629

16291630
public:
@@ -1633,10 +1634,8 @@ class UseValueTypeOfRawRepresentative final : public ConstraintFix {
16331634

16341635
bool diagnose(const Solution &solution, bool asNote = false) const override;
16351636

1636-
static UseValueTypeOfRawRepresentative *create(ConstraintSystem &cs,
1637-
Type rawReprType,
1638-
Type expectedType,
1639-
ConstraintLocator *locator);
1637+
static UseRawValue *create(ConstraintSystem &cs, Type rawReprType,
1638+
Type expectedType, ConstraintLocator *locator);
16401639
};
16411640

16421641
/// Replace a coercion ('as') with a forced checked cast ('as!').

lib/Sema/CSSimplify.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3184,7 +3184,7 @@ bool ConstraintSystem::repairFailures(
31843184
if (!isValueOfRawRepresentable(expectedType, rawReprType))
31853185
return false;
31863186

3187-
conversionsOrFixes.push_back(UseValueTypeOfRawRepresentative::create(
3187+
conversionsOrFixes.push_back(UseRawValue::create(
31883188
*this, rawReprType, expectedType, getConstraintLocator(locator)));
31893189
return true;
31903190
};
@@ -9578,7 +9578,7 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyFixConstraint(
95789578
case FixKind::UsePropertyWrapper:
95799579
case FixKind::UseWrappedValue:
95809580
case FixKind::ExpandArrayIntoVarargs:
9581-
case FixKind::UseValueTypeOfRawRepresentative:
9581+
case FixKind::UseRawValue:
95829582
case FixKind::ExplicitlyConstructRawRepresentable:
95839583
case FixKind::SpecifyBaseTypeForContextualMember:
95849584
case FixKind::CoerceToCheckedCast:

0 commit comments

Comments
 (0)