summaryrefslogtreecommitdiff
path: root/src/ir
diff options
context:
space:
mode:
Diffstat (limited to 'src/ir')
-rw-r--r--src/ir/type-updating.cpp2
-rw-r--r--src/ir/type-updating.h7
2 files changed, 8 insertions, 1 deletions
diff --git a/src/ir/type-updating.cpp b/src/ir/type-updating.cpp
index 00f313a2a..67ec4a5c0 100644
--- a/src/ir/type-updating.cpp
+++ b/src/ir/type-updating.cpp
@@ -89,7 +89,7 @@ void GlobalTypeRewriter::update() {
}
// Apply a super, if there is one
- if (auto super = type.getSuperType()) {
+ if (auto super = getSuperType(type)) {
if (auto it = typeIndices.find(*super); it != typeIndices.end()) {
assert(it->second < i);
typeBuilder[i].subTypeOf(typeBuilder[it->second]);
diff --git a/src/ir/type-updating.h b/src/ir/type-updating.h
index 5cd8eef47..e1b5e42a9 100644
--- a/src/ir/type-updating.h
+++ b/src/ir/type-updating.h
@@ -357,6 +357,13 @@ public:
virtual void modifyArray(HeapType oldType, Array& array) {}
virtual void modifySignature(HeapType oldType, Signature& sig) {}
+ // Subclasses can override this method to modify supertypes. The new
+ // supertype, if any, must be a supertype (or the same as) the original
+ // supertype.
+ virtual std::optional<HeapType> getSuperType(HeapType oldType) {
+ return oldType.getSuperType();
+ }
+
// Map an old type to a temp type. This can be called from the above hooks,
// so that they can use a proper temp type of the TypeBuilder while modifying
// things.