diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/Types.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/Types.java index 0be710b8cdc5..abfd211ef8c7 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/Types.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/Types.java @@ -201,6 +201,11 @@ public static Types getInstance(CompilerContext context) { public Types(CompilerContext context) { this(context, new Env()); + // TODO: this is a temporary workaround. + // For each new Env we need to have a new allocatedIds map. + // Can't move this to Env init as it belongs to a separate module. + BObjectType.resetAllocatedIds(); + BErrorType.resetAllocatedIds(); } public Types(CompilerContext context, Env typeEnv) { diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/types/BErrorType.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/types/BErrorType.java index 61a3ef50337a..a50fc17936c0 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/types/BErrorType.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/types/BErrorType.java @@ -115,6 +115,10 @@ private SemType semTypeInner() { } } + public static void resetAllocatedIds() { + DistinctIdSupplier.allocatedIds.clear(); + } + private final class DistinctIdSupplier implements Supplier> { private List ids = null; diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/types/BObjectType.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/types/BObjectType.java index 0bb55302e500..3a4589394be7 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/types/BObjectType.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/types/BObjectType.java @@ -248,6 +248,10 @@ public boolean isNullable() { return false; } + public static void resetAllocatedIds() { + DistinctIdSupplier.allocatedIds.clear(); + } + private final class DistinctIdSupplier implements Supplier> { private List ids = null;