Skip to content

Commit c27dca3

Browse files
committed
Sema: restrict the options to resolve the structural type of type aliases
1 parent 5bbf06c commit c27dca3

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/AST/Decl.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3437,6 +3437,8 @@ UnboundGenericType *TypeAliasDecl::getUnboundGenericType() const {
34373437
}
34383438

34393439
Type TypeAliasDecl::getStructuralType() const {
3440+
assert(!getGenericParams());
3441+
34403442
auto &context = getASTContext();
34413443
return evaluateOrDefault(context.evaluator,
34423444
StructuralTypeRequest { const_cast<TypeAliasDecl *>(this) },

lib/Sema/TypeCheckGeneric.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1012,7 +1012,13 @@ RequirementRequest::evaluate(Evaluator &evaluator,
10121012
llvm::Expected<Type>
10131013
swift::StructuralTypeRequest::evaluate(Evaluator &evaluator,
10141014
TypeAliasDecl *D) const {
1015+
TypeResolutionOptions options(TypeResolverContext::TypeAliasDecl);
1016+
if (!D->getDeclContext()->isCascadingContextForLookup(
1017+
/*functionsAreNonCascading*/true)) {
1018+
options |= TypeResolutionFlags::KnownNonCascadingDependency;
1019+
}
1020+
10151021
auto typeRepr = D->getUnderlyingTypeLoc().getTypeRepr();
10161022
auto resolution = TypeResolution::forStructural(D);
1017-
return resolution.resolveType(typeRepr, None);
1023+
return resolution.resolveType(typeRepr, options);
10181024
}

0 commit comments

Comments
 (0)