-
Notifications
You must be signed in to change notification settings - Fork 5
arrays.equals and nullabe TerminalNodes #8
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
base: master
Are you sure you want to change the base?
Conversation
added Arrays.equals for IntArray and nullable Arrays
There is a compilation error:
|
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.
A few things to revise but it seems we are on the good direction
return equals(a!!, b!!) | ||
} | ||
|
||
expect class BitSet() { |
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.
why did you remove the constructor from BitSet?
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 only moved the constructor so it is right after the classname 'BitSet()'. There is no difference semantically.
val a = o as ArrayPredictionContext? | ||
TODO() | ||
//return Arrays.equals(returnStates, a!!.returnStates) && Arrays.equals(parents, a.parents) | ||
o as ArrayPredictionContext |
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.
why casting it if we do not save it?
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.
So the compiler can infer the type later. IntelliJ uses the same trick when generating equals(). Maybe it's a hack, I'm not sure.
@@ -705,11 +705,11 @@ RuleContextDecl(r) ::= "var <r.name>: <r.ctxName>? = null" | |||
RuleContextListDecl(rdecl) ::= "var <rdecl.name> : MutableList\<<rdecl.ctxName>> = ArrayList\<<rdecl.ctxName>>()" | |||
|
|||
ContextTokenGetterDecl(t) ::= | |||
"fun <t.name>() : TerminalNode = getToken(<parser.name>.Tokens.<t.name>.id, 0) as TerminalNode" | |||
"fun <t.name>() : TerminalNode? = getToken(<parser.name>.Tokens.<t.name>.id, 0)" |
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.
Probably making these types nullable is causing the compilation issue we see on Travis
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.
Yes. I probably need to update some of the dependent code as well.
fix imports of generated sources
sourceSets { | ||
generated { | ||
kotlin.srcDir 'generated-src/antlr/' | ||
} | ||
} | ||
compileKotlin.source sourceSets.generated.kotlin, sourceSets.main.kotlin | ||
|
||
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.
Why removing this?
implemented Arrays.equals for nullable and primitive integer types.
TerminalNodes from ContextTokenGetter are nullable