// Generated from "switchstatement/SwitchStatement.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 switchstatement

import javaemul.lang.*
import java.lang.RuntimeException
import kotlin.Boolean
import kotlin.Byte
import kotlin.Char
import kotlin.Int
import kotlin.Short
import kotlin.Suppress
import kotlin.assert
import kotlin.jvm.JvmStatic

enum class Numbers {
 ONE,
 TWO,
 THREE;
}

open class SwitchStatement {
 open fun main() {
  when ("one") {
   "one", "two" -> {}
   else -> {
    return
   }
  }
  when ('1') {
   '1', '2' -> {}
   else -> {
    return
   }
  }
  when (1) {
   -2, 1, 2 -> {}
   else -> {
    return
   }
  }
  when (Numbers.ONE) {
   Numbers.ONE, Numbers.TWO -> {}
   Numbers.THREE -> {}
   else -> {
    return
   }
  }
  var s: Short = 1.toShort()
  when (s) {
   1.toShort() -> {
    s = (s.toInt() + 1).toShort()
   }
   3.toShort() -> {
    s = (s.toInt() + 1).toShort()
   }
   12.toShort() -> {
    s = (s.toInt() + 1).toShort()
   }
   else -> {}
  }
 }

 private fun testCaseExpressionTypes(ch: Char, i: Int, b: Byte, s: Short) {
  when (ch) {
   'a' -> {}
   '\u0001' -> {}
   '\u0002' -> {}
   '\u0003' -> {}
   else -> {}
  }
  when (i) {
   97 -> {}
   1 -> {}
   2 -> {}
   3 -> {}
   else -> {}
  }
  when (b) {
   97.toByte() -> {}
   1.toByte() -> {}
   2.toByte() -> {}
   3.toByte() -> {}
   else -> {}
  }
  when (s) {
   97.toShort() -> {}
   1.toShort() -> {}
   2.toShort() -> {}
   3.toShort() -> {}
   else -> {}
  }
 }

 private fun testBlocksInSwitchCase(i: Int) {
  when (i) {
   1 -> {
    this.foo(1)
    this.foo(2)
    this.foo(3)
    this.foo(4)
    this.foo(5)
   }
   else -> {}
  }
 }

 private fun testLabelInSwitchCase(i: Int) {
  SWITCH@ do {
   CASE@ do {
    do {
     when (i) {
      1 -> {
       break
      }
      else -> {
       break@CASE
      }
     }
     break@SWITCH
    } while (false)
    do {
     break
    } while (true)
   } while (false)
  } while (false)
 }

 private fun testNonFallThroughBreakCase(i: Int) {
  when (i) {
   1 -> {
    this.foo(1)
   }
   else -> {
    this.foo(2)
   }
  }
 }

 private fun testNonFallThroughBreakOuterCase(i: Int) {
  do {
   when (i) {
    1 -> {
     this.foo(1)
     break
    }
    else -> {
     this.foo(2)
    }
   }
  } while (false)
 }

 private fun testNonFallThroughContinueCase(i: Int) {
  do {
   when (i) {
    3 -> {
     this.foo(1)
     break
    }
    else -> {
     this.foo(2)
    }
   }
  } while (false)
 }

 private fun testNonFallThroughReturnCase(i: Int) {
  when (i) {
   4 -> {
    this.foo(1)
    return
   }
   else -> {
    this.foo(2)
   }
  }
 }

 private fun testNonFallThroughThrowCase(i: Int) {
  when (i) {
   5 -> {
    this.foo(1)
    throw RuntimeException()
   }
   else -> {
    this.foo(2)
   }
  }
 }

 private fun testNonFallThroughIfCase(i: Int) {
  when (i) {
   1 -> {
    this.foo(1)
    if (false) {} else {}
   }
   else -> {
    this.foo(2)
   }
  }
 }

 private fun testNonFallThroughBlockCase(i: Int) {
  when (i) {
   1 -> {
    this.foo(1)
   }
   else -> {
    this.foo(2)
   }
  }
 }

 private fun testNonFallThrough_defaultIsNotLast(i: Int) {
  SWITCH@ do {
   CASE@ do {
    CASE_1@ do {
     CASE_2@ do {
      do {
       when (i) {
        1 -> {
         break
        }
        2 -> {
         break@CASE_2
        }
        3 -> {
         break@CASE
        }
        else -> {
         break@CASE_1
        }
       }
       break@SWITCH
      } while (false)
      this.foo(1)
      break@SWITCH
     } while (false)
     this.foo(2)
     break@SWITCH
    } while (false)
    this.foo(3)
    break@SWITCH
   } while (false)
   this.foo(4)
  } while (false)
 }

 private fun testFallThroughCase(i: Int) {
  SWITCH@ do {
   CASE@ do {
    do {
     when (i) {
      1 -> {
       break
      }
      else -> {
       break@CASE
      }
     }
     break@SWITCH
    } while (false)
    this.foo(1)
   } while (false)
   this.foo(2)
  } while (false)
 }

 private fun testFallThroughBreakInnerCase(i: Int) {
  SWITCH@ do {
   CASE@ do {
    do {
     when (i) {
      1 -> {
       break
      }
      else -> {
       break@CASE
      }
     }
     break@SWITCH
    } while (false)
    this.foo(1)
   } while (false)
   this.foo(2)
  } while (false)
 }

 private fun testFallThroughContinueInnerCase(i: Int) {
  SWITCH@ do {
   CASE@ do {
    do {
     when (i) {
      1 -> {
       break
      }
      else -> {
       break@CASE
      }
     }
     break@SWITCH
    } while (false)
    this.foo(1)
   } while (false)
   this.foo(2)
  } while (false)
 }

 private fun testFallThroughLabeledStatement(i: Int) {
  SWITCH@ do {
   CASE@ do {
    do {
     when (i) {
      1 -> {
       break
      }
      else -> {
       break@CASE
      }
     }
     break@SWITCH
    } while (false)
    do {
     if (false) {
      break
     }
     return
    } while (false)
   } while (false)
   this.foo(2)
  } while (false)
 }

 private fun testFallThroughIfCase(i: Int) {
  SWITCH@ do {
   CASE@ do {
    do {
     when (i) {
      1 -> {
       break
      }
      else -> {
       break@CASE
      }
     }
     break@SWITCH
    } while (false)
    this.foo(1)
    if (false) {
     break@SWITCH
    }
   } while (false)
   this.foo(2)
  } while (false)
 }

 private fun testFallThroughIfElseCase(i: Int) {
  SWITCH@ do {
   CASE@ do {
    do {
     when (i) {
      1 -> {
       break
      }
      else -> {
       break@CASE
      }
     }
     break@SWITCH
    } while (false)
    if (true) {
     this.foo(1)
     break@SWITCH
    } else {
     this.foo(2)
    }
   } while (false)
   this.foo(2)
  } while (false)
 }

 private fun testFallThoughLastCase(i: Int) {
  when (i) {
   1 -> {
    this.foo(1)
   }
   else -> {
    this.foo(2)
   }
  }
 }

 private fun testDefaultIsNotLast_fallThrough(i: Int) {
  SWITCH@ do {
   CASE@ do {
    CASE_1@ do {
     CASE_2@ do {
      do {
       when (i) {
        1 -> {
         break
        }
        2 -> {
         break@CASE_2
        }
        4 -> {
         break@CASE
        }
        else -> {
         break@CASE_1
        }
       }
       break@SWITCH
      } while (false)
      this.foo(1)
     } while (false)
     this.foo(2)
    } while (false)
    this.foo(3)
   } while (false)
   this.foo(4)
  } while (false)
 }

 private fun testDefaultNotLast_fallThroughCase(i: Int): Int {
  var result: Int = 0
  SWITCH@ do {
   CASE@ do {
    do {
     when (i) {
      3 -> {
       break@CASE
      }
      else -> {
       break
      }
     }
     break@SWITCH
    } while (false)
    result = result + 10
    break@SWITCH
   } while (false)
   result = result + 100
  } while (false)
  return result
 }

 private fun testDefaultNotLast_fallThroughDefault(i: Int): Int {
  var result: Int = 0
  when (i) {
   1 -> {
    result = result + 10
   }
   else -> {
    result = result + 100
   }
  }
  return result
 }

 private fun testNonExhaustive(numbers: Numbers?): Int {
  when (numbers!!) {
   Numbers.ONE -> {
    return 1
   }
   Numbers.TWO -> {
    return 2
   }
   else -> {}
  }
  return 3
 }

 private fun testNonExhaustive_fallThrough(numbers: Numbers?) {
  SWITCH@ do {
   CASE@ do {
    CASE_1@ do {
     do {
      when (numbers!!) {
       Numbers.ONE -> {
        break
       }
       Numbers.TWO -> {
        break@CASE_1
       }
       else -> {
        break@CASE
       }
      }
      break@SWITCH
     } while (false)
     this.foo(1)
    } while (false)
    this.foo(2)
    break@SWITCH
   } while (false)
  } while (false)
 }

 private fun testNonExhaustive_foldableFallThrough(i: Int) {
  when (i) {
   1, 2, 3 -> {}
   else -> {}
  }
 }

 private fun foo(i: Int) {}

 companion object {
  internal const val CONST_pp_switchstatement: Short = 3.toShort()

  @JvmStatic
  private fun testSwitchVariableDeclarations() {
   var i: Int = 0
   when (3) {
    1 -> {
     val unassigned: Int = 0
     val unassigned2: Int = 0
     i = 0
     val j: Int = 2
     val b: Int = j + 1
    }
    3 -> {
     i = 3
     assert(i == 3)
     return
    }
    else -> {}
   }
   when (5) {
    5 -> {
     val i_1: Int = 1
    }
    else -> {}
   }
   assert(false)
  }

  @JvmStatic
  private fun testSwitchStatement_withRules() {
   val o: Int = 0
   SWITCH@ do {
    CASE@ do {
     do {
      when (1) {
       2 -> {
        break@CASE
       }
       else -> {
        break
       }
      }
      break@SWITCH
     } while (false)
     break@SWITCH
    } while (false)
   } while (false)
  }

  @JvmStatic
  private fun testDefaultNotLast_withRules(i: Int, doBreak: Boolean): Int {
   var result: Int = 0
   SWITCH@ do {
    CASE@ do {
     CASE_1@ do {
      CASE_2@ do {
       CASE_3@ do {
        do {
         when (i) {
          1 -> {
           break
          }
          2 -> {
           break@CASE_3
          }
          3 -> {
           break@CASE_1
          }
          4 -> {
           break@CASE
          }
          else -> {
           break@CASE_2
          }
         }
         break@SWITCH
        } while (false)
        result = 1
        if (doBreak) {
         break@SWITCH
        }
        result = 2
        break@SWITCH
       } while (false)
       break@SWITCH
      } while (false)
      break@SWITCH
     } while (false)
     result = 3
     break@SWITCH
    } while (false)
    SwitchStatement.foo()
   } while (false)
   return result
  }

  @JvmStatic
  private fun foo(): Int {
   return 1
  }
 }
}
