Skip to content

Commit 3447dd7

Browse files
committed
[astgen] Set TypeRepr when visiting ParamDecls.
1 parent 6855ca7 commit 3447dd7

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

include/swift/AST/CASTBridging.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ void *BridgedSourceLoc_advanced(void *loc, long len);
144144

145145
void *ParamDecl_create(void *ctx, void *loc, void *_Nullable argLoc,
146146
void *_Nullable argName, void *_Nullable paramLoc,
147-
void *_Nullable paramName, void *declContext);
147+
void *_Nullable paramName, void *_Nullable type,
148+
void *declContext);
148149

149150
void *FuncDecl_create(void *ctx, void *staticLoc, _Bool isStatic, void *funcLoc,
150151
BridgedIdentifier name, void *nameLoc, _Bool isAsync,

lib/AST/CASTBridging.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,13 +183,16 @@ void *ParamDecl_create(void *ctx, void *loc, void *_Nullable argLoc,
183183
BridgedIdentifier _Nullable argName,
184184
void *_Nullable paramLoc,
185185
BridgedIdentifier _Nullable paramName,
186+
void *_Nullable type,
186187
void *declContext) {
187188
ASTContext &Context = *static_cast<ASTContext *>(ctx);
188-
return new (Context) ParamDecl(
189+
auto paramDecl = new (Context) ParamDecl(
189190
getSourceLocFromPointer(loc), getSourceLocFromPointer(argLoc),
190191
Identifier::getFromOpaquePointer(argName),
191192
getSourceLocFromPointer(paramLoc),
192193
Identifier::getFromOpaquePointer(paramName), (DeclContext *)declContext);
194+
paramDecl->setTypeRepr((TypeRepr *)type);
195+
return paramDecl;
193196
}
194197

195198
void *FuncDecl_create(void *ctx, void *staticLoc, bool isStatic, void *funcLoc,

lib/ASTGen/Sources/ASTGen/Decls.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ extension ASTGenVisitor {
8383

8484
let firstName: UnsafeMutableRawPointer?
8585
let secondName: UnsafeMutableRawPointer?
86+
let type: UnsafeMutableRawPointer?
8687

8788
if let nodeFirstName = node.firstName {
8889
var text = nodeFirstName.text
@@ -101,8 +102,14 @@ extension ASTGenVisitor {
101102
} else {
102103
secondName = nil
103104
}
105+
106+
if let typeSyntax = node.type {
107+
type = visit(typeSyntax).rawValue
108+
} else {
109+
type = nil
110+
}
104111

105-
return .decl(ParamDecl_create(ctx, loc, loc, firstName, loc, secondName, declContext))
112+
return .decl(ParamDecl_create(ctx, loc, loc, firstName, loc, secondName, type, declContext))
106113
}
107114

108115
public func visit(_ node: FunctionDeclSyntax) -> ASTNode {

0 commit comments

Comments
 (0)