Skip to content

Commit 954b08c

Browse files
committed
[AST] Remove UnresolvedType
We have now removed all uses of this type.
1 parent 5171b84 commit 954b08c

20 files changed

+26
-99
lines changed

include/swift/AST/ASTContext.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1044,7 +1044,6 @@ class ASTContext final {
10441044

10451045
// Builtin type and simple types that are used frequently.
10461046
const CanType TheErrorType; /// This is the ErrorType singleton.
1047-
const CanType TheUnresolvedType; /// This is the UnresolvedType singleton.
10481047
const CanType TheEmptyTupleType; /// This is '()', aka Void
10491048
const CanType TheEmptyPackType;
10501049
const CanType TheAnyType; /// This is 'Any', the empty protocol composition

include/swift/AST/TypeMatcher.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,6 @@ class TypeMatcher {
117117
#define SINGLETON_TYPE(SHORT_ID, ID) TRIVIAL_CASE(ID##Type)
118118
#include "swift/AST/TypeNodes.def"
119119

120-
bool visitUnresolvedType(CanUnresolvedType firstType, Type secondType,
121-
Type sugaredFirstType) {
122-
// Unresolved types never match.
123-
return mismatch(firstType.getPointer(), secondType, sugaredFirstType);
124-
}
125-
126120
bool visitTupleType(CanTupleType firstTuple, Type secondType,
127121
Type sugaredFirstType) {
128122
if (auto secondTuple = secondType->getAs<TupleType>()) {

include/swift/AST/TypeNodes.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@
123123
#if !defined(SINGLETON_TYPE)
124124

125125
TYPE(Error, Type)
126-
UNCHECKED_TYPE(Unresolved, Type)
127126
UNCHECKED_TYPE(Placeholder, Type)
128127
ABSTRACT_TYPE(Builtin, Type)
129128
ABSTRACT_TYPE(AnyBuiltinInteger, BuiltinType)

include/swift/AST/TypeTransform.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ case TypeKind::Id:
109109
#define TYPE(Id, Parent)
110110
#include "swift/AST/TypeNodes.def"
111111
case TypeKind::Error:
112-
case TypeKind::Unresolved:
113112
case TypeKind::TypeVariable:
114113
case TypeKind::Placeholder:
115114
case TypeKind::SILToken:

include/swift/AST/Types.h

Lines changed: 16 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -141,61 +141,58 @@ class RecursiveTypeProperties {
141141
/// This type expression contains a GenericTypeParamType.
142142
HasTypeParameter = 0x04,
143143

144-
/// This type expression contains an UnresolvedType.
145-
HasUnresolvedType = 0x08,
146-
147144
/// Whether this type expression contains an unbound generic type.
148-
HasUnboundGeneric = 0x10,
145+
HasUnboundGeneric = 0x08,
149146

150147
/// This type expression contains an LValueType other than as a
151148
/// function input, and can be loaded to convert to an rvalue.
152-
IsLValue = 0x20,
149+
IsLValue = 0x10,
153150

154151
/// This type expression contains an opened existential ArchetypeType.
155-
HasOpenedExistential = 0x40,
152+
HasOpenedExistential = 0x20,
156153

157154
/// This type expression contains a DynamicSelf type.
158-
HasDynamicSelf = 0x80,
155+
HasDynamicSelf = 0x40,
159156

160157
/// This type contains an Error type.
161-
HasError = 0x100,
158+
HasError = 0x80,
162159

163160
/// This type contains an Error type without an underlying original type.
164-
HasBareError = 0x200,
161+
HasBareError = 0x100,
165162

166163
/// This type contains a DependentMemberType.
167-
HasDependentMember = 0x400,
164+
HasDependentMember = 0x200,
168165

169166
/// This type contains an OpaqueTypeArchetype.
170-
HasOpaqueArchetype = 0x800,
167+
HasOpaqueArchetype = 0x400,
171168

172169
/// This type contains a type placeholder.
173-
HasPlaceholder = 0x1000,
170+
HasPlaceholder = 0x800,
174171

175172
/// This type contains a generic type parameter that is declared as a
176173
/// parameter pack.
177-
HasParameterPack = 0x2000,
174+
HasParameterPack = 0x1000,
178175

179176
/// This type contains a parameterized existential type \c any P<T>.
180-
HasParameterizedExistential = 0x4000,
177+
HasParameterizedExistential = 0x2000,
181178

182179
/// This type contains an ElementArchetypeType.
183-
HasElementArchetype = 0x8000,
180+
HasElementArchetype = 0x4000,
184181

185182
/// Whether the type is allocated in the constraint solver arena. This can
186183
/// differ from \c HasTypeVariable for types such as placeholders, which do
187184
/// not have type variables, but we still want to allocate in the solver if
188185
/// they have a type variable originator.
189-
SolverAllocated = 0x10000,
186+
SolverAllocated = 0x8000,
190187

191188
/// Contains a PackType.
192-
HasPack = 0x20000,
189+
HasPack = 0x10000,
193190

194191
/// Contains a PackArchetypeType. Also implies HasPrimaryArchetype.
195-
HasPackArchetype = 0x40000,
192+
HasPackArchetype = 0x20000,
196193

197194
/// Whether this type contains an unsafe type.
198-
IsUnsafe = 0x080000,
195+
IsUnsafe = 0x040000,
199196

200197
Last_Property = IsUnsafe
201198
};
@@ -228,9 +225,6 @@ class RecursiveTypeProperties {
228225
/// Does a type with these properties have a type parameter somewhere in it?
229226
bool hasTypeParameter() const { return Bits & HasTypeParameter; }
230227

231-
/// Does a type with these properties have an unresolved type somewhere in it?
232-
bool hasUnresolvedType() const { return Bits & HasUnresolvedType; }
233-
234228
/// Is a type with these properties an lvalue?
235229
bool isLValue() const { return Bits & IsLValue; }
236230

@@ -756,11 +750,6 @@ class alignas(1 << TypeAlignInBits) TypeBase
756750
/// member root in a type variable.
757751
bool isTypeVariableOrMember();
758752

759-
/// Determine whether this type involves a UnresolvedType.
760-
bool hasUnresolvedType() const {
761-
return getRecursiveProperties().hasUnresolvedType();
762-
}
763-
764753
/// Determine whether this type involves a \c PlaceholderType.
765754
bool hasPlaceholder() const {
766755
return getRecursiveProperties().hasPlaceholder();
@@ -1712,25 +1701,6 @@ class ErrorType final : public TypeBase {
17121701
}
17131702
};
17141703
DEFINE_EMPTY_CAN_TYPE_WRAPPER(ErrorType, Type)
1715-
1716-
/// UnresolvedType - This represents a type variable that cannot be resolved to
1717-
/// a concrete type because the expression is ambiguous. This is produced when
1718-
/// parsing expressions and producing diagnostics. Any instance of this should
1719-
/// cause the entire expression to be ambiguously typed.
1720-
class UnresolvedType : public TypeBase {
1721-
friend class ASTContext;
1722-
// The Unresolved type is always canonical.
1723-
UnresolvedType(ASTContext &C)
1724-
: TypeBase(TypeKind::Unresolved, &C,
1725-
RecursiveTypeProperties(RecursiveTypeProperties::HasUnresolvedType)) { }
1726-
public:
1727-
// Implement isa/cast/dyncast/etc.
1728-
static bool classof(const TypeBase *T) {
1729-
return T->getKind() == TypeKind::Unresolved;
1730-
}
1731-
};
1732-
DEFINE_EMPTY_CAN_TYPE_WRAPPER(UnresolvedType, Type)
1733-
17341704

17351705
/// BuiltinType - An abstract class for all the builtin types.
17361706
class BuiltinType : public TypeBase {

include/swift/IDE/TypeCheckCompletionCallback.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ struct WithSolutionSpecificVarTypesRAII {
9292
} else {
9393
RestoreVarTypes[var] = Type();
9494
}
95-
if (!ty->hasArchetype() && !ty->hasUnresolvedType()) {
95+
if (!ty->hasArchetype()) {
9696
setInterfaceType(const_cast<VarDecl *>(var), ty);
9797
} else {
9898
setInterfaceType(const_cast<VarDecl *>(var), ErrorType::get(ty));

lib/AST/ASTContext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5856,7 +5856,7 @@ ProtocolConformanceRef ProtocolConformanceRef::forAbstract(
58565856
case TypeKind::GenericTypeParam:
58575857
case TypeKind::TypeVariable:
58585858
case TypeKind::DependentMember:
5859-
case TypeKind::Unresolved:
5859+
case TypeKind::Error:
58605860
case TypeKind::Placeholder:
58615861
case TypeKind::PrimaryArchetype:
58625862
case TypeKind::PackArchetype:

lib/AST/ASTDumper.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6062,8 +6062,6 @@ namespace {
60626062
printFoot();
60636063
}
60646064

6065-
TRIVIAL_TYPE_PRINTER(Unresolved, unresolved)
6066-
60676065
void visitPlaceholderType(PlaceholderType *T, Label label) {
60686066
printCommon("placeholder_type", label);
60696067
auto originator = T->getOriginator();

lib/AST/ASTMangler.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1417,7 +1417,6 @@ void ASTMangler::appendType(Type type, GenericSignature sig,
14171417
llvm_unreachable("Cannot mangle module type yet");
14181418

14191419
case TypeKind::Error:
1420-
case TypeKind::Unresolved:
14211420
case TypeKind::Placeholder:
14221421
appendOperator("Xe");
14231422
return;

lib/AST/ASTPrinter.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6204,14 +6204,6 @@ class TypePrinter : public TypeVisitor<TypePrinter, void, NonRecursivePrintOptio
62046204
}
62056205
}
62066206

6207-
void visitUnresolvedType(UnresolvedType *T,
6208-
NonRecursivePrintOptions nrOptions) {
6209-
if (Options.PrintTypesForDebugging)
6210-
Printer << "<<unresolvedtype>>";
6211-
else
6212-
Printer << "_";
6213-
}
6214-
62156207
void visitErrorUnionType(ErrorUnionType *T,
62166208
NonRecursivePrintOptions nrOptions) {
62176209
Printer << "error_union(";

0 commit comments

Comments
 (0)