elect
08/26/2019, 4:55 PMIntBuffer, I'm writing an extension function for an Enum, where its companion object extends a specific interface. But if I cast, the compiler says the cast can never succeed.. why?
fun <E> Enum<E>.bind() where E : Enum<E>, E : A = (Enum.Companion as B).buffers[ordinal].bind() // this cast can never succeedSam Schilling
08/26/2019, 5:01 PMelect
08/26/2019, 5:01 PMEnum.Companion as Belect
08/26/2019, 5:01 PMUnitSam Schilling
08/26/2019, 5:02 PMjw
08/26/2019, 5:02 PMEnum class, not the companion of the receiverelect
08/26/2019, 5:03 PMRuckus
08/26/2019, 5:08 PMDominaezzz
08/26/2019, 5:16 PMEnum<E> with an interface that can return it's "companion object". Won't be type safe but .... it works 😅.Ruckus
08/26/2019, 5:31 PMbind to accept a Belect
08/26/2019, 5:35 PMDominaezzz
08/26/2019, 5:36 PMelect
08/26/2019, 5:40 PMelect
08/26/2019, 5:41 PMRuckus
08/26/2019, 5:43 PMDominaezzz
08/26/2019, 5:44 PMGlBufE can have a method that returns an instance of GlBufEco.elect
08/26/2019, 5:44 PMRuckus
08/26/2019, 5:49 PMfun <E> E.bind(... instead of Enum<E>.bind(...)Ruckus
08/26/2019, 6:00 PMDominaezzz
08/26/2019, 6:09 PMT : Enum<T>.Ruckus
08/26/2019, 6:14 PMbind infinitely recursive?Dominaezzz
08/26/2019, 6:17 PMbind.Dominaezzz
08/26/2019, 6:18 PMbind just be a member at this point.elect
08/27/2019, 8:04 AMfun <T> T.bind(target: BufferTarget) where T : Enum<T>, T : GlBufE = T.buffers[ordinal].bind(target) I get:
Error:(182, 70) Kotlin: Type parameter 'T' cannot have or inherit a companion object, so it cannot be on the left hand side of dot
elect
08/27/2019, 8:05 AMfun <T> T.bind(target: BufferTarget) where T : Enum<T>, T : GlBufE = buffers[ordinal].bind(target)elect
08/27/2019, 8:06 AMDominaezzz
08/27/2019, 8:13 AM