Skip to content

Commit 2a678f2

Browse files
committed
Sema: Remove TypeResolutionFlags::AllowUnavailable{,Protocol}
1 parent baa9d71 commit 2a678f2

File tree

4 files changed

+11
-28
lines changed

4 files changed

+11
-28
lines changed

lib/Sema/PreCheckExpr.cpp

+1-4
Original file line numberDiff line numberDiff line change
@@ -1326,11 +1326,8 @@ TypeExpr *PreCheckExpression::simplifyNestedTypeExpr(UnresolvedDotExpr *UDE) {
13261326
// Fold 'T.U' into a nested type.
13271327
if (auto *ITR = dyn_cast<IdentTypeRepr>(InnerTypeRepr)) {
13281328
// Resolve the TypeRepr to get the base type for the lookup.
1329-
// Disable availability diagnostics here, because the final
1330-
// TypeRepr will be resolved again when generating constraints.
13311329
const auto options =
1332-
TypeResolutionOptions(TypeResolverContext::InExpression) |
1333-
TypeResolutionFlags::AllowUnavailable;
1330+
TypeResolutionOptions(TypeResolverContext::InExpression);
13341331
const auto resolution =
13351332
TypeResolution::forContextual(DC, options, [](auto unboundTy) {
13361333
// FIXME: Don't let unbound generic types escape type resolution.

lib/Sema/TypeCheckRequestFunctions.cpp

+2-6
Original file line numberDiff line numberDiff line change
@@ -30,31 +30,27 @@ Type InheritedTypeRequest::evaluate(
3030
llvm::PointerUnion<const TypeDecl *, const ExtensionDecl *> decl,
3131
unsigned index, TypeResolutionStage stage) const {
3232
// Figure out how to resolve types.
33-
TypeResolutionOptions options = None;
3433
DeclContext *dc;
3534
if (auto typeDecl = decl.dyn_cast<const TypeDecl *>()) {
3635
if (auto nominal = dyn_cast<NominalTypeDecl>(typeDecl)) {
3736
dc = (DeclContext *)nominal;
38-
39-
options |= TypeResolutionFlags::AllowUnavailableProtocol;
4037
} else {
4138
dc = typeDecl->getDeclContext();
4239
}
4340
} else {
4441
dc = (DeclContext *)decl.get<const ExtensionDecl *>();
45-
options |= TypeResolutionFlags::AllowUnavailableProtocol;
4642
}
4743

4844
Optional<TypeResolution> resolution;
4945
switch (stage) {
5046
case TypeResolutionStage::Structural:
5147
resolution =
52-
TypeResolution::forStructural(dc, options, /*unboundTyOpener*/ nullptr);
48+
TypeResolution::forStructural(dc, None, /*unboundTyOpener*/ nullptr);
5349
break;
5450

5551
case TypeResolutionStage::Interface:
5652
resolution =
57-
TypeResolution::forInterface(dc, options, /*unboundTyOpener*/ nullptr);
53+
TypeResolution::forInterface(dc, None, /*unboundTyOpener*/ nullptr);
5854
break;
5955

6056
case TypeResolutionStage::Contextual: {

lib/Sema/TypeCheckType.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,6 @@ static TypeResolutionOptions
575575
adjustOptionsForGenericArgs(TypeResolutionOptions options) {
576576
options.setContext(None);
577577
options -= TypeResolutionFlags::SILType;
578-
options -= TypeResolutionFlags::AllowUnavailableProtocol;
579578

580579
return options;
581580
}
@@ -1878,9 +1877,6 @@ NeverNullType TypeResolver::resolveType(TypeRepr *repr,
18781877
options.setContext(None);
18791878
}
18801879

1881-
if (getASTContext().LangOpts.DisableAvailabilityChecking)
1882-
options |= TypeResolutionFlags::AllowUnavailable;
1883-
18841880
bool isDirect = false;
18851881
if ((options & TypeResolutionFlags::Direct) && !isa<SpecifierTypeRepr>(repr)){
18861882
isDirect = true;

lib/Sema/TypeCheckType.h

+8-14
Original file line numberDiff line numberDiff line change
@@ -36,37 +36,31 @@ enum class TypeResolutionFlags : uint16_t {
3636
/// Whether to allow unspecified types within a pattern.
3737
AllowUnspecifiedTypes = 1 << 0,
3838

39-
/// Whether an unavailable protocol can be referenced.
40-
AllowUnavailableProtocol = 1 << 1,
41-
42-
/// Whether we should allow references to unavailable types.
43-
AllowUnavailable = 1 << 2,
44-
4539
/// Whether the given type can override the type of a typed pattern.
46-
OverrideType = 1 << 3,
40+
OverrideType = 1 << 1,
4741

4842
/// Whether we are validating the type for SIL.
4943
// FIXME: Move this flag to TypeResolverContext.
50-
SILType = 1 << 4,
44+
SILType = 1 << 2,
5145

5246
/// Whether we are parsing a SIL file. Not the same as SILType,
5347
/// because the latter is not set if we're parsing an AST type.
54-
SILMode = 1 << 5,
48+
SILMode = 1 << 3,
5549

5650
/// Whether this is a resolution based on a non-inferred type pattern.
57-
FromNonInferredPattern = 1 << 6,
51+
FromNonInferredPattern = 1 << 4,
5852

5953
/// Whether we are at the direct base of a type expression.
60-
Direct = 1 << 7,
54+
Direct = 1 << 5,
6155

6256
/// Whether we should not produce diagnostics if the type is invalid.
63-
SilenceErrors = 1 << 8,
57+
SilenceErrors = 1 << 6,
6458

6559
/// Whether to allow module declaration types.
66-
AllowModule = 1 << 9,
60+
AllowModule = 1 << 7,
6761

6862
/// Make internal @usableFromInline and @inlinable decls visible.
69-
AllowInlinable = 1 << 10,
63+
AllowInlinable = 1 << 8,
7064
};
7165

7266
/// Type resolution contexts that require special handling.

0 commit comments

Comments
 (0)