Skip to content

Commit c392b3b

Browse files
committed
Remote: demangling of existential metatype with representation
Just drop the representation for now.
1 parent 06dc666 commit c392b3b

File tree

2 files changed

+21
-13
lines changed

2 files changed

+21
-13
lines changed

include/swift/Remote/MetadataReader.h

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,8 @@ class TypeDecoder {
9191
auto mangledName = Demangle::mangleNode(Node);
9292
return Builder.createBuiltinType(mangledName);
9393
}
94+
case NodeKind::Metatype:
9495
case NodeKind::ExistentialMetatype: {
95-
auto instance = decodeMangledType(Node->getChild(0));
96-
if (!instance)
97-
return BuiltType();
98-
return Builder.createExistentialMetatypeType(instance);
99-
}
100-
case NodeKind::Metatype: {
10196
unsigned i = 0;
10297
bool wasAbstract = false;
10398

@@ -116,7 +111,16 @@ class TypeDecoder {
116111
auto instance = decodeMangledType(Node->getChild(i));
117112
if (!instance)
118113
return BuiltType();
119-
return Builder.createMetatypeType(instance, wasAbstract);
114+
if (Node->getKind() == NodeKind::Metatype) {
115+
return Builder.createMetatypeType(instance, wasAbstract);
116+
} else if (Node->getKind() == NodeKind::ExistentialMetatype) {
117+
// FIXME: Ignore representation of existential metatype
118+
// completely for now
119+
return Builder.createExistentialMetatypeType(instance);
120+
} else {
121+
assert(false);
122+
return nullptr;
123+
}
120124
}
121125
case NodeKind::ProtocolList: {
122126
std::vector<BuiltType> protocols;

test/Reflection/capture_descriptors.sil

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,20 @@ import SwiftShims
1313

1414
// Concrete caller and callee -- nothing interesting going on
1515

16-
sil @concrete_callee1 : $@convention(thin) (Int, @owned @box Int, @thin Int.Type) -> () {
17-
bb0(%i: $Int, %b: $@box Int, %m: $@thin Int.Type):
16+
protocol P {}
17+
18+
sil @concrete_callee1 : $@convention(thin) (Int, @owned @box Int, @thin Int.Type, @thick P.Type) -> () {
19+
bb0(%i: $Int, %b: $@box Int, %m: $@thin Int.Type, %p: $@thick P.Type):
1820
%12 = tuple ()
1921
return %12 : $()
2022
}
2123

22-
sil @concrete_caller1 : $@convention(thin) (Int) -> @owned @callee_owned () -> () {
23-
bb0(%i: $Int):
24-
%f = function_ref @concrete_callee1 : $@convention(thin) (Int, @owned @box Int, @thin Int.Type) -> ()
24+
sil @concrete_caller1 : $@convention(thin) (Int, @thick P.Type) -> @owned @callee_owned () -> () {
25+
bb0(%i: $Int, %p: $@thick P.Type):
26+
%f = function_ref @concrete_callee1 : $@convention(thin) (Int, @owned @box Int, @thin Int.Type, @thick P.Type) -> ()
2527
%b = alloc_box $Int
2628
%m = metatype $@thin Int.Type
27-
%c = partial_apply %f(%i, %b, %m) : $@convention(thin) (Int, @owned @box Int, @thin Int.Type) -> ()
29+
%c = partial_apply %f(%i, %b, %m, %p) : $@convention(thin) (Int, @owned @box Int, @thin Int.Type, @thick P.Type) -> ()
2830
return %c : $@callee_owned () -> ()
2931
}
3032

@@ -34,6 +36,8 @@ bb0(%i: $Int):
3436
// CHECK-NEXT: (struct Swift.Int))
3537
// CHECK-NEXT: (metatype
3638
// CHECK-NEXT: (struct Swift.Int))
39+
// CHECK-NEXT: (existential_metatype
40+
// CHECK-NEXT: (protocol capture_descriptors.P))
3741
// CHECK-NEXT: - Metadata sources:
3842

3943

0 commit comments

Comments
 (0)