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

Sylvain Patenaude

12/03/2019, 10:24 PM
Anyone seeing a problem with this extension function?
Copy code
package toto.toto2

@ExperimentalUnsignedTypes
fun UByteArray.toUnsignedInt(): UInt {
    return ...
}
When I try to call it from inside an
object
, like this:
myUInt = myUByteArray.toUnsignedInt()
, I have an Unresolved reference. Thanks in advance!
a

Alexey Belkov [JB]

12/04/2019, 11:38 AM
Failed to reproduce with
Copy code
package toto.toto2
@ExperimentalUnsignedTypes
fun UByteArray.toUnsignedInt(): UInt {
    TODO()
}

object O {
    val myUByteArray: UByteArray = ubyteArrayOf(0u)
    val myUInt = myUByteArray.toUnsignedInt()
}
Can you please share a self-contained example to reproduce?
s

Sylvain Patenaude

12/04/2019, 2:48 PM
I found my problem! For the 1st time, I was adding a file instead of class or object, because I wanted my extension method to be at module/package level instead of class/object level. But the file extension .kt wasn't added to my file name by default. When I renamed my file (from toto to toto.kt), it worked fine.
🆒 1
2 Views