Skip to content

Commit 48ac512

Browse files
committed
[AST] Fold away nested ErrorTypes
Remove the now-unnecessary hack where we could build recursive ErrorTypes.
1 parent 57557de commit 48ac512

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

lib/AST/ASTContext.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3618,15 +3618,11 @@ static Type replacingTypeVariablesAndPlaceholders(Type ty) {
36183618
Type ErrorType::get(Type originalType) {
36193619
// The original type is only used for printing/debugging, and we don't support
36203620
// solver-allocated ErrorTypes. As such, fold any type variables and
3621-
// placeholders into bare ErrorTypes, which print as placeholders.
3622-
//
3623-
// FIXME: If the originalType is itself an ErrorType we ought to be flattening
3624-
// it, but that's currently load-bearing as it avoids crashing for recursive
3625-
// generic signatures such as in `0120-rdar34184392.swift`. To fix this we
3626-
// ought to change the evaluator to ensure the outer step of a request cycle
3627-
// returns the same default value as the inner step such that we don't end up
3628-
// with conflicting generic signatures on encountering a cycle.
3621+
// placeholders into ErrorTypes. If we have a top-level one, we can return
3622+
// that directly.
36293623
originalType = replacingTypeVariablesAndPlaceholders(originalType);
3624+
if (isa<ErrorType>(originalType.getPointer()))
3625+
return originalType;
36303626

36313627
ASSERT(originalType);
36323628
ASSERT(!originalType->getRecursiveProperties().isSolverAllocated() &&

lib/Sema/ConstraintSystem.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1917,9 +1917,6 @@ static Type replacePlaceholderType(PlaceholderType *placeholder,
19171917

19181918
return Type(gp);
19191919
});
1920-
if (isa<TypeVariableType>(replacement.getPointer()))
1921-
return ErrorType::get(ctx);
1922-
19231920
// For completion, we want to produce an archetype instead of an ErrorType
19241921
// for a top-level generic parameter.
19251922
// FIXME: This is pretty weird, we're producing a contextual type outside of
@@ -1930,8 +1927,8 @@ static Type replacePlaceholderType(PlaceholderType *placeholder,
19301927
return GP->getDecl()->getInnermostDeclContext()->mapTypeIntoContext(GP);
19311928
}
19321929
// Return an ErrorType with the replacement as the original type. Note that
1933-
// if we failed to replace a type variable with a generic parameter in a
1934-
// dependent member, `ErrorType::get` will fold it away.
1930+
// if we failed to replace a type variable with a generic parameter,
1931+
// `ErrorType::get` will fold it away.
19351932
return ErrorType::get(replacement);
19361933
}
19371934

0 commit comments

Comments
 (0)