is boxing involved if I do something like ``` inli...
# announcements
e
is boxing involved if I do something like
Copy code
inline class GLEnum0(val i: Int) : A, B

interface A
interface B

fun whatever(param0: A) {} // boxing?
d
Yes, there will be a box. From the documentation:
As a rule of thumb, inline classes are boxed whenever they are used as another type.
e
isn't there a way to obtain that kind of type safety without boxing?
d
That would require actual support from the JVM. What should the method signature of
whatever
be? It has to accept any object of type
A
.
e
@diesieben07 what about this:
Copy code
interface GLtexture {

    val i: Int
    val target: TextureTarget

    // --- [ glIsTexture ] ---

    val valid: Boolean
        get() = GL20C.glIsTexture(i)
}

inline class GLtexture1d(override val i: Int) : GLtexture

fun a(tex: GLTexture1d) {
    override val target: TextureTarget         get() = `1D`
    if(tex.isValid) // boxing?
}
d
Firstly, that does not even compile (
GLtexture1d
does not implement
target
). And secondly, yes, it has to box. What if
valid
does stuff with
this
? What if it puts
this
into a collection, etc.?
e
Sorry, I forgot some pieces
d
Yeah, that still does not compile. But it doesn't matter. Yes, you will get boxing, since the methods you are calling are not aware that they are working on an inline class.