-
Notifications
You must be signed in to change notification settings - Fork 758
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reset unknownTypeRefs
after silent type checking
#43758
base: master
Are you sure you want to change the base?
Conversation
This reverts commit 8eed105.
...erina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/TypeChecker.java
Outdated
Show resolved
Hide resolved
@@ -9918,6 +9914,24 @@ String recordsToString(Set<BRecordType> recordTypeSet) { | |||
} | |||
} | |||
|
|||
public GlobalStateData getGlobalStateSnapshotAndResetGlobalState() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we do this via analyzer data instead of introducing a new data holder?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AnalyzerData
act like set of global fields where we pass through the functions. GlobalStateData
is used as a snapshot of several fields where we will be creating multiple of objects of it. However, we can still use the AnalyzerData
for the same purpose. The issue is it will introduce unwanted object creations of the AnalyzerData
which is not clean
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The addition is basically resetting unknown type refs, right? Can we just do it inline instead of introducing GlobalStateData
? The name is ambiguous and can be confusing with analyzer data IMO.
@@ -164,7 +164,7 @@ public class TypeResolver { | |||
private final HashSet<BLangClassDefinition> resolvedClassDef = new HashSet<>(); | |||
private final Map<String, BLangNode> modTable = new LinkedHashMap<>(); | |||
private final Map<String, BLangConstantValue> constantMap = new HashMap<>(); | |||
private final HashSet<LocationData> unknownTypeRefs; | |||
public HashSet<LocationData> unknownTypeRefs; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add a setter instead.
@@ -9933,4 +9945,10 @@ public static class AnalyzerData { | |||
QueryTypeChecker.AnalyzerData queryData = new QueryTypeChecker.AnalyzerData(); | |||
Set<String> queryVariables; | |||
} | |||
|
|||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add documentation (if we continue to keep this).
@@ -9918,6 +9914,24 @@ String recordsToString(Set<BRecordType> recordTypeSet) { | |||
} | |||
} | |||
|
|||
public GlobalStateData getGlobalStateSnapshotAndResetGlobalState() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The addition is basically resetting unknown type refs, right? Can we just do it inline instead of introducing GlobalStateData
? The name is ambiguous and can be confusing with analyzer data IMO.
Purpose
$title
Fixes #43286
Approach
Compiler error at L#1749 was not reached because the field
unknownTypeRefs
was populated at the silent typechecking and does not reset after.ballerina-lang/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SymbolResolver.java
Line 1749 in a6e4f99
Introduced
GlobalStateData
inner class to make the solution scalable for such fields may occur in futureSamples
The following sample should give unknown type error of unknown types
I
andJ
Check List