// Generated from "cast/CastPrimitives.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.Boolean
import kotlin.Byte
import kotlin.ByteArray
import kotlin.Char
import kotlin.Double
import kotlin.Float
import kotlin.Int
import kotlin.Long
import kotlin.Short
import kotlin.Suppress
import kotlin.jvm.JvmStatic

open class CastPrimitives {
 open fun testPrimitiveCasts() {
  var b: Byte = 1.toByte()
  var c: Char = 1.toChar()
  var s: Short = 1.toShort()
  var i: Int = 1
  var l: Long = 1L
  var f: Float = 1.1f
  var d: Double = 1.1
  b = b
  c = b.toInt().toChar()
  s = b.toShort()
  i = b.toInt()
  l = b.toLong()
  f = b.toFloat()
  d = b.toDouble()
  b = c.code.toByte()
  c = c
  s = c.code.toShort()
  i = c.code
  l = c.code.toLong()
  f = c.code.toFloat()
  d = c.code.toDouble()
  b = s.toByte()
  c = s.toInt().toChar()
  s = s
  i = s.toInt()
  l = s.toLong()
  f = s.toFloat()
  d = s.toDouble()
  b = i.toByte()
  c = i.toChar()
  s = i.toShort()
  i = i
  l = i.toLong()
  f = i.toFloat()
  d = i.toDouble()
  b = l.toByte()
  c = l.toInt().toChar()
  s = l.toShort()
  i = l.toInt()
  l = l
  f = l.toFloat()
  d = l.toDouble()
  b = f.toInt().toByte()
  c = f.toInt().toChar()
  s = f.toInt().toShort()
  i = f.toInt()
  l = f.toLong()
  f = f
  d = f.toDouble()
  b = d.toInt().toByte()
  c = d.toInt().toChar()
  s = d.toInt().toShort()
  i = d.toInt()
  l = d.toLong()
  f = d.toFloat()
  d = d
 }

 open fun testReferenceToPrimitive() {
  val o: Any = Any()
  val bool: Boolean = o as Boolean
  val b: Byte = o as Byte
  val c: Char = o as Char
  val s: Short = o as Short
  val i: Int = o as Int
  val l: Long = o as Long
  val f: Float = o as Float
  val d: Double = o as Double
 }

 open fun testLiteralToPrimitive() {
  var b: Byte = 0.toByte()
  var c: Char = '\u0000'
  var s: Short = 0.toShort()
  var i: Int = 0
  var l: Long = 0L
  var f: Float = 0.0f
  var d: Double = 0.0
  b = 1.toByte()
  c = 1.toChar()
  s = 1.toShort()
  i = 1
  l = 1.toLong()
  f = 1.toFloat()
  d = 1.toDouble()
  b = 1L.toByte()
  c = 1L.toInt().toChar()
  s = 1L.toShort()
  i = 1L.toInt()
  l = 1L
  f = 1L.toFloat()
  d = 1L.toDouble()
  b = 1.2f.toInt().toByte()
  c = 1.2f.toInt().toChar()
  s = 1.2f.toInt().toShort()
  i = 1.2f.toInt()
  l = 1.2f.toLong()
  f = 1.2f
  d = 1.2f.toDouble()
  b = 1.2.toInt().toByte()
  c = 1.2.toInt().toChar()
  s = 1.2.toInt().toShort()
  i = 1.2.toInt()
  l = 1.2.toLong()
  f = 1.2.toFloat()
  d = 1.2
  b = 'a'.code.toByte()
  c = 'a'
  s = 'a'.code.toShort()
  i = 'a'.code
  l = 'a'.code.toLong()
  f = 'a'.code.toFloat()
  d = 'a'.code.toDouble()
 }

 open fun testUnboxAndWiden() {
  val boxedByte: Byte? = java.lang.Byte.valueOf(
   0.toByte(),
  )
  val s: Short = boxedByte!!.toByte().toShort()
  val i: Int = boxedByte!!.toByte().toInt()
  val l: Long = boxedByte!!.toByte().toLong()
  val f: Float = boxedByte!!.toByte().toFloat()
  val d: Double = boxedByte!!.toByte().toDouble()
 }

 open fun testImplicitArgumentCasts() {
  val b: Byte = 127.toByte()
  val c: Char = 65535.toChar()
  val s: Short = 32767.toShort()
  val i: Int = 2147483647
  val l: Long = 9223372036854775807L
  val f: Float = 3.4028235E38f
  val d: Double = 1.7976931348623157E308
  CastPrimitives.getShort(
   b.toShort(),
  )
  CastPrimitives.getInt(
   b.toInt(),
  )
  CastPrimitives.getLong(
   b.toLong(),
  )
  CastPrimitives.getFloat(
   b.toFloat(),
  )
  CastPrimitives.getDouble(
   b.toDouble(),
  )
  CastPrimitives.getFloat(
   l.toFloat(),
  )
  CastPrimitives.getDouble(
   l.toDouble(),
  )
  CastPrimitives.getDouble(
   f.toDouble(),
  )
  IntValueHolder(
   b.toInt(),
  )
  IntValueHolder(
   c.code,
  )
  IntValueHolder(
   s.toInt(),
  )
  LongValueHolder(
   b.toLong(),
  )
  LongValueHolder(
   c.code.toLong(),
  )
  LongValueHolder(
   i.toLong(),
  )
 }

 open fun testImplicitArrayIndexCasts(array: ByteArray?) {
  val b: Byte = 127.toByte()
  val c: Char = 65535.toChar()
  val s: Short = 32767.toShort()
  val i: Int = 2147483647
  var result: Byte = 0.toByte()
  result = array!![b.toInt()]
  result = array!![c.code]
  result = array!![s.toInt()]
  result = array!![i]
  result = array!![1]
  result = array!![97]
 }

 open fun testImplicitLongAssignmentCasts() {
  val fbyte: Byte = 11.toByte()
  val fchar: Char = 12.toChar()
  val fshort: Short = 13.toShort()
  val fint: Int = 14
  val flong: Long = 15L
  val ffloat: Float = 16.0f
  val fdouble: Double = 17.0
  var tlong: Long = 0L
  tlong = fbyte.toLong()
  tlong = flong
  tlong = fint.toLong()
  tlong = tlong + fint.toLong()
  tlong = tlong.shl(fint)
  tlong = tlong + fchar.code.toLong()
  tlong = tlong + flong
  tlong = (tlong.toFloat() + ffloat).toLong()
  tlong = flong * fint.toLong()
  tlong = flong.shr(fint)
  tlong = flong + fshort.toLong()
  tlong = flong + flong
  tlong = flong.shl(
   tlong.toInt(),
  )
  tlong = tlong.shl(
   flong.toInt(),
  )
  tlong = (0 + 1).toLong() + 2L
 }

 companion object {
  @JvmStatic
  private fun getShort(value: Short): Short {
   return value
  }

  @JvmStatic
  private fun getInt(value: Int): Int {
   return value
  }

  @JvmStatic
  private fun getLong(value: Long): Long {
   return value
  }

  @JvmStatic
  private fun getFloat(value: Float): Float {
   return value
  }

  @JvmStatic
  private fun getDouble(value: Double): Double {
   return value
  }
 }

 open class IntValueHolder {
  internal constructor(value: Int)
 }

 open class LongValueHolder {
  internal constructor(value: Long)
 }
}
