Skip to content

Commit 5a735b5

Browse files
committed
RemoteAST: type-check TypeReprs within a TopLevelCodeDecl
instead of just a ModuleDecl. Fixes simple generic types.
1 parent d2c4a4d commit 5a735b5

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

lib/RemoteAST/RemoteAST.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ namespace {
3333
class RemoteASTTypeBuilder {
3434
ASTContext &Ctx;
3535

36-
/// The notional module in which we're writing and type-checking code.
36+
/// The notional context in which we're writing and type-checking code.
3737
/// Created lazily.
38-
ModuleDecl *NotionalModule = nullptr;
38+
DeclContext *NotionalDC = nullptr;
3939

4040
public:
4141
using BuiltType = swift::Type;
@@ -320,21 +320,22 @@ class RemoteASTTypeBuilder {
320320
Demangle::Node::Kind kind);
321321

322322
Type checkTypeRepr(TypeRepr *repr) {
323-
ModuleDecl *module = getNotionalModule();
323+
DeclContext *dc = getNotionalDC();
324324

325325
TypeLoc loc(repr);
326-
if (performTypeLocChecking(Ctx, loc, /*SILType*/ false, module,
326+
if (performTypeLocChecking(Ctx, loc, /*SILType*/ false, dc,
327327
/*diagnose*/ false))
328328
return Type();
329329

330330
return loc.getType();
331331
}
332332

333-
ModuleDecl *getNotionalModule() {
334-
if (!NotionalModule) {
335-
NotionalModule = ModuleDecl::create(Ctx.getIdentifier(".RemoteAST"), Ctx);
333+
DeclContext *getNotionalDC() {
334+
if (!NotionalDC) {
335+
NotionalDC = ModuleDecl::create(Ctx.getIdentifier(".RemoteAST"), Ctx);
336+
NotionalDC = new (Ctx) TopLevelCodeDecl(NotionalDC);
336337
}
337-
return NotionalModule;
338+
return NotionalDC;
338339
}
339340

340341
class TypeReprList {

test/RemoteAST/nominal_types.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,9 @@ printType(G.self)
5353
// CHECK: G
5454
printType(G.Foo.self)
5555
// CHECK: G.Foo
56+
57+
struct H<T, U> {}
58+
printType(H<A,A>.self)
59+
// CHECK: H<A, A>
60+
printType(H<B.Foo, H<B, A>>.self)
61+
// CHECK: H<B.Foo, H<B, A>>

0 commit comments

Comments
 (0)