Skip to content

Fix validateDeclForNameLookup() to use the right flags when resolving type alias underlying type #17061

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/Sema/ITCDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ void IterativeTypeChecker::processResolveTypeDecl(
if (typeAliasDecl->getDeclContext()->isModuleScopeContext() &&
typeAliasDecl->getGenericParams() == nullptr) {
TypeResolutionOptions options =
TypeResolutionFlags::TypeAliasUnderlyingType;
TypeResolutionFlags::TypeAliasUnderlyingType;
if (!typeAliasDecl->getDeclContext()->isCascadingContextForLookup(
/*functionsAreNonCascading*/true)) {
options |= TypeResolutionFlags::KnownNonCascadingDependency;
Expand Down
7 changes: 3 additions & 4 deletions lib/Sema/TypeCheckDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3815,9 +3815,6 @@ void TypeChecker::resolveIsObjC(ValueDecl *VD) {
auto dc = VD->getDeclContext();
if (dc->getAsClassOrClassExtensionContext()) {
// Members of classes can be @objc.

// FIXME: We
validateDeclForNameLookup(VD);
}
else if (isa<ClassDecl>(VD)) {
// Classes can be @objc.
Expand Down Expand Up @@ -7990,8 +7987,10 @@ void TypeChecker::validateDeclForNameLookup(ValueDecl *D) {
validateAccessControl(typealias);

ProtocolRequirementTypeResolver resolver;
TypeResolutionOptions options =
TypeResolutionFlags::TypeAliasUnderlyingType;
if (validateType(typealias->getUnderlyingTypeLoc(),
typealias, TypeResolutionOptions(), &resolver)) {
typealias, options, &resolver)) {
typealias->setInvalid();
typealias->getUnderlyingTypeLoc().setInvalidType(Context);
}
Expand Down
9 changes: 9 additions & 0 deletions test/decl/typealias/protocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -290,3 +290,12 @@ struct Y11: P11 { }
extension P11 {
func foo(_: X11<Self.A>) { }
}

// Ordering issue
struct SomeConformingType : UnboundGenericAliasProto {
func f(_: G<Int>) {}
}

protocol UnboundGenericAliasProto {
typealias G = X
}