Skip to content

Commit b2a26af

Browse files
Fix leaking anyimpl ref
1 parent c599a10 commit b2a26af

File tree

1 file changed

+5
-6
lines changed
  • bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/types

1 file changed

+5
-6
lines changed

bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/types/BAnyType.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ public final class BAnyType extends BSemTypeWrapper<BAnyType.BAnyTypeImpl> imple
5050
public BAnyType(String typeName, Module pkg, boolean readonly) {
5151
super(new ConcurrentLazySupplier<>(() -> new BAnyTypeImpl(typeName, pkg, readonly)),
5252
typeName, pkg, TypeTags.ANY_TAG, pickSemType(readonly));
53+
if (!readonly) {
54+
BAnyType immutableAnyType = new BAnyType(TypeConstants.READONLY_ANY_TNAME, pkg, true);
55+
this.getbType().immutableType = new BIntersectionType(pkg, new Type[]{this, PredefinedTypes.TYPE_READONLY},
56+
immutableAnyType, TypeFlags.asMask(TypeFlags.NILABLE), true);
57+
}
5358
}
5459

5560
@Override
@@ -91,12 +96,6 @@ protected static final class BAnyTypeImpl extends BType implements AnyType {
9196
private BAnyTypeImpl(String typeName, Module pkg, boolean readonly) {
9297
super(typeName, pkg, RefValue.class, false);
9398
this.readonly = readonly;
94-
95-
if (!readonly) {
96-
BAnyType immutableAnyType = new BAnyType(TypeConstants.READONLY_ANY_TNAME, pkg, true);
97-
this.immutableType = new BIntersectionType(pkg, new Type[]{this, PredefinedTypes.TYPE_READONLY},
98-
immutableAnyType, TypeFlags.asMask(TypeFlags.NILABLE), true);
99-
}
10099
}
101100

102101
@Override

0 commit comments

Comments
 (0)