Skip to content

[Sema] Remove workaround from TypeExpr::createForSpecializedDecl #76444

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
30 changes: 0 additions & 30 deletions lib/AST/Expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2295,36 +2295,6 @@ TypeExpr *TypeExpr::createForSpecializedDecl(DeclRefTypeRepr *ParentTR,
specializedTR->setValue(boundDecl, ParentTR->getDeclContext());
} else {
auto *const qualIdentTR = cast<QualifiedIdentTypeRepr>(ParentTR);
if (isa<TypeAliasDecl>(boundDecl)) {
// If any of our parent types are unbound, bail out and let
// the constraint solver can infer generic parameters for them.
//
// This is because a type like GenericClass.GenericAlias<Int>
// cannot be represented directly.
//
// This also means that [GenericClass.GenericAlias<Int>]()
// won't parse correctly, whereas if we fully specialize
// GenericClass, it does.
//
// FIXME: Once we can model generic typealiases properly, rip
// this out.
QualifiedIdentTypeRepr *currTR = qualIdentTR;
while (auto *declRefBaseTR =
dyn_cast<DeclRefTypeRepr>(currTR->getBase())) {
if (!declRefBaseTR->hasGenericArgList()) {
auto *decl =
dyn_cast_or_null<GenericTypeDecl>(declRefBaseTR->getBoundDecl());
if (decl && decl->isGeneric())
return nullptr;
}

currTR = dyn_cast<QualifiedIdentTypeRepr>(declRefBaseTR);
if (!currTR) {
break;
}
}
}

specializedTR = QualifiedIdentTypeRepr::create(
C, qualIdentTR->getBase(), ParentTR->getNameLoc(),
ParentTR->getNameRef(), Args, AngleLocs);
Expand Down
8 changes: 8 additions & 0 deletions test/type/array.swift
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,11 @@ do {
// expected-note@-2 {{remove the space between the elements to silence this warning}}{{14-15=}}
]
}

struct TupleWith<T> {
typealias And<U> = (T, U)
}
_ = [TupleWith<String>.And<Int>](repeating: ("", 0), count: 0)
_ = [TupleWith.And<Int>](repeating: ("", 0), count: 0)
_ = [TupleWith<String>.And](repeating: ("", 0), count: 0)
_ = [TupleWith.And](repeating: ("", 0), count: 0)