https://kotlinlang.org logo
#announcements
Title
# announcements
k

karelpeeters

06/19/2017, 1:15 PM
Hey guys, I'm trying out LWJGL and I came accross this piece of code: (https://github.com/Zi0P4tch0/LWJGL-Kotlin-Example/blob/ed8e30bcb0ad5f99a01a4f501461457a0bd9d36f/src/main/kotlin/com/example/Engine.kt#L47). I don't really understand why there's a "kotlin." in front of every type, why is that necessary? It doesn't compile without it, I get the error "Object must be declared abstract or implement abstract base class member public abstract operator fun invoke(p0: Long, p1: Int, p2: Int, p3: Int, p4: Int): Unit defined in org.lwjgl.glfw.GLFWKeyCallback". The definition of the "invoke" method can be found here: (https://github.com/LWJGL/lwjgl3-generated/blob/894ed035ec3037975a344cf719936159a632967b/java/org/lwjgl/glfw/GLFWKeyCallbackI.java#L41)
d

dalexander

06/19/2017, 1:21 PM
karelpeeters: I can’t tell without setting up the project, but I would assume there are multiple “Int” classes in the namespace so it has to specify. You could test this theory by navigating to the definition of plain “Int” after you changing one of the parameters in the signature.
k

karelpeeters

06/19/2017, 1:23 PM
@darienalvarez Yup, turns out that is the case, Int refers to org.lwjgl.system.libffi.Closure.Int, while kotlin.Int refers to the normal Int. Though I can declare Int vals just outside the implementation, and they're the normal ones. I don't really get how that's possible, any idea?
d

dalexander

06/19/2017, 1:30 PM
You at-ed the wrong person by the way 🙂
Um, I’m not very familiar with the specifics of type resolution. I would assume there’s something going on with the import statements that’s causing it to prefer the lwjgl Ints over Kotlin Ints.
k

karelpeeters

06/19/2017, 1:36 PM
@dalexander Ah oops, I hope this is correct? 😄 Strange, I don't import Closure anywhere. I'll read up on type resolution though, maybe I find something.
d

dalexander

06/19/2017, 1:36 PM
Yep, that’s me 🙂
13 Views