Skip to content

Commit 645fc20

Browse files
committed
AST: TypeAliasDecl::get{Structural,Underlying}Type() always return non-empty Type
Return an ErrorType on circularity instead of Type().
1 parent 88bc5b8 commit 645fc20

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

lib/AST/Decl.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3551,9 +3551,10 @@ void TypeAliasDecl::computeType() {
35513551
}
35523552

35533553
Type TypeAliasDecl::getUnderlyingType() const {
3554-
return evaluateOrDefault(getASTContext().evaluator,
3554+
auto &ctx = getASTContext();
3555+
return evaluateOrDefault(ctx.evaluator,
35553556
UnderlyingTypeRequest{const_cast<TypeAliasDecl *>(this)},
3556-
Type());
3557+
ErrorType::get(ctx));
35573558
}
35583559

35593560
void TypeAliasDecl::setUnderlyingType(Type underlying) {
@@ -3583,10 +3584,11 @@ UnboundGenericType *TypeAliasDecl::getUnboundGenericType() const {
35833584
}
35843585

35853586
Type TypeAliasDecl::getStructuralType() const {
3586-
auto &context = getASTContext();
3587+
auto &ctx = getASTContext();
35873588
return evaluateOrDefault(
3588-
context.evaluator,
3589-
StructuralTypeRequest{const_cast<TypeAliasDecl *>(this)}, Type());
3589+
ctx.evaluator,
3590+
StructuralTypeRequest{const_cast<TypeAliasDecl *>(this)},
3591+
ErrorType::get(ctx));
35903592
}
35913593

35923594
Type AbstractTypeParamDecl::getSuperclass() const {

0 commit comments

Comments
 (0)