Skip to content

Commit 4612184

Browse files
authored
Merge pull request #76444 from hamishknight/remove-typealias-special-case
[Sema] Remove workaround from `TypeExpr::createForSpecializedDecl`
2 parents c997778 + 3367d8b commit 4612184

File tree

2 files changed

+8
-30
lines changed

2 files changed

+8
-30
lines changed

lib/AST/Expr.cpp

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2295,36 +2295,6 @@ TypeExpr *TypeExpr::createForSpecializedDecl(DeclRefTypeRepr *ParentTR,
22952295
specializedTR->setValue(boundDecl, ParentTR->getDeclContext());
22962296
} else {
22972297
auto *const qualIdentTR = cast<QualifiedIdentTypeRepr>(ParentTR);
2298-
if (isa<TypeAliasDecl>(boundDecl)) {
2299-
// If any of our parent types are unbound, bail out and let
2300-
// the constraint solver can infer generic parameters for them.
2301-
//
2302-
// This is because a type like GenericClass.GenericAlias<Int>
2303-
// cannot be represented directly.
2304-
//
2305-
// This also means that [GenericClass.GenericAlias<Int>]()
2306-
// won't parse correctly, whereas if we fully specialize
2307-
// GenericClass, it does.
2308-
//
2309-
// FIXME: Once we can model generic typealiases properly, rip
2310-
// this out.
2311-
QualifiedIdentTypeRepr *currTR = qualIdentTR;
2312-
while (auto *declRefBaseTR =
2313-
dyn_cast<DeclRefTypeRepr>(currTR->getBase())) {
2314-
if (!declRefBaseTR->hasGenericArgList()) {
2315-
auto *decl =
2316-
dyn_cast_or_null<GenericTypeDecl>(declRefBaseTR->getBoundDecl());
2317-
if (decl && decl->isGeneric())
2318-
return nullptr;
2319-
}
2320-
2321-
currTR = dyn_cast<QualifiedIdentTypeRepr>(declRefBaseTR);
2322-
if (!currTR) {
2323-
break;
2324-
}
2325-
}
2326-
}
2327-
23282298
specializedTR = QualifiedIdentTypeRepr::create(
23292299
C, qualIdentTR->getBase(), ParentTR->getNameLoc(),
23302300
ParentTR->getNameRef(), Args, AngleLocs);

test/type/array.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,11 @@ do {
126126
// expected-note@-2 {{remove the space between the elements to silence this warning}}{{14-15=}}
127127
]
128128
}
129+
130+
struct TupleWith<T> {
131+
typealias And<U> = (T, U)
132+
}
133+
_ = [TupleWith<String>.And<Int>](repeating: ("", 0), count: 0)
134+
_ = [TupleWith.And<Int>](repeating: ("", 0), count: 0)
135+
_ = [TupleWith<String>.And](repeating: ("", 0), count: 0)
136+
_ = [TupleWith.And](repeating: ("", 0), count: 0)

0 commit comments

Comments
 (0)