// Generated from "autoboxing/AutoBoxing.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 autoboxing

import javaemul.lang.*
import java.lang.Void
import javaemul.internal.annotations.DoNotAutobox
import jsinterop.annotations.JsMethod
import kotlin.Any
import kotlin.Array
import kotlin.Boolean
import kotlin.Byte
import kotlin.Char
import kotlin.Comparable
import kotlin.Double
import kotlin.Float
import kotlin.Int
import kotlin.Long
import kotlin.Short
import kotlin.String
import kotlin.Suppress
import kotlin.assert
import kotlin.collections.MutableIterable
import kotlin.jvm.JvmField
import kotlin.jvm.JvmStatic
import kotlin.let
import kotlin.run

open class AutoBoxing {
 open fun box(b: Boolean): Boolean? {
  return b
 }

 open fun box(d: Double): Double? {
  return d
 }

 open fun box(b: Byte): Byte? {
  return b
 }

 open fun box(f: Float): Float? {
  return f
 }

 open fun box(i: Int): Int? {
  return i
 }

 open fun box(l: Long): Long? {
  return l
 }

 open fun box(s: Short): Short? {
  return s
 }

 open fun box(c: Char): Char? {
  return c
 }

 open fun unbox(b: Boolean?): Boolean {
  return b!!.booleanValue()
 }

 open fun unbox(d: Double?): Double {
  return d!!.toDouble()
 }

 open fun unbox(b: Byte?): Byte {
  return b!!.toByte()
 }

 open fun unbox(f: Float?): Float {
  return f!!.toFloat()
 }

 open fun unbox(i: Int?): Int {
  return i!!.toInt()
 }

 open fun unbox(l: Long?): Long {
  return l!!.toLong()
 }

 open fun unbox(s: Short?): Short {
  return s!!.toShort()
 }

 open fun unbox(c: Char?): Char {
  return c!!.toChar()
 }

 open fun takesAndReturnsPrimitiveDouble(d: Double): Double {
  return d
 }

 open fun takesAndReturnsVoid(v: Void?): Void? {
  return null
 }

 open fun takesFloatVarArgs(vararg elements: Float?) {
  val elements_1: Array<Float?>? = elements as Array<Float?>?
 }

 open fun takesObjectAndReturnsPrimitiveDouble(@DoNotAutobox o: Any?): Double {
  return o as Double
 }

 open fun sumWithoutBoxing(@DoNotAutobox vararg numbers: Any?): Double {
  val numbers_1: Array<Any?>? = numbers as Array<Any?>?
  var sum: Double = 0.0
  for (number in numbers_1!!) {
   sum = sum + (number as Double?)!!.toDouble()
  }
  return sum
 }

 @JsMethod
 open fun sumWithoutBoxingJsVarargs(@DoNotAutobox vararg numbers: Any?): Double {
  val numbers_1: Array<Any?>? = numbers as Array<Any?>?
  var sum: Double = 0.0
  for (number in numbers_1!!) {
   sum = sum + (number as Double?)!!.toDouble()
  }
  return sum
 }

 open fun sumWithUnboxing(boxedDoubles: MutableIterable<Double?>?): Double {
  var sum: Double = 0.0
  for (d in boxedDoubles!!) {
   val d_1: Double = d!!.toDouble()
   sum = sum + d_1
  }
  return sum
 }

 open fun testBoxing() {
  var bool: Boolean = true
  var d: Double = 2.2
  var b: Byte = 1.toByte()
  var f: Float = 1.1f
  var i: Int = 1
  var l: Long = 2L
  var s: Short = 1.toShort()
  var c: Char = 'a'
  var boxBool: Boolean? = bool
  var boxD: Double? = d
  var boxB: Byte? = b
  var boxF: Float? = f
  var boxI: Int? = i
  var boxL: Long? = l
  var boxS: Short? = s
  var boxC: Char? = c
  boxBool = true
  boxD = 2.2
  boxB = 1.toByte()
  boxF = 1.1f
  boxI = 1
  boxL = 2L
  boxS = 1.toShort()
  boxC = '\u0001'
  boxC = 'a'
  bool = this.unbox(bool)
  d = this.unbox(d)
  b = this.unbox(b)
  f = this.unbox(f)
  i = this.unbox(i)
  l = this.unbox(l)
  s = this.unbox(s)
  c = this.unbox(c)
  var unusedDouble: Double = this.takesObjectAndReturnsPrimitiveDouble(4)
  unusedDouble = this.sumWithoutBoxing(
   1,
   2.2,
   1.toByte(),
   1.toShort(),
   2.2.toFloat(),
  )
  unusedDouble = this.sumWithoutBoxingJsVarargs(
   1,
   2.2,
   1.toByte(),
   1.toShort(),
   2.2.toFloat(),
  )
  this.takesFloatVarArgs(
   1.1f,
   'a'.code.toFloat(),
   2.2.toFloat(),
  )
  var o: Any? = null
  o = 2.2
  o = 1.1f
  o = 1
  o = 'a'
  boxBool = boxBool!!.booleanValue() && boxBool!!.booleanValue()
  boxD = boxD!!.toDouble() + boxD!!.toDouble()
  boxI = boxI!!.toInt() / boxI!!.toInt()
  boxL = boxL!!.toLong() / boxL!!.toLong()
  boxBool = !boxBool!!.booleanValue()
  boxI = + boxI!!.toInt()
  boxI = - boxI!!.toInt()
  boxI = boxI!!.toInt().shl(
   boxI!!.toInt(),
  )
  boxI = boxI!!.toInt().shl(
   boxL!!.toLong().toInt(),
  )
  boxL = boxL!!.toLong().shl(
   boxI!!.toInt(),
  )
  boxL = boxL!!.toLong().shl(
   boxL!!.toLong().toInt(),
  )
  o = 15.let { it as Int; it as Comparable<Int>; it }
 }

 open fun testUnboxing() {
  var boxBool: Boolean? = Boolean(true)
  var boxD: Double? = Double(2.2)
  var boxB: Byte? = Byte(
   1.toByte(),
  )
  var boxF: Float? = Float(1.1f)
  var boxI: Int? = Int(1)
  var boxL: Long? = Long(1L)
  var boxS: Short? = Short(
   1.toShort(),
  )
  var boxC: Char? = Char('a')
  var bool: Boolean = boxBool!!.booleanValue()
  var d: Double = boxD!!.toDouble()
  val b: Byte = boxB!!.toByte()
  var f: Float = boxF!!.toFloat()
  var i: Int = boxI!!.toInt()
  var l: Long = boxL!!.toLong()
  val s: Short = boxS!!.toShort()
  val c: Char = boxC!!.toChar()
  boxBool = this.box(
   boxBool!!.booleanValue(),
  )
  boxD = this.box(
   boxD!!.toDouble(),
  )
  boxB = this.box(
   boxB!!.toByte(),
  )
  boxF = this.box(
   boxF!!.toFloat(),
  )
  boxI = this.box(
   boxI!!.toInt(),
  )
  boxL = this.box(
   boxL!!.toLong(),
  )
  boxS = this.box(
   boxS!!.toShort(),
  )
  boxC = this.box(
   boxC!!.toChar(),
  )
  d = boxB!!.toByte().toDouble()
  d = boxF!!.toFloat().toDouble()
  d = boxI!!.toInt().toDouble()
  d = boxL!!.toLong().toDouble()
  d = boxS!!.toShort().toDouble()
  d = boxC!!.toChar().code.toDouble()
  this.takesAndReturnsPrimitiveDouble(
   boxB!!.toByte().toDouble(),
  )
  this.takesAndReturnsPrimitiveDouble(
   boxF!!.toFloat().toDouble(),
  )
  this.takesAndReturnsPrimitiveDouble(
   boxI!!.toInt().toDouble(),
  )
  this.takesAndReturnsPrimitiveDouble(
   boxL!!.toLong().toDouble(),
  )
  this.takesAndReturnsPrimitiveDouble(
   boxS!!.toShort().toDouble(),
  )
  this.takesAndReturnsPrimitiveDouble(
   boxC!!.toChar().code.toDouble(),
  )
  val v: Void? = this.takesAndReturnsVoid(
   this.takesAndReturnsVoid(null),
  )
  bool = boxBool!!.booleanValue() && boxBool!!.booleanValue()
  d = boxD!!.toDouble() + boxD!!.toDouble()
  f = boxF!!.toFloat() - boxF!!.toFloat()
  i = boxI!!.toInt() * boxI!!.toInt()
  l = boxL!!.toLong() / boxL!!.toLong()
  bool = !boxBool!!.booleanValue()
  i = + boxI!!.toInt()
  i = - boxI!!.toInt()
  i = boxI!!.toInt().inv()
  boxD = - boxD!!.toDouble()
  boxI = - boxI!!.toInt()
  when (boxI!!.toInt()) {
   else -> {}
  }
  i = i + run {
   boxI = boxI!!.toInt() + run {
    i = i + boxI!!.toInt()
    i
   }
   boxI
  }!!.toInt()
  i = i.shl(
   boxI!!.toInt(),
  )
  i = i.shl(
   boxL!!.toLong().toInt(),
  )
  l = l.shl(
   boxI!!.toInt(),
  )
  l = l.shl(
   boxL!!.toLong().toInt(),
  )
 }

 open fun testUnboxingBoolean() {
  var boxB1: Boolean? = Boolean(true)
  val boxB2: Boolean? = Boolean(false)
  var br: Boolean = false
  var boxr: Boolean = false
  boxr = boxB1 === boxB2
  br = boxB1 === boxB2
  assert(boxr)
  assert(br)
  boxr = boxB1 !== boxB2
  br = boxB1 !== boxB2
  assert(boxr)
  assert(br)
  boxr = boxB1!!.booleanValue().xor(
   boxB2!!.booleanValue(),
  )
  br = boxB1!!.booleanValue().xor(
   boxB2!!.booleanValue(),
  )
  assert(boxr)
  assert(br)
  boxr = boxB1!!.booleanValue().and(
   boxB2!!.booleanValue(),
  )
  br = boxB1!!.booleanValue().and(
   boxB2!!.booleanValue(),
  )
  assert(boxr)
  assert(br)
  boxr = boxB1!!.booleanValue().or(
   boxB2!!.booleanValue(),
  )
  br = boxB1!!.booleanValue().or(
   boxB2!!.booleanValue(),
  )
  assert(boxr)
  assert(br)
  boxr = boxB1!!.booleanValue() && boxB2!!.booleanValue()
  br = boxB1!!.booleanValue() && boxB2!!.booleanValue()
  assert(boxr)
  assert(br)
  boxr = boxB1!!.booleanValue() || boxB2!!.booleanValue()
  br = boxB1!!.booleanValue() || boxB2!!.booleanValue()
  assert(boxr)
  assert(br)
  boxr = run {
   boxB1 = boxB2
   boxB1
  }!!.booleanValue()
  br = run {
   boxB1 = boxB2
   boxB1
  }!!.booleanValue()
  assert(boxr)
  assert(br)
  boxr = run {
   boxB1 = boxB1!!.booleanValue().and(
    boxB2!!.booleanValue(),
   )
   boxB1
  }!!.booleanValue()
  br = run {
   boxB1 = boxB1!!.booleanValue().and(
    boxB2!!.booleanValue(),
   )
   boxB1
  }!!.booleanValue()
  assert(boxr)
  assert(br)
  boxr = run {
   boxB1 = boxB1!!.booleanValue().or(
    boxB2!!.booleanValue(),
   )
   boxB1
  }!!.booleanValue()
  br = run {
   boxB1 = boxB1!!.booleanValue().or(
    boxB2!!.booleanValue(),
   )
   boxB1
  }!!.booleanValue()
  assert(boxr)
  assert(br)
  boxr = run {
   boxB1 = boxB1!!.booleanValue().xor(
    boxB2!!.booleanValue(),
   )
   boxB1
  }!!.booleanValue()
  br = run {
   boxB1 = boxB1!!.booleanValue().xor(
    boxB2!!.booleanValue(),
   )
   boxB1
  }!!.booleanValue()
  assert(boxr)
  assert(br)
  var boxB: Boolean? = null
  boxB = !boxB!!.booleanValue()
  boxB = boxB!!.booleanValue() && boxB!!.booleanValue()
  boxB = if (boxB!!.booleanValue()) boxB else boxB
  if (boxB!!.booleanValue()) {}
  var b: Boolean = false
  b = b.or(
   run {
    boxB = boxB!!.booleanValue().or(
     run {
      b = b.or(
       boxB!!.booleanValue(),
      )
      b
     },
    )
    boxB
   }!!.booleanValue(),
  )
 }

 open fun testUnboxingEquality() {
  val boxB: Boolean? = Boolean(true)
  val b: Boolean = false
  assert(boxB === boxB)
  assert(boxB!!.booleanValue() == b)
  assert(b != b)
  assert(b != boxB!!.booleanValue())
  val boxI: Int? = Int(1)
  val i: Int = 1
  assert(boxI === boxI)
  assert(boxI!!.toInt() == i)
  assert(i != i)
  assert(i != boxI!!.toInt())
 }

 open fun testAssertStatement() {
  val boxB: Boolean? = Boolean(true)
  val b: Boolean = true
  assert(boxB!!.booleanValue())
  assert(b)
 }

 open fun testUnbox_withCast() {
  open class Supplier<T> internal constructor() {
   internal open fun get_pp_autoboxing(): T {
    return null as T
   }
  }
  val supplier: Supplier<Int?> = Supplier<Int?>()
  val i: Int = supplier.get_pp_autoboxing()!!.toInt()
 }

 companion object {
  const val COMPILE_TIME_CONSTANT: Float = 1.1f

  @JvmStatic
  private fun acceptsObject(x: Any?) {}

  @JvmStatic
  private fun acceptsInt(x: Int) {}

  @JvmStatic
  private fun acceptsString(x: String?) {}

  @JvmStatic
  private fun testUnboxingGeneric(integerRef: Ref<Int?>?, booleanRef: Ref<Boolean?>?, stringRef: Ref<String?>?) {
   integerRef!!.field_pp_autoboxing = integerRef!!.field_pp_autoboxing
   integerRef!!.field_pp_autoboxing = integerRef!!.field_pp_autoboxing!!.toInt() + 1
   integerRef!!.field_pp_autoboxing = integerRef!!.field_pp_autoboxing!!.toInt() + 1
   AutoBoxing.acceptsInt(
    integerRef!!.field_pp_autoboxing!!.toInt(),
   )
   AutoBoxing.acceptsObject(
    - integerRef!!.field_pp_autoboxing!!.toInt(),
   )
   AutoBoxing.acceptsObject(
    !booleanRef!!.field_pp_autoboxing!!.booleanValue(),
   )
   AutoBoxing.acceptsObject(
    1 + integerRef!!.field_pp_autoboxing!!.toInt(),
   )
   AutoBoxing.acceptsObject(
    booleanRef!!.field_pp_autoboxing!!.booleanValue() || booleanRef!!.field_pp_autoboxing!!.booleanValue(),
   )
   AutoBoxing.acceptsObject(
    "" + stringRef!!.field_pp_autoboxing + stringRef!!.field_pp_autoboxing,
   )
   stringRef!!.field_pp_autoboxing = stringRef!!.field_pp_autoboxing
   AutoBoxing.acceptsString(
    "" + integerRef!!.field_pp_autoboxing,
   )
  }

  @JvmStatic
  fun <T: Long?> testUnboxingFromTypeVariable() {
   var n: T? = 10L as (T & Any)
   var l: Long = n!!.toLong()
   assert(l == 10L)
   n = (n!!.toLong() + 1L) as T?
   n = (n!!.toLong() + 1L) as T?
   n = run {
    val ___value: T? = n
    n = (n!!.toLong() + 1L) as T?
    ___value
   }
   n = run {
    n = (n!!.toLong() + 1L) as T?
    n
   }
   open class Local<T: Long?> internal constructor() {
    internal open fun toLong_pp_autoboxing(l: T): Long {
     assert(l!!.equals(11L))
     return l!!.toLong()
    }
   }
   l = Local<Long?>().toLong_pp_autoboxing(11L)
   assert(l == 11L)
  }

  @JvmStatic
  fun <T> testUnboxingFromIntersectionType() where T: Long?, T: Comparable<Long>? {
   var n: T? = 10L as (T & Any)
   var l: Long = n!!.toLong()
   assert(l == 10L)
   n = (n!!.toLong() + 1L) as T?
   n = (n!!.toLong() + 1L) as T?
   n = run {
    val ___value: T? = n
    n = (n!!.toLong() + 1L) as T?
    ___value
   }
   n = run {
    n = (n!!.toLong() + 1L) as T?
    n
   }
   open class Local<T> internal constructor() where T: Long?, T: Comparable<Long>? {
    internal open fun toLong_pp_autoboxing(l: T): Long {
     assert(l!!.equals(11L))
     return l!!.toLong()
    }
   }
   l = Local<Long?>().toLong_pp_autoboxing(11L)
   assert(l == 11L)
   val i: Int = 10.let { it as Int; it as Comparable<Int>; it }.toInt()
  }
 }

 open class Ref<T> {
  @JvmField
  internal var field_pp_autoboxing: T

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