I'm implementing the kotlin language spec (<https://github.com/Kotlin/kotlin-spec/blob/release/gramm...
a
I'm implementing the kotlin language spec (https://github.com/Kotlin/kotlin-spec/blob/release/grammar/src/main/antlr/KotlinParser.g4#L254) as a hobby project and am a bit confused by the following rule: typeReference : userType | DYNAMIC ; Based on the definition of userType "dynamic" should be valid, so will DYNAMIC ever match?
e
lexed as a keyword before getting to the parser
a
Oh interesting! So userType by definition can never be "dynamic"? I noticed DYNAMIC is also a part "simpleIdentifier" (which is used to define userType)
e
hmm good point, I didn't spot that
a
As a test I tried parsing the word "dynamic" with the compiled KotlinParser from the kotlin-spec repo, and it resolved to "userType"
Also if there is a better channel please let me know 🙏
e
#compiler maybe
d
Yes,
dynamic
in type position is always parsed as intrinsic type for js even if there is a class named
dynamic
Copy code
class dynamic // (1)

fun foo() {
    val x: dynamic /* dynamic type */ = dynamic() // constructor of (1)
}