summaryrefslogtreecommitdiff
path: root/src/passes/StringLowering.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/passes/StringLowering.cpp')
-rw-r--r--src/passes/StringLowering.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/passes/StringLowering.cpp b/src/passes/StringLowering.cpp
index f735b9ab2..fa5c1c9a8 100644
--- a/src/passes/StringLowering.cpp
+++ b/src/passes/StringLowering.cpp
@@ -291,8 +291,9 @@ struct StringLowering : public StringGathering {
// singleton rec group.
std::vector<Type> params, results;
auto fix = [](Type t) {
- if (t.isRef() && t.getHeapType() == HeapType::string) {
- t = Type(HeapType::ext, t.getNullability());
+ if (t.isRef() && t.getHeapType().isMaybeShared(HeapType::string)) {
+ auto share = t.getHeapType().getShared();
+ t = Type(HeapTypes::ext.getBasic(share), t.getNullability());
}
return t;
};
@@ -495,9 +496,13 @@ struct StringLowering : public StringGathering {
void noteSubtype(Expression* a, Type b) {
// This is the case we care about: if |a| is a null that must be a
// subtype of ext then we fix that up.
- if (b.isRef() && b.getHeapType().getTop() == HeapType::ext) {
+ if (!b.isRef()) {
+ return;
+ }
+ HeapType top = b.getHeapType().getTop();
+ if (top.isMaybeShared(HeapType::ext)) {
if (auto* null = a->dynCast<RefNull>()) {
- null->finalize(HeapType::noext);
+ null->finalize(HeapTypes::noext.getBasic(top.getShared()));
}
}
}