https://kotlinlang.org logo
Title
e

eygraber

05/03/2023, 6:13 PM
If I have the following function:
inline fun <T1, T2, T3, T4, T5, T6, R> combine(
  flow: Flow<T1>,
  flow2: Flow<T2>,
  flow3: Flow<T3>,
  flow4: Flow<T4>,
  flow5: Flow<T5>,
  flow6: Flow<T6>,
  crossinline transform: suspend (T1, T2, T3, T4, T5, T6) -> R
): Flow<R> = kotlinx.coroutines.flow.combine(flow, flow2, flow3, flow4, flow5, flow6) { args: Array<*> ->
  transform(
    args[0] as T1,
    args[1] as T2,
    args[2] as T3,
    args[3] as T4,
    args[4] as T5,
    args[5] as T6
  )
}
It violates
CastNullableToNonNullableType
, but the generic parameters here could be nullable (and in fact I think they are because they're not
* & Any
). Am I missing something here?
b

Brais Gabin

05/03/2023, 7:05 PM
This seems like a false positive indeed.
T1
could be a nullable type. So we shouldn't say anything about that casting. It should only raise an issue if
T1
is defined as
T1 : Any
.
a

Atul Gupta

05/03/2023, 7:48 PM
Hi @eygraber can you create a bug with minimal reproducing code?
e

eygraber

05/03/2023, 7:49 PM
Sure, I'll do that now
a

Atul Gupta

05/03/2023, 9:08 PM
@eygraber you really had very complex project setup and you keep
detekt
on its edge 😒aluting_face:
e

eygraber

05/03/2023, 9:11 PM
A blessing and a curse. Sometimes we can't repro out of the project and we can't share the project 😬