Skip to content

Commit 040be29

Browse files
committed
AST: TypeDecl::getDeclaredInterfaceType() always returns a non-empty Type
In the case of circular type aliases, this now returns ErrorType instead of Type().
1 parent edd5105 commit 040be29

File tree

2 files changed

+3
-11
lines changed

2 files changed

+3
-11
lines changed

lib/AST/Decl.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3248,13 +3248,10 @@ Type TypeDecl::getDeclaredInterfaceType() const {
32483248
}
32493249

32503250
Type interfaceType = getInterfaceType();
3251-
if (interfaceType.isNull() || interfaceType->is<ErrorType>())
3252-
return interfaceType;
3253-
3254-
if (isa<ModuleDecl>(this))
3255-
return interfaceType;
3251+
if (!interfaceType)
3252+
return ErrorType::get(getASTContext());
32563253

3257-
return interfaceType->castTo<MetatypeType>()->getInstanceType();
3254+
return interfaceType->getMetatypeInstanceType();
32583255
}
32593256

32603257
int TypeDecl::compare(const TypeDecl *type1, const TypeDecl *type2) {

lib/AST/GenericSignatureBuilder.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3811,8 +3811,6 @@ static Type substituteConcreteType(GenericSignatureBuilder &builder,
38113811
// Form an unsubstituted type referring to the given type declaration,
38123812
// for use in an inferred same-type requirement.
38133813
auto type = getStructuralType(concreteDecl, /*keepSugar=*/true);
3814-
if (!type)
3815-
return Type();
38163814

38173815
SubstitutionMap subMap;
38183816
if (proto) {
@@ -4209,10 +4207,7 @@ ConstraintResult GenericSignatureBuilder::expandConformanceRequirement(
42094207
// within this protocol or a protocol it inherits.
42104208
auto addInferredSameTypeReq = [&](TypeDecl *first, TypeDecl *second) {
42114209
Type firstType = getStructuralType(first, /*keepSugar=*/false);
4212-
if (!firstType) return;
4213-
42144210
Type secondType = getStructuralType(second, /*keepSugar=*/false);
4215-
if (!secondType) return;
42164211

42174212
auto inferredSameTypeSource =
42184213
FloatingRequirementSource::viaProtocolRequirement(

0 commit comments

Comments
 (0)