0xFF0000FF An integer literal does not conform to the expected type kotlin.Int
Asked Answered
L

2

48

Why doesn't this work:

var color: Int = 0xFF0000FF

and why do I have to call toInt()

var color: Int = 0xFF0000FF.toInt()
Loveless answered 8/10, 2015 at 19:3 Comment(2)
because 0xFF0000FF is not an integer already, so you have to convert it to an integer if you want your color variable to be that type.Isabelleisac
@dubstylee What if I have the same, but for "long" type? converting to long won't help, no? 0xFF0000FFFF0000FF , for example...Mccue
S
47

This is a bug in the compiler, feel free to vote / watch it: https://youtrack.jetbrains.com/issue/KT-2780

Stare answered 8/10, 2015 at 19:58 Comment(5)
Partially under KT-2780, but now the rest of it and the part affecting this is under KT-4749Thunderstorm
As of today it's still a bug in Android/Kotlin ver 1.2.41Dunleavy
Still a bug in Kotlin 1.3.10 :(Chryso
This S.O. question has thousands of views but these kotlin bugs only have dozens of votes. Please take a minute to vote on these issues, if they impacted you.Chryso
The related issue now is youtrack.jetbrains.com/issue/KT-4749Tantivy
C
1

I am using boolean an in my case I was using this way with same error

var shouldShowOnBoarding by remember { mutableStateOf(true) }

Previous import was

import androidx.compose.runtime.Composable

Then I changed it to

import androidx.compose.runtime.*
Charcoal answered 9/11, 2021 at 16:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.