Skip to content

Commit 8f065e7

Browse files
committed
Delete TypeChecker::validateType
Inline it into its final user: swift::performTypeLocChecking
1 parent 29cdbe8 commit 8f065e7

File tree

8 files changed

+16
-27
lines changed

8 files changed

+16
-27
lines changed

include/swift/AST/LazyResolver.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#define SWIFT_AST_LAZYRESOLVER_H
1919

2020
#include "swift/AST/ProtocolConformanceRef.h"
21-
#include "swift/AST/TypeLoc.h"
2221
#include "llvm/ADT/PointerEmbeddedInt.h"
2322

2423
namespace swift {

include/swift/Basic/Statistics.def

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,6 @@ FRONTEND_STATISTIC(Sema, NamedLazyMemberLoadSuccessCount)
247247
/// Number of types deserialized.
248248
FRONTEND_STATISTIC(Sema, NumTypesDeserialized)
249249

250-
/// Number of types validated.
251-
FRONTEND_STATISTIC(Sema, NumTypesValidated)
252-
253250
/// Number of lazy iterable declaration contexts left unloaded.
254251
FRONTEND_STATISTIC(Sema, NumUnloadedLazyIterableDeclContexts)
255252

lib/AST/ConformanceLookupTable.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#define SWIFT_AST_CONFORMANCE_LOOKUP_TABLE_H
2222

2323
#include "swift/AST/DeclContext.h"
24-
#include "swift/AST/TypeLoc.h"
2524
#include "swift/Basic/Debug.h"
2625
#include "swift/Basic/LLVM.h"
2726
#include "swift/Basic/SourceLoc.h"

lib/Parse/ParseType.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include "swift/Parse/Parser.h"
1818
#include "swift/AST/ASTWalker.h"
1919
#include "swift/AST/Attr.h"
20-
#include "swift/AST/TypeLoc.h"
2120
#include "swift/AST/TypeRepr.h"
2221
#include "swift/Parse/Lexer.h"
2322
#include "swift/Parse/CodeCompletionCallbacks.h"

lib/Sema/CSGen.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1495,12 +1495,14 @@ namespace {
14951495

14961496
Type resolveTypeReferenceInExpression(TypeRepr *repr,
14971497
TypeResolverContext resCtx) {
1498-
TypeLoc loc(repr);
14991498
TypeResolutionOptions options(resCtx);
15001499
options |= TypeResolutionFlags::AllowUnboundGenerics;
1501-
bool hadError = TypeChecker::validateType(
1502-
loc, TypeResolution::forContextual(CS.DC, options));
1503-
return hadError ? Type() : loc.getType();
1500+
auto result = TypeResolution::forContextual(CS.DC, options)
1501+
.resolveType(repr);
1502+
if (!result || result->hasError()) {
1503+
return Type();
1504+
}
1505+
return result;
15041506
}
15051507

15061508
Type visitTypeExpr(TypeExpr *E) {

lib/Sema/TypeCheckType.cpp

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1688,20 +1688,6 @@ static bool validateAutoClosureAttributeUse(DiagnosticEngine &Diags,
16881688
return !isValid;
16891689
}
16901690

1691-
bool TypeChecker::validateType(TypeLoc &Loc, TypeResolution resolution) {
1692-
// If we've already validated this type, don't do so again.
1693-
if (Loc.wasValidated())
1694-
return Loc.isError();
1695-
1696-
if (auto *Stats = resolution.getASTContext().Stats)
1697-
++Stats->getFrontendCounters().NumTypesValidated;
1698-
1699-
auto type = resolution.resolveType(Loc.getTypeRepr());
1700-
Loc.setType(type);
1701-
1702-
return type->hasError();
1703-
}
1704-
17051691
namespace {
17061692
const auto DefaultParameterConvention = ParameterConvention::Direct_Unowned;
17071693
const auto DefaultResultConvention = ResultConvention::Unowned;
@@ -3898,7 +3884,7 @@ Type CustomAttrTypeRequest::evaluate(Evaluator &eval, CustomAttr *attr,
38983884
// We always require the type to resolve to a nominal type.
38993885
if (!type->getAnyNominal()) {
39003886
assert(ctx.Diags.hadAnyError());
3901-
return Type();
3887+
return ErrorType::get(ctx);
39023888
}
39033889

39043890
return type;

lib/Sema/TypeChecker.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,15 @@ bool swift::performTypeLocChecking(ASTContext &Ctx, TypeLoc &T,
424424
Optional<DiagnosticSuppression> suppression;
425425
if (!ProduceDiagnostics)
426426
suppression.emplace(Ctx.Diags);
427-
return TypeChecker::validateType(T, resolution);
427+
428+
// If we've already validated this type, don't do so again.
429+
if (T.wasValidated()) {
430+
return T.isError();
431+
}
432+
433+
auto type = resolution.resolveType(T.getTypeRepr());
434+
T.setType(type);
435+
return type->hasError();
428436
}
429437

430438
/// Expose TypeChecker's handling of GenericParamList to SIL parsing.

lib/Serialization/ModuleFile.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include "swift/AST/FileUnit.h"
2121
#include "swift/AST/Module.h"
2222
#include "swift/AST/RawComment.h"
23-
#include "swift/AST/TypeLoc.h"
2423
#include "swift/Serialization/Validation.h"
2524
#include "swift/Basic/LLVM.h"
2625
#include "clang/AST/Type.h"

0 commit comments

Comments
 (0)