Hi guys! I'm having some troubles with Kotlin + An...
# announcements
l
Hi guys! I'm having some troubles with Kotlin + Antlr. I have this class:
Copy code
package br.com.colman.dicehelper


import br.com.colman.dicehelper.br.com.colman.dicehelper.Dice
import org.antlr.runtime.ANTLRStringStream

public fun String.dice(): List<Dice> {
    DiceNotationLexer(ANTLRStringStream(this))
    return emptyList()
}
But the compiler warns me (via gradlew compileKotlin)
Copy code
Type mismatch: inferred type is ANTLRStringStream but CharStream! was expected
ANTLRStringStream is a Java class, and it's definition is
Copy code
public class ANTLRStringStream implements CharStream {
I assume that the "Type Mismatch" is wrong, as ANTLRStringStream is a CharStream, but it seems that the Kotlin compiler isn't very happy. Does anybody know how what is going on here?
I'm on Kotlin 1.5.0
Doing this solves the issue
Copy code
DiceNotationLexer(ANTLRStringStream(this) as CharStream)
However it seems completely unnecessary.