Skip to content

Commit 1c4132f

Browse files
committed
[AST] Remove the use of UnresolvedType in replacingTypeVariablesAndPlaceholders
Now that ErrorType prints as `_`, we can use that instead of UnresolvedType here since the original type is only really used for type printing and debugging.
1 parent 52a163f commit 1c4132f

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

lib/AST/ASTContext.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3605,13 +3605,9 @@ static Type replacingTypeVariablesAndPlaceholders(Type ty) {
36053605
if (!ty->hasTypeVariableOrPlaceholder())
36063606
return ty;
36073607

3608-
// Match the logic in `Solution::simplifyType` and use UnresolvedType.
3609-
// FIXME: Ideally we'd get rid of UnresolvedType and just use a fresh
3610-
// PlaceholderType, but we don't currently support placeholders with no
3611-
// originators.
36123608
auto *typePtr = ty.getPointer();
36133609
if (isa<TypeVariableType>(typePtr) || isa<PlaceholderType>(typePtr))
3614-
return ctx.TheUnresolvedType;
3610+
return ErrorType::get(ctx);
36153611

36163612
return std::nullopt;
36173613
});
@@ -3620,7 +3616,14 @@ static Type replacingTypeVariablesAndPlaceholders(Type ty) {
36203616
Type ErrorType::get(Type originalType) {
36213617
// The original type is only used for printing/debugging, and we don't support
36223618
// solver-allocated ErrorTypes. As such, fold any type variables and
3623-
// placeholders into UnresolvedTypes, which print as placeholders.
3619+
// placeholders into bare ErrorTypes, which print as placeholders.
3620+
//
3621+
// FIXME: If the originalType is itself an ErrorType we ought to be flattening
3622+
// it, but that's currently load-bearing as it avoids crashing for recursive
3623+
// generic signatures such as in `0120-rdar34184392.swift`. To fix this we
3624+
// ought to change the evaluator to ensure the outer step of a request cycle
3625+
// returns the same default value as the inner step such that we don't end up
3626+
// with conflicting generic signatures on encountering a cycle.
36243627
originalType = replacingTypeVariablesAndPlaceholders(originalType);
36253628

36263629
ASSERT(originalType);

0 commit comments

Comments
 (0)