Skip to content

Commit 94af768

Browse files
committed
[AST] Enforce we don't get solver-allocated ErrorTypes
I don't believe we ever form these types, and if we did we aren't correctly handling them in `Solution::simplifyType`. Let's just enforce we don't get them.
1 parent 450b553 commit 94af768

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

lib/AST/ASTContext.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3577,7 +3577,13 @@ void LocatableType::Profile(llvm::FoldingSetNodeID &id, SourceLoc loc,
35773577
Type ErrorType::get(const ASTContext &C) { return C.TheErrorType; }
35783578

35793579
Type ErrorType::get(Type originalType) {
3580-
assert(originalType);
3580+
ASSERT(originalType);
3581+
// We don't currently support solver-allocated error types, if we want
3582+
// this in the future we'll need to adjust `Solution::simplifyType` to fold
3583+
// them into regular ErrorTypes. Additionally, any clients of
3584+
// `typesSatisfyConstraint` will need to be taught not to pass such types.
3585+
ASSERT(!originalType->getRecursiveProperties().isSolverAllocated() &&
3586+
"Solver-allocated error types not supported");
35813587

35823588
auto originalProperties = originalType->getRecursiveProperties();
35833589
auto arena = getArena(originalProperties);
@@ -3588,14 +3594,8 @@ Type ErrorType::get(Type originalType) {
35883594

35893595
void *mem = ctx.Allocate(sizeof(ErrorType) + sizeof(Type),
35903596
alignof(ErrorType), arena);
3591-
RecursiveTypeProperties properties = RecursiveTypeProperties::HasError;
3592-
3593-
// We need to preserve the solver allocated bit, to ensure any wrapping
3594-
// types are solver allocated too.
3595-
if (originalProperties.isSolverAllocated())
3596-
properties |= RecursiveTypeProperties::SolverAllocated;
3597-
3598-
return entry = new (mem) ErrorType(ctx, originalType, properties);
3597+
return entry = new (mem) ErrorType(ctx, originalType,
3598+
RecursiveTypeProperties::HasError);
35993599
}
36003600

36013601
void ErrorUnionType::Profile(llvm::FoldingSetNodeID &id, ArrayRef<Type> terms) {

0 commit comments

Comments
 (0)