Skip to content

Commit 8bee060

Browse files
authored
Merge pull request #10989 from rjmccall/remote-ast-nested-generics
2 parents 7e21faa + 590af0e commit 8bee060

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

lib/RemoteAST/RemoteAST.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ class RemoteASTTypeBuilder {
135135

136136
Type createNominalType(NominalTypeDecl *decl, Type parent) {
137137
// If the declaration is generic, fail.
138-
if (decl->getGenericSignature())
138+
if (decl->getGenericParams())
139139
return Type();
140140

141141
// Validate the parent type.
@@ -148,7 +148,7 @@ class RemoteASTTypeBuilder {
148148
Type createBoundGenericType(NominalTypeDecl *decl, ArrayRef<Type> args,
149149
Type parent) {
150150
// If the declaration isn't generic, fail.
151-
if (!decl->getGenericSignature())
151+
if (!decl->getGenericParams())
152152
return Type();
153153

154154
// Validate the parent type.
@@ -212,9 +212,11 @@ class RemoteASTTypeBuilder {
212212
auto nominal = p->castTo<NominalType>();
213213
simpleComponents.emplace_back(SourceLoc(),
214214
nominal->getDecl()->getName());
215+
simpleComponents.back().setValue(nominal->getDecl());
215216
componentReprs.push_back(&simpleComponents.back());
216217
}
217218
}
219+
componentReprs.push_back(&genericRepr);
218220

219221
CompoundIdentTypeRepr compoundRepr(componentReprs);
220222
genericType = checkTypeRepr(&compoundRepr);

test/RemoteAST/nominal_types.swift

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,27 +50,32 @@ enum G {
5050
case Gwhatever
5151

5252
struct Foo {}
53+
struct Bar<T> {}
5354
}
5455
printType(G.self)
5556
// CHECK: G
5657
printType(G.Foo.self)
5758
// CHECK: G.Foo
59+
printType(G.Bar<A>.self)
60+
// CHECK: G.Bar<A>
5861

59-
struct H<T, U> {}
62+
struct H<T, U> {
63+
struct Foo {}
64+
struct Bar<V, W> {}
65+
}
6066
printType(H<A,A>.self)
6167
// CHECK: H<A, A>
6268
printType(H<B.Foo, H<B, A>>.self)
6369
// CHECK: H<B.Foo, H<B, A>>
70+
printType(H<B, B>.Foo.self)
71+
// CHECK: H<B, B>.Foo
72+
printType(H<A, B>.Bar<B, A>.self)
73+
// CHECK: H<A, B>.Bar<B, A>
6474

6575
class I<T> {}
6676
printType(I<Int>.self)
6777
// CHECK: I<Int>
6878

69-
// None of these are currently permitted by Sema.
70-
// TODO: non-generic types nested in generic types
71-
// TODO: generic types nested in generic types
72-
// TODO: generic types nested in non-generic types
73-
7479
protocol J {}
7580

7681
printType(J.self)

0 commit comments

Comments
 (0)