// Generated from "cast/CastGenerics.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 cast

import javaemul.lang.*
import kotlin.Any
import kotlin.Array
import kotlin.Enum
import kotlin.Error
import kotlin.Int
import kotlin.Number
import kotlin.String
import kotlin.Suppress
import kotlin.jvm.JvmField
import kotlin.jvm.JvmStatic

open class CastGenerics<T, E: Number?> {
 @JvmField
 internal var field_pp_cast: T? = null

 internal open fun method_pp_cast(): T {
  return null as T
 }

 open fun testCastToTypeVariable() {
  val o: Any = Int(1)
  val e: E? = o as E?
  val t: T? = o as T?
  val es: Array<E>? = o as Array<E>?
  val ts: Array<T>? = o as Array<T>?
 }

 open fun <S, V: Enum<V>> testCastToMethodTypeVariable() {
  val o: Any = Int(1)
  val s: S? = o as S?
  var c: Any? = o as CastGenerics<S, Number?>?
  c = o as Array<S>?
  c = o as V?
 }

 open fun testCastToRawToGeneric(foo: Foo<Any?>?): Foo<String?>? {
  return foo as Foo<String?>?
 }

 open fun <TT: Enum<*>> outerGenericMethod() {
  open class Nested<SS> internal constructor() {
   private fun nestedGenericMethod(o: Any?) {
    val t: TT? = o as TT?
   }
  }
 }

 open fun <EE> method(o: Any?): EE where EE: Empty1?, EE: Empty2<EE>? {
  if (o is Empty1) {
   return o as EE
  }
  return null as EE
 }

 companion object {
  @JvmStatic
  fun <T_1, U: T_1> testErasureCast() where T_1: A?, T_1: B? {
   var str: String? = CastGenerics<String?, Number?>().field_pp_cast
   str = CastGenerics<String?, Number?>().method_pp_cast()
   val containerT: Container<T_1>? = null
   containerT!!.get_pp_cast()!!.mA()
   containerT!!.get_pp_cast()!!.mB()
   val containerU: Container<U>? = null
   containerU!!.get_pp_cast()!!.mA()
   containerU!!.get_pp_cast()!!.mB()
   val containerArrT: Container<Array<T_1>?>? = null
   val arrT: Array<T_1>? = containerArrT!!.get_pp_cast()
   arrT!![0]!!.mA()
   arrT!![0]!!.mB()
   var arrA: Array<A?>? = containerArrT!!.get_pp_cast() as Array<A?>?
   var arrB: Array<B?>? = containerArrT!!.get_pp_cast() as Array<B?>?
   val containerArrU: Container<Array<U>?>? = null
   val arrU: Array<U>? = containerArrU!!.get_pp_cast()
   arrU!![0]!!.mA()
   arrU!![0]!!.mB()
   arrA = containerArrU!!.get_pp_cast() as Array<A?>?
   arrB = containerArrU!!.get_pp_cast() as Array<B?>?
   val containerBase: Container<BaseImplementor?>? = null
   containerBase!!.get_pp_cast()!!.mA()
   containerBase!!.get_pp_cast()!!.mB()
   val containerImplementor: Container<Implementor?>? = null
   containerImplementor!!.get_pp_cast()!!.mA()
   containerImplementor!!.get_pp_cast()!!.mB()
   val strictlyA: Container<A?>? = null
   var oA: Any? = strictlyA!!.get_pp_cast()
   var a: A? = strictlyA!!.get_pp_cast()
   val extendsA: Container<out A?>? = null
   oA = extendsA!!.get_pp_cast()
   a = extendsA!!.get_pp_cast()
   val superA: Container<in A?>? = null
   oA = superA!!.get_pp_cast()
   val strictlyString: Container<String?>? = null
   str = strictlyString!!.get_pp_cast()
   val extendsString: Container<out String?>? = null
   str = extendsString!!.get_pp_cast()
   val superString: Container<in String?>? = null
   oA = superString!!.get_pp_cast()
  }

  @JvmStatic
  fun testErasureCastInNullMarkedCode() {
   val container: NullMarkedContainer<out String> = NullMarkedContainer<String>("abc")
   val s: String? = container.get_pp_cast()
  }

  @JvmStatic
  fun testCastToParamterizedType() {
   val o: Any = Int(1)
   var cc: CastGenerics<Error?, Number?>? = o as CastGenerics<Error?, Number?>?
   cc = o as CastGenerics<Error?, Number?>?
  }

  @JvmStatic
  fun <T_1> doSomething(): Foo<T_1>? {
   return object : Foo<T_1>() {}
  }
 }

 fun interface A {
  fun mA()
 }

 fun interface B {
  fun mB()
 }

 abstract class BaseImplementor internal constructor(): A, B

 open class Implementor internal constructor(): BaseImplementor() {
  override fun mA() {}

  override fun mB() {}
 }

 open class Container<T> internal constructor() {
  internal open fun get_pp_cast(): T {
   return null as T
  }
 }

 open class NullMarkedContainer<T: Any> {
  private var value: T

  internal constructor(value: T) {
   this.value = value
  }

  internal open fun get_pp_cast(): T {
   return this.value
  }
 }

 interface Empty1

 interface Empty2<TT>

 open class Foo<V>
}
