Skip to content

Commit 0e637f4

Browse files
committed
IDE: Support for reconstruction of generic parameter types
Mostly fixes the rest of <rdar://problem/36132173>, but we still need to correctly reconstruct dependent member types. That's no longer related to the original problem of subscripts not working though.
1 parent 0018173 commit 0e637f4

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

lib/IDE/TypeReconstruction.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2106,6 +2106,25 @@ VisitNodeWeak(ASTContext *ast,
21062106
}
21072107
}
21082108

2109+
static void
2110+
VisitNodeGenericParam(ASTContext *ast,
2111+
Demangle::NodePointer cur_node,
2112+
VisitNodeResult &result) {
2113+
if (cur_node->getNumChildren() == 2) {
2114+
auto first = cur_node->getChild(0);
2115+
auto second = cur_node->getChild(1);
2116+
if (first->getKind() == Demangle::Node::Kind::Index &&
2117+
second->getKind() == Demangle::Node::Kind::Index) {
2118+
result._types.push_back(
2119+
GenericTypeParamType::get(first->getIndex(),
2120+
second->getIndex(), *ast));
2121+
return;
2122+
}
2123+
}
2124+
2125+
result._error = "bad generic param type";
2126+
}
2127+
21092128
static void VisitFirstChildNode(
21102129
ASTContext *ast,
21112130
Demangle::NodePointer cur_node, VisitNodeResult &result) {
@@ -2275,6 +2294,10 @@ static void VisitNode(
22752294
VisitNodeWeak(ast, node, result);
22762295
break;
22772296

2297+
case Demangle::Node::Kind::DependentGenericParamType:
2298+
VisitNodeGenericParam(ast, node, result);
2299+
break;
2300+
22782301
case Demangle::Node::Kind::LocalDeclName:
22792302
case Demangle::Node::Kind::Identifier:
22802303
case Demangle::Node::Kind::PrivateDeclName:

test/IDE/reconstruct_type_from_mangled_name.swift

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,3 +282,27 @@ struct HasSubscript {
282282
set {}
283283
}
284284
}
285+
286+
// FIXME
287+
// CHECK: decl: FAILURE for 'T' usr=s:14swift_ide_test19HasGenericSubscriptV1Txmfp
288+
struct HasGenericSubscript<T> {
289+
// CHECK: subscript<U>(t: T) -> U { get set } for 'subscript' usr=s:14swift_ide_test19HasGenericSubscriptVyqd__xclui
290+
// FIXME
291+
// CHECK: decl: FAILURE for 'U'
292+
// FIXME
293+
// CHECK: decl: FAILURE for 't'
294+
subscript<U>(_ t: T) -> U {
295+
296+
// CHECK: decl: get {} for '' usr=s:14swift_ide_test19HasGenericSubscriptVyqd__xcluig
297+
// FIXME
298+
// CHECK: dref: FAILURE for 't'
299+
get {
300+
return t as! U
301+
}
302+
303+
// FIXME
304+
// CHECK: dref: FAILURE for 'U'
305+
// CHECK: decl: set {} for '' usr=s:14swift_ide_test19HasGenericSubscriptVyqd__xcluis
306+
set {}
307+
}
308+
}

0 commit comments

Comments
 (0)