Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e1bd903

Browse files
committed
[AST] NFC: Remove DelayedDiag from ErrorTypeRepr
This is no longer used.
1 parent 3ee222f commit e1bd903

File tree

3 files changed

+6
-28
lines changed

3 files changed

+6
-28
lines changed

include/swift/AST/TypeRepr.h

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -216,36 +216,24 @@ class alignas(1 << TypeReprAlignInBits) TypeRepr
216216
/// A TypeRepr for a type with a syntax error. Can be used both as a
217217
/// top-level TypeRepr and as a part of other TypeRepr.
218218
///
219-
/// The client can either emit a detailed diagnostic at the construction time
220-
/// (in the parser) or store a zero-arg diagnostic in this TypeRepr to be
221-
/// emitted after parsing, during type resolution.
222-
///
223219
/// All uses of this type should be ignored and not re-diagnosed.
224220
class ErrorTypeRepr : public TypeRepr {
225221
SourceRange Range;
226-
std::optional<ZeroArgDiagnostic> DelayedDiag;
227222

228-
ErrorTypeRepr(SourceRange Range, std::optional<ZeroArgDiagnostic> Diag)
229-
: TypeRepr(TypeReprKind::Error), Range(Range), DelayedDiag(Diag) {}
223+
ErrorTypeRepr(SourceRange Range)
224+
: TypeRepr(TypeReprKind::Error), Range(Range) {}
230225

231226
public:
232227
static ErrorTypeRepr *
233-
create(ASTContext &Context, SourceRange Range,
234-
std::optional<ZeroArgDiagnostic> DelayedDiag = std::nullopt) {
235-
assert((!DelayedDiag || Range) && "diagnostic needs a location");
236-
return new (Context) ErrorTypeRepr(Range, DelayedDiag);
228+
create(ASTContext &Context, SourceRange Range) {
229+
return new (Context) ErrorTypeRepr(Range);
237230
}
238231

239232
static ErrorTypeRepr *
240-
create(ASTContext &Context, SourceLoc Loc = SourceLoc(),
241-
std::optional<ZeroArgDiagnostic> DelayedDiag = std::nullopt) {
242-
return create(Context, SourceRange(Loc), DelayedDiag);
233+
create(ASTContext &Context, SourceLoc Loc = SourceLoc()) {
234+
return create(Context, SourceRange(Loc));
243235
}
244236

245-
/// If there is a delayed diagnostic stored in this TypeRepr, consumes and
246-
/// emits that diagnostic.
247-
void dischargeDiagnostic(ASTContext &Context);
248-
249237
static bool classof(const TypeRepr *T) {
250238
return T->getKind() == TypeReprKind::Error;
251239
}

lib/AST/TypeRepr.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -970,15 +970,6 @@ void IntegerTypeRepr::printImpl(ASTPrinter &Printer,
970970
Printer.printText(getValue());
971971
}
972972

973-
void ErrorTypeRepr::dischargeDiagnostic(swift::ASTContext &Context) {
974-
if (!DelayedDiag)
975-
return;
976-
977-
// Consume and emit the diagnostic.
978-
Context.Diags.diagnose(Range.Start, *DelayedDiag).highlight(Range);
979-
DelayedDiag = std::nullopt;
980-
}
981-
982973
// See swift/Basic/Statistic.h for declaration: this enables tracing
983974
// TypeReprs, is defined here to avoid too much layering violation / circular
984975
// linkage dependency.

lib/Sema/TypeCheckType.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2766,7 +2766,6 @@ NeverNullType TypeResolver::resolveType(TypeRepr *repr,
27662766

27672767
switch (repr->getKind()) {
27682768
case TypeReprKind::Error:
2769-
cast<ErrorTypeRepr>(repr)->dischargeDiagnostic(getASTContext());
27702769
return ErrorType::get(getASTContext());
27712770

27722771
case TypeReprKind::Attributed:

0 commit comments

Comments
 (0)