JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
16.35k stars 1.18k forks source link

Cannot find declaration of: remember { ... } #142

Closed atoktoto closed 2 months ago

atoktoto commented 4 years ago

obraz

Workaround: add to imports import androidx.compose.runtime.getValue import androidx.compose.runtime.setValue

igordmn commented 4 years ago

Did you try to sync the project with Gradle?

image

Also can you provide archive with the project and tell what version of IDEA/Kotlin plugin are you using?

atoktoto commented 4 years ago

I've tried to:

The project: https://github.com/atoktoto/compose-experiment (based on a provided desktop template)

Intellj version:

IntelliJ IDEA 2020.2.3 (Ultimate Edition)
Build #IU-202.7660.26, built on October 6, 2020
Subscription is active until December 7, 2020
Runtime version: 11.0.8+10-b944.34 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 10 10.0
GC: ParNew, ConcurrentMarkSweep
Memory: 1979M
Cores: 12
Registry: documentation.show.toolbar=true
Non-Bundled Plugins: org.antlr.intellij.plugin, org.jetbrains.plugins.hocon, org.jetbrains.plugins.vue, io.ktor.intellij.plugin, com.intellij.lang.jsgraphql
igordmn commented 4 years ago

Thanks! Reproduced the issue

Dominaezzz commented 4 years ago

The same thing happens in Android studio and iirc it's intentional since it's an intrinsic.

atoktoto commented 4 years ago

The thing is, it makes it hard to understand what is going on without prior experience in Android dev. I finally found the documentation: https://developer.android.com/reference/kotlin/androidx/compose/runtime/package-summary#remember https://developer.android.com/jetpack/compose/state

It also has a kotlin implementation in source code: https://cs.android.com/androidx/platform/frameworks/support/+/androidx-master-dev:compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Remember.kt?q=remember&ss=androidx%2Fplatform%2Fframeworks%2Fsupport:compose%2Fruntime%2Fruntime%2F

astrodyn commented 4 years ago

I have the same error. Some more information:

remember-bug

and

remember-bug2

Treated with replacement import androidx.compose.runtime.remember to import androidx.compose.runtime.*

IDEA version:

IntelliJ IDEA 2020.3 RC (Community Edition)
Build #IC-203.5981.114, built on November 26, 2020
Runtime version: 11.0.9+11-b1145.21 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Linux 5.8.18-1-manjaro
GC: ParNew, ConcurrentMarkSweep
Memory: 977M
Cores: 2
Non-Bundled Plugins: com.atlassian.bitbucket.references, no.tornado.tornadofx.idea
Current Desktop: KDE

(and earlier versions)

Compose v. 0.2.0-build131 and earlier

Construction val a = remember { .... } works fine...

igordmn commented 4 years ago

Error "has no method" happened because there are no these imports in the file:

import androidx.compose.runtime.getValue
import androidx.compose.runtime.setValue

getValue/setValue are kotlin delegates needed for "var test by" expression.

IDEA doesn't offer to import them if we wrap mutableStateOf in remember, so we have to write them manually.

jimgoog commented 3 years ago

https://youtrack.jetbrains.com/issue/KT-39199

akurasov commented 2 years ago

New Kotlin ticket - https://youtrack.jetbrains.com/issue/KTIJ-20402

okushnikov commented 4 months ago

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.