Skip to content

Commit 9e34516

Browse files
committed
Sema: Fix validateDeclForNameLookup() to use the right flags when resolving type alias underlying type
Otherwise, we would in some cases reject this idiom, which looks odd at first glance but we do support and users rely on: struct Generic<T> {} protocol P { typealias X = Generic // Equivalent to 'typealias X<T> = Generic<T>' }
1 parent d6b432a commit 9e34516

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/Sema/TypeCheckDecl.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7924,8 +7924,10 @@ void TypeChecker::validateDeclForNameLookup(ValueDecl *D) {
79247924
validateAccessControl(typealias);
79257925

79267926
ProtocolRequirementTypeResolver resolver;
7927+
TypeResolutionOptions options =
7928+
TypeResolutionFlags::TypeAliasUnderlyingType;
79277929
if (validateType(typealias->getUnderlyingTypeLoc(),
7928-
typealias, TypeResolutionOptions(), &resolver)) {
7930+
typealias, options, &resolver)) {
79297931
typealias->setInvalid();
79307932
typealias->getUnderlyingTypeLoc().setInvalidType(Context);
79317933
}

test/decl/typealias/protocol.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,3 +290,12 @@ struct Y11: P11 { }
290290
extension P11 {
291291
func foo(_: X11<Self.A>) { }
292292
}
293+
294+
// Ordering issue
295+
struct SomeConformingType : UnboundGenericAliasProto {
296+
func f(_: G<Int>) {}
297+
}
298+
299+
protocol UnboundGenericAliasProto {
300+
typealias G = X
301+
}

0 commit comments

Comments
 (0)