// Generated from "j2kt/NullabilityScopes2.java"
@file:Suppress(
 "ALWAYS_NULL",
 "PARAMETER_NAME_CHANGED_ON_OVERRIDE",
 "SENSELESS_COMPARISON",
 "UNCHECKED_CAST",
 "UNNECESSARY_LATEINIT",
 "UNNECESSARY_NOT_NULL_ASSERTION",
 "UNREACHABLE_CODE",
 "UNUSED_ANONYMOUS_PARAMETER",
 "UNUSED_PARAMETER",
 "UNUSED_VARIABLE",
 "USELESS_CAST",
 "VARIABLE_IN_SINGLETON_WITHOUT_THREAD_LOCAL",
 "VARIABLE_WITH_REDUNDANT_INITIALIZER",
 "REDUNDANT_ELSE_IN_WHEN")

package j2kt

import javaemul.lang.*
import j2kt.NullabilityScopes2.NullMarkedScope.Recursive
import java.lang.RuntimeException
import java.util.function.Function
import java.util.stream.Collector
import java.util.stream.Stream
import kotlin.Any
import kotlin.Suppress
import kotlin.collections.MutableList
import kotlin.jvm.JvmStatic

open class NullabilityScopes2 internal constructor() {
 open class NullMarkedScope internal constructor() {
  companion object {
   @JvmStatic
   fun <E> toList(): Collector<E, *, MutableList<E>> {
    throw RuntimeException()
   }
  }

  fun interface Recursive<M: Recursive<M>> {
   fun toList(): MutableList<Recursive<M>>
  }
 }

 open class NonNullMarkedScope<T: Recursive<T>> internal constructor() {
  open fun flatten(recursive: Recursive<T>?): MutableList<Any?>? {
   return recursive!!.toList().stream().map<MutableList<Any?>?>(
    Function { arg0: Recursive<T>? ->
     return@Function this.flatten(arg0)
    },
   ).flatMap<Any?>(
    Function { arg0_1: MutableList<Any?>? ->
     return@Function arg0_1!!.stream()
    } as Function<in MutableList<Any?>?, out Stream<*>>,
   ).collect<MutableList<Any>, Any?>(
    NullMarkedScope.toList<Any>() as Collector<in Any?, Any?, MutableList<Any>>,
   ) as MutableList<Any?>?
  }
 }
}
