Skip to content

Commit f2bd764

Browse files
committed
AST: Fix crash with circular raw value
Fixes rdar://problem/123543175.
1 parent 5f003fd commit f2bd764

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/AST/Decl.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5634,7 +5634,8 @@ EnumDecl::EnumDecl(SourceLoc EnumLoc,
56345634
Type EnumDecl::getRawType() const {
56355635
ASTContext &ctx = getASTContext();
56365636
return evaluateOrDefault(
5637-
ctx.evaluator, EnumRawTypeRequest{const_cast<EnumDecl *>(this)}, Type());
5637+
ctx.evaluator, EnumRawTypeRequest{const_cast<EnumDecl *>(this)},
5638+
ErrorType::get(ctx));
56385639
}
56395640

56405641
void EnumDecl::setRawType(Type rawType) {
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// RUN: %target-typecheck-verify-swift
2+
3+
public enum E : E.R {
4+
// expected-error@-1 {{'E' has a raw type that depends on itself}}
5+
// expected-note@-2 2{{through reference here}}
6+
// expected-note@-3 {{while resolving type 'E.R'}}
7+
// expected-error@-4 {{'R' is not a member type of enum 'rdar123543175.E'}}
8+
// expected-note@-5 {{'E' declared here}}
9+
case x
10+
}

0 commit comments

Comments
 (0)