Files
kotlin-fork/compiler/testData/diagnostics/tests/resolve/specialConstructions/constantsInIf.kt
T
Dmitriy Novozhilov ca0e66bafc [NI] Refactor compiler representation of integer literals types
Add `IntegerLiteralTypeConstructor` that holds types, that can take
  integer literal with given value. It has two supertypes
  (`Number` and `Comparable<IntegerLiteralType>`) and have
  special rules for subtyping, `intersect` and `commonSuperType`
  functions with primitive number:

Example (assuming that ILT holds Int type):
* ILT <: Int
* Int :> ILT
* ILT intersect Int = Int
* commonSuperType(ILT, Int) = Int

#KT-30293 Fixed
#KT-30446 Fixed
2019-03-25 18:55:36 +03:00

14 lines
417 B
Kotlin
Vendored

// !WITH_NEW_INFERENCE
// !DIAGNOSTICS: -USELESS_ELVIS
fun test() {
bar(<!NI;TYPE_MISMATCH, NI;TYPE_MISMATCH!>if (true) {
<!OI;CONSTANT_EXPECTED_TYPE_MISMATCH!>1<!>
} else {
<!OI;CONSTANT_EXPECTED_TYPE_MISMATCH!>2<!>
}<!>)
bar(<!NI;TYPE_MISMATCH, NI;TYPE_MISMATCH!><!OI;CONSTANT_EXPECTED_TYPE_MISMATCH!>1<!> ?: <!OI;CONSTANT_EXPECTED_TYPE_MISMATCH!>2<!><!>)
}
fun bar(s: String) = s