// Generated from "intersectiontype/IntersectionTypeTest.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 intersectiontype

import javaemul.lang.*
import kotlin.Any
import kotlin.Comparable
import kotlin.Int
import kotlin.String
import kotlin.Suppress
import kotlin.jvm.JvmStatic
import kotlin.let

fun interface Getable<T> {
 fun get(): T
}

fun interface Setable {
 fun set(i: Int)
}

interface Serial

fun interface Cmp {
 fun cmp(): Int

 fun defaultM(): Int {
  return 1
 }
}

fun interface Cmp2<T> {
 fun cmp(a: Int): Int
}

open class CmpImpl internal constructor(): Cmp {
 override fun cmp(): Int {
  return 1
 }
}

open class IntersectionTypeTest<U> {
 open fun cast3(s: Any?): Any? {
  return s
 }

 open fun testMethodCall() {
  val o: Any? = IntersectionTypeTest.m()
  IntersectionTypeTest.set(
   o.let { it as A?; it as EmptyA?; it },
  )
  IntersectionTypeTest.set(
   IntersectionTypeTest.m(),
  )
  val g: Getable<*>? = IntersectionTypeTest.n()
 }

 open fun testDefaultMethodCall(o: Any?) {
  o.let { it as Cmp?; it as EmptyA?; it }!!.defaultM()
  o.let { it as CmpImpl?; it as EmptyA?; it }!!.defaultM()
 }

 companion object {
  @JvmStatic
  fun <T> getAndSet(`object`: T) where T: Getable<*>?, T: Setable? {
   `object`!!.set(1)
   `object`!!.get()
  }

  @JvmStatic
  fun <T> cast(o: Any?): Getable<T>? {
   if (o == null) {
    return o.let { it as Getable<T>?; it as Setable?; it }
   }
   return o.let { it as Getable<T>?; it as Setable?; it }
  }

  @JvmStatic
  fun <T> cast1(s: Any?): Getable<Comparable<String>?>? {
   return s.let { it as Getable<Comparable<String>?>?; it as Setable?; it }
  }

  @JvmStatic
  fun <T> cast2(s: Any?): Getable<Comparable<T & Any>?>? {
   return s.let { it as Getable<Comparable<T & Any>?>?; it as Setable?; it }
  }

  @JvmStatic
  fun method(): Cmp? {
   return (Cmp {
    return@Cmp 1
   }).let { it as Cmp; it as Serial; it }
  }

  @JvmStatic
  fun method2(): Cmp2<Any?>? {
   return Cmp2 { a: Int ->
    return@Cmp2 1
   } as Cmp2<Any?>?
  }

  @JvmStatic
  fun testClosureAssignment(o: Any?) {
   val e: A? = o.let { it as A?; it as EmptyA?; it as EmptyB?; it }
   val g: EmptyA? = o.let { it as A?; it as EmptyA?; it as EmptyB?; it }
   val s: EmptyB? = o.let { it as A?; it as EmptyA?; it as EmptyB?; it }
  }

  @JvmStatic
  private fun <T> get(t: T): T {
   return t
  }

  @JvmStatic
  private fun <T> m(): T where T: A?, T: EmptyA? {
   return IntersectionTypeTest.get<Any?>(
    Any(),
   ) as T
  }

  @JvmStatic
  private fun <T> n(): Getable<T>? where T: A?, T: EmptyA? {
   return null
  }

  @JvmStatic
  private fun <T> set(t: T) where T: A?, T: EmptyA? {}

  @JvmStatic
  private fun <T> callOnIntersetionTypes(t: T) where T: SomeConcreteType?, T: Cmp? {
   t!!.cmp()
   null.let { it as SomeConcreteType?; it as Cmp?; it }!!.cmp()
  }

  @JvmStatic
  private fun <T> callOnIntersectionTypeWithParameterizedType(t: T) where T: GenericType<String?>?, T: Getable<Int?>? {
   t!!.doSomething_pp_intersectiontype("")
   t!!.get()
  }

  @JvmStatic
  private fun callOnIntersectionTypeWithRawType() {
   val t = GenericType<String?>().let { it as GenericType<Any?>; it as Getable<Any?>; it }
   (t as GenericType<Any?>).doSomething_pp_intersectiontype("")
   (t as Getable<Any?>).get()
  }
 }

 open inner class MapEntry internal constructor() {
  open fun <T> method(o: Any?): Getable<T>? {
   return o.let { it as Getable<T>?; it as Setable?; it }
  }
 }

 open class A internal constructor()

 interface EmptyA

 interface EmptyB

 open class SomeConcreteType internal constructor()

 open class GenericType<T> internal constructor() {
  internal open fun doSomething_pp_intersectiontype(t: T) {}
 }
}
