Skip to content

Sema: Don't look through nested typealiases when checking for unsupported member reference #32761

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
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
3 changes: 1 addition & 2 deletions lib/Sema/TypeCheckNameLookup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,7 @@ bool TypeChecker::isUnsupportedMemberTypeAccess(Type type, TypeDecl *typeDecl) {
// underlying type is not dependent.
if (auto *aliasDecl = dyn_cast<TypeAliasDecl>(typeDecl)) {
if (!aliasDecl->isGeneric() &&
aliasDecl->getUnderlyingType()->getCanonicalType()
->hasTypeParameter()) {
aliasDecl->getUnderlyingType()->hasTypeParameter()) {
return true;
}
}
Expand Down
6 changes: 5 additions & 1 deletion test/decl/typealias/dependent_types.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ struct X1<T> : P1 {
}
}

struct GenericStruct<T> { // expected-note 2{{generic type 'GenericStruct' declared here}}
struct GenericStruct<T> { // expected-note 3{{generic type 'GenericStruct' declared here}}
typealias Alias = T
typealias MetaAlias = T.Type

typealias Concrete = Int
typealias ReferencesConcrete = Concrete

func methodOne() -> Alias.Type {}
func methodTwo() -> MetaAlias {}
Expand Down Expand Up @@ -59,6 +60,9 @@ let _: GenericStruct.MetaAlias = metaFoo()
// we are OK.
let _: GenericStruct.Concrete = foo()

let _: GenericStruct.ReferencesConcrete = foo()
// expected-error@-1 {{reference to generic type 'GenericStruct' requires arguments in <...>}}

class SuperG<T, U> {
typealias Composed = (T, U)
}
Expand Down