Skip to content

Commit 452b99a

Browse files
authored
Merge pull request #84799 from hamishknight/round-objects
[AST] Avoid computing `getValueType` in `GenericTypeParamType`'s decl constructor
2 parents 773d327 + d165b6f commit 452b99a

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

lib/AST/Type.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2237,7 +2237,10 @@ GenericTypeParamType::GenericTypeParamType(GenericTypeParamDecl *param,
22372237
Weight = 0;
22382238
Index = param->getIndex();
22392239
ParamKind = param->getParamKind();
2240-
ValueType = param->getValueType();
2240+
// Note we intentionally don't compute `ValueType` here since that could
2241+
// trigger a request cycle with the interface type computation of the
2242+
// GenericTypeParamDecl. Instead, `getValueType` forwards the query to the
2243+
// decl.
22412244
}
22422245

22432246
GenericTypeParamType::GenericTypeParamType(Identifier name,
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// {"kind":"typecheck","original":"06207482","signature":"swift::InferredGenericSignatureRequest::evaluate(swift::Evaluator&, swift::GenericSignatureImpl const*, swift::GenericParamList*, swift::WhereClauseOwner, llvm::SmallVector<swift::Requirement, 2u>, llvm::SmallVector<swift::TypeBase*, 2u>, swift::SourceLoc, swift::ExtensionDecl*, bool) const","signatureAssert":"Assertion failed: (isa<To>(Val) && \"cast<Ty>() argument of incompatible type!\"), function cast"}
2+
// RUN: %target-typecheck-verify-swift
3+
@available(SwiftStdlib 6.2, *)
4+
class a<let b: b> {
5+
// expected-error@-1 {{circular reference}}
6+
// expected-note@-2 {{through reference here}}
7+
// expected-note@-3 {{while resolving type 'b'}}
8+
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
// {"kind":"typecheck","signature":"swift::GenericContext::getGenericSignature() const","signatureAssert":"Assertion failed: (isa<To>(Val) && \"cast<Ty>() argument of incompatible type!\"), function cast"}
2-
// RUN: not --crash %target-swift-frontend -typecheck %s
2+
// RUN: not %target-swift-frontend -typecheck %s
33
struct a < let b : c
44
class c < b : a
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
// {"kind":"typecheck","signature":"swift::TypeResolution::applyUnboundGenericArguments(swift::GenericTypeDecl*, swift::Type, swift::SourceLoc, llvm::ArrayRef<swift::Type>) const","signatureAssert":"Assertion failed: (isa<To>(Val) && \"cast<Ty>() argument of incompatible type!\"), function cast"}
2-
// RUN: not --crash %target-swift-frontend -typecheck %s
2+
// RUN: not %target-swift-frontend -typecheck %s
33
enum a < let b : a<Int>> {
44
}

0 commit comments

Comments
 (0)