https://kotlinlang.org logo
#compose
Title
# compose
t

Tash

11/04/2020, 7:58 PM
Frequently seeing the following build error on
AS 4.2 Canary 15
&
1.0.0-alpha04
:
Copy code
e: java.lang.IllegalArgumentException: Unbound type parameters are forbidden: [Unbound private symbol org.jetbrains.kotlin.ir.symbols.impl.IrTypeParameterSymbolImpl@4decb5a, Unbound private symbol org.jetbrains.kotlin.ir.symbols.impl.IrTypeParameterSymbolImpl@45aa5e3d]
Haven't had success with isolating it to anything in particular. Anyone know what might be causing this?
l

Leland Richardson [G]

11/04/2020, 7:59 PM
is there any more to the stack trace?
i’d be very interested in a minimal repro for this
i think the easiest way to repro would be to bisect / binary search the code by just commenting code out until it succeeds
👍🏼 1
t

Tash

11/04/2020, 8:02 PM
@Leland Richardson [G] Here's the rest of the trace ran with
--stacktrace
i’d be very interested in a minimal repro for this
Let me try commenting stuff out
l

Leland Richardson [G]

11/04/2020, 8:08 PM
i see that that stack trace is from the incremental compiler. it might also be worth seeing if the exception happens / doesn’t happen depending on whether or not you are doing an incremental compile or not
💡 1
t

Tash

11/04/2020, 8:43 PM
Tried turning off incremental comp, seeing a similar failure, albeit different trace ^^ @Leland Richardson [G]
l

Leland Richardson [G]

11/04/2020, 8:45 PM
thanks, good to know. it would be great if you could figure out what code is causing this. it is either a bug in the compose compiler (most likely) or a bug in the kotlin compiler
t

Tash

11/04/2020, 8:46 PM
Still trying to pin it down. Its seems intermittent, so haven't gotten a good series of green builds
Will update this thread if anything turns up
l

Leland Richardson [G]

11/04/2020, 8:48 PM
thanks!
🙏🏼 1
t

Tash

11/04/2020, 9:18 PM
@Leland Richardson [G] Update: A potential candidate seems to be a custom
ViewModelProvider.Factory
that I had created for DI purposes. It is accessed in a Composable via an Ambient like so:
Copy code
@Composable
internal fun ImageScreen() -> Unit) {
    val viewModel = viewModel<ImageViewModel>(factory = ViewModelFactoryAmbient.current)
}
The custom factory itself looks something like this:
Copy code
class ViewModelFactory(...) : ViewModelProvider.Factory {
    @Suppress("UNCHECKED_CAST")
    override fun <T : ViewModel> create(modelClass: Class<T>): T {
        return when {
            modelClass.isAssignableFrom(ImageViewModel::class.java) -> {
                ImageViewModel(...) as T
            }
            else -> throw IllegalArgumentException("...")
        }
    }
}
l

Leland Richardson [G]

11/04/2020, 9:26 PM
if you can come up with a small example that reproduces this, that would be very helpful
👍🏼 1
t

Tash

11/04/2020, 9:26 PM
Ah this looks to be the issue: https://youtrack.jetbrains.com/issue/KT-41006 reportedly fixed in the unreleased kotlin
1.4.20
l

Leland Richardson [G]

11/04/2020, 9:28 PM
ah. nice find
t
Tried with
1.4.20-RC
, but then getting a different error 😅 . I am guessing Compose might need its own updates for
1.4.20
☝️ 1
l

Leland Richardson [G]

11/05/2020, 2:50 AM
yep. we are working on 1.4.20 support, but aren’t there yet
🙏🏼 2
t

Tash

11/05/2020, 8:45 AM
Thank you! For the time being, going to pass the `ViewModel`s around via arguments instead of using the Compose viewinterop
viewModel
method.