Skip to content

Commit 29a04bd

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 fc5d047 commit 29a04bd

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
@@ -7987,8 +7987,10 @@ void TypeChecker::validateDeclForNameLookup(ValueDecl *D) {
79877987
validateAccessControl(typealias);
79887988

79897989
ProtocolRequirementTypeResolver resolver;
7990+
TypeResolutionOptions options =
7991+
TypeResolutionFlags::TypeAliasUnderlyingType;
79907992
if (validateType(typealias->getUnderlyingTypeLoc(),
7991-
typealias, TypeResolutionOptions(), &resolver)) {
7993+
typealias, options, &resolver)) {
79927994
typealias->setInvalid();
79937995
typealias->getUnderlyingTypeLoc().setInvalidType(Context);
79947996
}

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)