[FIR] Add UNCHECKED_CAST

Regenerate diagnostics code
This commit is contained in:
Ivan Kochurkin
2021-09-16 23:24:58 +03:00
committed by TeamCityServer
parent 1fbccff1bd
commit d0a4ca199d
70 changed files with 118 additions and 933 deletions
@@ -1599,7 +1599,7 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert
add(FirErrors.WRONG_NUMBER_OF_TYPE_ARGUMENTS) { firDiagnostic ->
WrongNumberOfTypeArgumentsImpl(
firDiagnostic.a,
firSymbolBuilder.classifierBuilder.buildClassLikeSymbol(firDiagnostic.b.fir),
firSymbolBuilder.classifierBuilder.buildClassLikeSymbol(firDiagnostic.b.fir as FirClass),
firDiagnostic as KtPsiDiagnostic,
token,
)
@@ -1614,7 +1614,7 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert
}
add(FirErrors.OUTER_CLASS_ARGUMENTS_REQUIRED) { firDiagnostic ->
OuterClassArgumentsRequiredImpl(
firSymbolBuilder.classifierBuilder.buildClassLikeSymbol(firDiagnostic.a.fir),
firSymbolBuilder.classifierBuilder.buildClassLikeSymbol(firDiagnostic.a.fir as FirClass),
firDiagnostic as KtPsiDiagnostic,
token,
)
@@ -2771,7 +2771,7 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert
firDiagnostic.b,
firDiagnostic.c.mapKeys { (incompatible, _) ->
incompatible
}.mapValues { (_, collection) ->
}.mapValues { (_, collection) ->
collection.map { firBasedSymbol ->
firSymbolBuilder.buildSymbol(firBasedSymbol.fir)
}
@@ -2785,7 +2785,7 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert
firSymbolBuilder.buildSymbol(firDiagnostic.a.fir),
firDiagnostic.b.mapKeys { (incompatible, _) ->
incompatible
}.mapValues { (_, collection) ->
}.mapValues { (_, collection) ->
collection.map { firBasedSymbol ->
firSymbolBuilder.buildSymbol(firBasedSymbol.fir)
}
@@ -2820,7 +2820,7 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert
firDiagnostic.b.map { pair ->
firSymbolBuilder.buildSymbol(pair.first.fir) to pair.second.mapKeys { (incompatible, _) ->
incompatible
}.mapValues { (_, collection) ->
}.mapValues { (_, collection) ->
collection.map { firBasedSymbol ->
firSymbolBuilder.buildSymbol(firBasedSymbol.fir)
}
@@ -3100,13 +3100,13 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert
add(FirErrors.CANNOT_CHECK_FOR_ERASED) { firDiagnostic ->
CannotCheckForErasedImpl(
firSymbolBuilder.typeBuilder.buildKtType(firDiagnostic.a),
firDiagnostic as FirPsiDiagnostic,
firDiagnostic as KtPsiDiagnostic,
token,
)
}
add(FirErrors.CAST_NEVER_SUCCEEDS) { firDiagnostic ->
CastNeverSucceedsImpl(
firDiagnostic as FirPsiDiagnostic,
firDiagnostic as KtPsiDiagnostic,
token,
)
}
@@ -3116,6 +3116,14 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert
token,
)
}
add(FirErrors.UNCHECKED_CAST) { firDiagnostic ->
UncheckedCastImpl(
firSymbolBuilder.typeBuilder.buildKtType(firDiagnostic.a),
firSymbolBuilder.typeBuilder.buildKtType(firDiagnostic.b),
firDiagnostic as KtPsiDiagnostic,
token,
)
}
add(FirErrors.USELESS_IS_CHECK) { firDiagnostic ->
UselessIsCheckImpl(
firDiagnostic.a,
@@ -2181,6 +2181,12 @@ sealed class KtFirDiagnostic<PSI : PsiElement> : KtDiagnosticWithPsi<PSI> {
override val diagnosticClass get() = UselessCast::class
}
abstract class UncheckedCast : KtFirDiagnostic<KtBinaryExpressionWithTypeRHS>() {
override val diagnosticClass get() = UncheckedCast::class
abstract val originalType: KtType
abstract val targetType: KtType
}
abstract class UselessIsCheck : KtFirDiagnostic<KtElement>() {
override val diagnosticClass get() = UselessIsCheck::class
abstract val compileTimeCheckResult: Boolean
@@ -2612,24 +2612,27 @@ internal class UselessElvisRightIsNullImpl(
internal class CannotCheckForErasedImpl(
override val type: KtType,
firDiagnostic: FirPsiDiagnostic,
override val firDiagnostic: KtPsiDiagnostic,
override val token: ValidityToken,
) : KtFirDiagnostic.CannotCheckForErased(), KtAbstractFirDiagnostic<PsiElement> {
override val firDiagnostic: FirPsiDiagnostic by weakRef(firDiagnostic)
}
) : KtFirDiagnostic.CannotCheckForErased(), KtAbstractFirDiagnostic<PsiElement>
internal class CastNeverSucceedsImpl(
firDiagnostic: FirPsiDiagnostic,
override val firDiagnostic: KtPsiDiagnostic,
override val token: ValidityToken,
) : KtFirDiagnostic.CastNeverSucceeds(), KtAbstractFirDiagnostic<KtBinaryExpressionWithTypeRHS> {
override val firDiagnostic: FirPsiDiagnostic by weakRef(firDiagnostic)
}
) : KtFirDiagnostic.CastNeverSucceeds(), KtAbstractFirDiagnostic<KtBinaryExpressionWithTypeRHS>
internal class UselessCastImpl(
override val firDiagnostic: KtPsiDiagnostic,
override val token: ValidityToken,
) : KtFirDiagnostic.UselessCast(), KtAbstractFirDiagnostic<KtBinaryExpressionWithTypeRHS>
internal class UncheckedCastImpl(
override val originalType: KtType,
override val targetType: KtType,
override val firDiagnostic: KtPsiDiagnostic,
override val token: ValidityToken,
) : KtFirDiagnostic.UncheckedCast(), KtAbstractFirDiagnostic<KtBinaryExpressionWithTypeRHS>
internal class UselessIsCheckImpl(
override val compileTimeCheckResult: Boolean,
override val firDiagnostic: KtPsiDiagnostic,
@@ -5,11 +5,11 @@ fun foo(b: B<Int, Int>) {}
fun test_1(b: B<String, Number>) {
foo(b.myMap {
it.k.length // implicits
} as B<Int, Int>)
} <!UNCHECKED_CAST!>as B<Int, Int><!>)
}
fun test_2(s: String) {
val func = { s.length } <!CAST_NEVER_SUCCEEDS!>as<!> B<Int, Int>
val func = { s.length } <!UNCHECKED_CAST!>as B<Int, Int><!>
}
class B<out K, V>(val k: K, val v: V)
@@ -12,6 +12,6 @@ interface AbstractFirBasedSymbol<E> where E : FirSymbolOwner<E>, E : FirDeclarat
fun foo(firAdaptee: FirFunction<*>) {}
fun test(symbol: AbstractFirBasedSymbol<*>) {
val firAdaptee = symbol.fir as FirFunction
val firAdaptee = symbol.fir <!UNCHECKED_CAST!>as FirFunction<!> // TODO: KT-48832
foo(firAdaptee)
}
@@ -30,9 +30,9 @@ fun uExpression(): UExpressionPattern.Capture<UExpression> = expressionCapture(U
fun <T : UExpression> expressionCapture(clazz: Class<T>): UExpressionPattern.Capture<T> = UExpressionPattern.Capture(clazz)
open class UElementPattern<T : UElement, Self : UElementPattern<T, Self>>(clazz: Class<T>) : ObjectPattern<T, Self>(clazz) {
fun filter(filter: (T) -> Boolean): Self = this as Self
fun filter(filter: (T) -> Boolean): Self = this <!UNCHECKED_CAST!>as Self<!>
}
open class UExpressionPattern<T : UExpression, Self : UExpressionPattern<T, Self>>(clazz: Class<T>) : UElementPattern<T, Self>(clazz) {
open class Capture<T : UExpression>(clazz: Class<T>) : UExpressionPattern<T, Capture<T>>(clazz)
}
}
@@ -6,7 +6,7 @@ fun List<String>.modify() {
}
fun Any.modify() {
(<!VARIABLE_EXPECTED!>this as List<Int><!>) += 42
(<!VARIABLE_EXPECTED!>this <!UNCHECKED_CAST!>as List<Int><!><!>) += 42
}
operator fun <T> Set<T>.plusAssign(x: T) {}
@@ -17,5 +17,5 @@ fun Set<String>.modify() {
}
fun Any.modifySet() {
(this as Set<Int>) += 42
(this <!UNCHECKED_CAST!>as Set<Int><!>) += 42
}
@@ -1107,6 +1107,10 @@ object DIAGNOSTICS_LIST : DiagnosticList("FirErrors") {
}
val CAST_NEVER_SUCCEEDS by warning<KtBinaryExpressionWithTypeRHS>(PositioningStrategy.OPERATOR)
val USELESS_CAST by warning<KtBinaryExpressionWithTypeRHS>(PositioningStrategy.AS_TYPE)
val UNCHECKED_CAST by warning<KtBinaryExpressionWithTypeRHS>(PositioningStrategy.AS_TYPE) {
parameter<ConeKotlinType>("originalType")
parameter<ConeKotlinType>("targetType")
}
val USELESS_IS_CHECK by warning<KtElement> {
parameter<Boolean>("compileTimeCheckResult")
}
@@ -593,6 +593,7 @@ object FirErrors {
val CANNOT_CHECK_FOR_ERASED by error1<PsiElement, ConeKotlinType>()
val CAST_NEVER_SUCCEEDS by warning0<KtBinaryExpressionWithTypeRHS>(SourceElementPositioningStrategies.OPERATOR)
val USELESS_CAST by warning0<KtBinaryExpressionWithTypeRHS>(SourceElementPositioningStrategies.AS_TYPE)
val UNCHECKED_CAST by warning2<KtBinaryExpressionWithTypeRHS, ConeKotlinType, ConeKotlinType>(SourceElementPositioningStrategies.AS_TYPE)
val USELESS_IS_CHECK by warning1<KtElement, Boolean>()
val IS_ENUM_ENTRY by error0<KtTypeReference>()
val ENUM_ENTRY_AS_TYPE by error0<KtTypeReference>(SourceElementPositioningStrategies.SELECTOR_BY_QUALIFIED)
@@ -77,11 +77,11 @@ import test.L
fun main(a: test.A, l: L<Map<String, Int>, Int?>, l1: L<Map<String, Int>, Int>) {
a.foo(l)
a.foo(<!ARGUMENT_TYPE_MISMATCH!>l as L<Map<String, Int>, Int><!>)
a.foo(l as L<Map<String, Int?>, Int?>)
a.foo(<!ARGUMENT_TYPE_MISMATCH!>l <!UNCHECKED_CAST!>as L<Map<String, Int>, Int><!><!>)
a.foo(l <!UNCHECKED_CAST!>as L<Map<String, Int?>, Int?><!>)
a.bar(l1)
a.bar(l1 as L<Map<String, Int>, Int?>)
a.bar(l1 <!UNCHECKED_CAST!>as L<Map<String, Int>, Int?><!>)
a.baz1().t().containsKey("")
a.baz1().t().containsKey(null)
@@ -90,7 +90,7 @@ fun main(a: test.A, l: L<Map<String, Int>, Int?>, l1: L<Map<String, Int>, Int>)
a.baz1().s().hashCode()
a.baz1().setT(l.t())
a.baz1().setT(<!ARGUMENT_TYPE_MISMATCH!>l.t() as L<Map<String, Int>, Int><!>)
a.baz1().setT(<!ARGUMENT_TYPE_MISMATCH!>l.t() <!UNCHECKED_CAST!>as L<Map<String, Int>, Int><!><!>)
a.baz1().setT(null)
a.baz2().t().containsKey("")
+1 -1
View File
@@ -43,7 +43,7 @@ typealias ArrayOfEnumEntry = Array<Color.<!ENUM_ENTRY_AS_TYPE!>RED<!>>
typealias ArrayOfEnumEntryAlias = Array<RedAlias>
fun <T> bar(a: Any): T = a as T
fun <T> bar(a: Any): T = a <!UNCHECKED_CAST!>as T<!>
fun <T> foo() {
foo<Color.<!ENUM_ENTRY_AS_TYPE!>RED<!>>()
@@ -26,7 +26,7 @@ fun test() {
c
val d = id(Scope.Nested<*>::keyT as Scope.Nested<Number>)
val d = id(Scope.Nested<*>::keyT <!UNCHECKED_CAST!>as Scope.Nested<Number><!>)
d
@@ -40,4 +40,4 @@ fun justResolve() {
val b = Scope.Nested<String>::keyT
val c = Scope.Nested<*>::keyT
val d = Scope.Nested<out Number?>::keyT
}
}
@@ -1 +0,0 @@
fun f(x: Any) = x as Array<String>
+1
View File
@@ -1 +1,2 @@
// FIR_IDENTICAL
fun f(x: Any) = x <!UNCHECKED_CAST!>as Array<String><!>
@@ -1,2 +0,0 @@
fun ff(c: MutableCollection<String>) = c as MutableList<Int>
@@ -1,2 +1,3 @@
// FIR_IDENTICAL
fun ff(c: MutableCollection<String>) = c <!UNCHECKED_CAST!>as MutableList<Int><!>
@@ -1,2 +0,0 @@
fun ff(a: Any) = a as MutableList<String>
@@ -1,2 +1,3 @@
// FIR_IDENTICAL
fun ff(a: Any) = a <!UNCHECKED_CAST!>as MutableList<String><!>
@@ -1,34 +0,0 @@
// See also: KT-6611 (cast can never succeed: Class<T> -> Class<Any>)
class Class<T>(val name: String, val instance: T)
fun <T> test(clazz: Class<T>) {
println((clazz as Class<Any>).name)
}
fun use() {
test(Class("String", ""))
}
fun checkArrays(): Array<Any> {
val someArray = arrayOfNulls<Any>(5)
someArray as Array<Int>
return someArray as Array<Any>
}
class Wrapper<T>(val x: T)
fun checkArrays2(): Array<Wrapper<String>> {
val someArray = arrayOf(Wrapper(1), Wrapper(2))
return someArray as Array<Wrapper<String>>
}
fun checkArrays3() {
val someArray = arrayOfNulls<String>(1)
someArray as Array<Any>
val intArray = arrayOfNulls<Int>(1)
intArray as Array<Any>
}
fun println(s: String) = s
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// See also: KT-6611 (cast can never succeed: Class<T> -> Class<Any>)
class Class<T>(val name: String, val instance: T)
@@ -10,9 +10,9 @@ fun <T, S : T> test(x: T?, y: S, z: T) {
<!USELESS_IS_CHECK!>z is T<!>
<!USELESS_IS_CHECK!>z is T?<!>
null as T
null <!UNCHECKED_CAST!>as T<!>
null as T?
null as S
null <!UNCHECKED_CAST!>as S<!>
}
inline fun <reified T> test(x: T?) {
@@ -25,7 +25,7 @@ class MyProperty<R, T> {
operator fun getValue(thisRef: R, desc: KProperty<*>): T {
println("get $thisRef ${desc.name}")
return null as T
return null <!UNCHECKED_CAST!>as T<!>
}
operator fun setValue(thisRef: R, desc: KProperty<*>, value: T) {
@@ -22,7 +22,7 @@ fun <E> foo(x: Any, y: Any) : Any {
return y
}
y as Outer<*>.Inner
y <!UNCHECKED_CAST!>as Outer<*>.Inner<!>
return C()
}
@@ -39,7 +39,7 @@ fun main1() {
// --- from Kotlin --- //
public class Bar<T> {
var value: T = null as T
var value: T = null <!UNCHECKED_CAST!>as T<!>
}
fun takeStarBar(x: Bar<*>) {
@@ -115,4 +115,4 @@ fun main6() {
bar.value = 1
takeStarBar3(bar)
println(bar.value) // CCE: String cannot be cast to Number
}
}
@@ -39,7 +39,7 @@ fun main1() {
// --- from Kotlin --- //
public class Bar<T> {
var value: T = null as T
var value: T = null <!UNCHECKED_CAST!>as T<!>
}
fun takeStarBar(x: Bar<*>) {
@@ -2,7 +2,7 @@
fun foo() = 1
fun <T> foo() = foo() as T
fun <T> foo() = foo() <!UNCHECKED_CAST!>as T<!>
fun <T> foo2(): T = TODO()
@@ -12,7 +12,7 @@ object WriterAppender {
class Builder1<B : Builder1<B>> {
fun asBuilder(): B {
return this as B
return this <!UNCHECKED_CAST!>as B<!>
}
}
@@ -23,4 +23,4 @@ object WriterAppender {
fun <B> intersectTwoSelfTypes(): B where B : Builder1<B>, B: Builder2<B> {
return Builder1<B>().asBuilder()
}
}
}
@@ -37,7 +37,7 @@ object WriterAppender {
class Builder1<B : Builder1<B>> {
fun asBuilder(): B {
return this as B
return this <!UNCHECKED_CAST!>as B<!>
}
}
@@ -48,4 +48,4 @@ object WriterAppender {
fun <B> intersectTwoSelfTypes(): B where B : Builder1<B>, B: Builder2<B> {
return Builder1<B>().asBuilder()
}
}
}
@@ -11,7 +11,7 @@ class B<T> {
fun <Y> foo(c: A<Y>): Y = TODO()
fun <E> main(a: A<E>) {
a as A<B<*>>
a <!UNCHECKED_CAST!>as A<B<*>><!>
foo(a).b()
}
@@ -21,7 +21,7 @@ class AOut<out X>
fun <Y> foo(c: AOut<Y>): Y = TODO()
fun <E> mainOut(a: AOut<E>) {
a as AOut<B<*>>
a <!UNCHECKED_CAST!>as AOut<B<*>><!>
foo(a).b()
}
@@ -1,14 +0,0 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
class Inv<T>
fun <T> materializeInv() = Inv<T>()
fun <X> foo(x: Inv<X>, y: X) = materializeInv<X>()
fun <X> foo(x: Inv<X>, y: () -> X) = materializeInv<X>()
fun <R> main(fn: () -> R) {
fun bar(): R = null as R
val x1 = foo<R>(materializeInv()) { fn() } // OVERLOAD_RESOLUTION_AMBIGUITY only in NI
val x2 = foo<R>(materializeInv(), fn) // OK
val x3 = foo<R>(materializeInv(), ::bar) // OK
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
@@ -1,20 +0,0 @@
//KT-2856 Fix the getOrElse signature to be able to return any supertype of V
package d
import java.util.HashMap
public inline fun <K,V1, V: V1> Map<K,V>.getOrElse1(key: K, defaultValue: ()-> V1) : V1 {
if (this.containsKey(key)) {
return this.get(key) as V
} else {
return defaultValue()
}
}
fun main() {
val map = HashMap<Int, Int>()
println(map.getOrElse1(2, { null })) // Error
}
//from standard library
fun println(message : Any?) {}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
//KT-2856 Fix the getOrElse signature to be able to return any supertype of V
package d
@@ -26,7 +26,7 @@ fun <T> testMutableCollection(c: MutableCollection<T>, t: T) {
val mutableIterator: MutableIterator<T> = c.iterator()
c.add(t)
c.remove(1 as T)
c.remove(1 <!UNCHECKED_CAST!>as T<!>)
c.addAll(c)
c.removeAll(c)
c.retainAll(c)
@@ -84,7 +84,7 @@ fun <T> testMutableSet(s: MutableSet<T>, t: T) {
val mutableIterator: MutableIterator<T> = s.iterator()
s.add(t)
s.remove(1 as T)
s.remove(1 <!UNCHECKED_CAST!>as T<!>)
s.addAll(s)
s.removeAll(s)
s.retainAll(s)
@@ -1,48 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER, -SENSELESS_COMPARISON, -DEBUG_INFO_SMARTCAST
fun <T: Any?> test1(t: Any?): Any {
return t as T ?: ""
}
fun <T: Any> test2(t: Any?): Any {
return t as T <!USELESS_ELVIS!>?: ""<!>
}
fun <T: Any?> test3(t: Any?): Any {
if (t != null) {
return t <!USELESS_ELVIS!>?: ""<!>
}
return 1
}
fun takeNotNull(s: String) {}
fun <T> notNull(): T = TODO()
fun <T> nullable(): T? = null
fun <T> dependOn(x: T) = x
fun test() {
takeNotNull(notNull() ?: "")
takeNotNull(nullable() ?: "")
val x: String? = null
takeNotNull(dependOn(x) ?: "")
takeNotNull(dependOn(dependOn(x)) ?: "")
takeNotNull(dependOn(dependOn(x as String)) <!USELESS_ELVIS!>?: ""<!>)
if (x != null) {
takeNotNull(dependOn(x) <!USELESS_ELVIS!>?: ""<!>)
takeNotNull(dependOn(dependOn(x)) <!USELESS_ELVIS!>?: ""<!>)
takeNotNull(dependOn(dependOn(x) as? String) ?: "")
}
takeNotNull(bar()!!)
}
inline fun <reified T : Any> reifiedNull(): T? = null
fun testFrom13648() {
takeNotNull(reifiedNull() ?: "")
}
fun bar() = <!UNRESOLVED_REFERENCE!>unresolved<!>
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER, -SENSELESS_COMPARISON, -DEBUG_INFO_SMARTCAST
fun <T: Any?> test1(t: Any?): Any {
@@ -1,67 +0,0 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE
// FILE: A.java
import java.util.*;
public class A {
void foo(List<Object> x) {}
void foo(Iterable<Object> x) {}
void foo(Iterator<Object> x) {}
void foo(Set<Object> x) {}
void foo(Map<Object, Object> x) {}
void foo(Map.Entry<Object, Object> x) {}
void foo1(List<List<Object>> x) {}
}
// FILE: main.kt
fun main(
a: A,
ml: MutableList<String>, l: List<String>,
ms: MutableSet<String>, s: Set<String>,
mm: MutableMap<Any, String>, m: Map<Any, String>,
mme: MutableMap.MutableEntry<Any, String>, me: Map.Entry<Any, String>,
mll: MutableList<MutableList<String>>, ll: List<List<String>>
) {
// Lists
a.foo(<!JAVA_TYPE_MISMATCH!>ml<!>)
a.foo(l)
a.foo(ml as MutableList<Any>)
a.foo(l as List<Any>)
// Iterables
val mit: MutableIterable<String> = ml
val it: Iterable<String> = ml
a.foo(mit)
a.foo(it)
// Iterators
a.foo(ml.iterator())
a.foo(l.iterator())
// Sets
a.foo(<!JAVA_TYPE_MISMATCH!>ms<!>)
a.foo(s)
a.foo(ms as MutableSet<Any>)
a.foo(s as Set<Any>)
// Maps
a.foo(<!JAVA_TYPE_MISMATCH!>mm<!>)
a.foo(m)
a.foo(mm as MutableMap<Any, Any>)
a.foo(m as Map<Any, Any>)
// Map entries
a.foo(<!JAVA_TYPE_MISMATCH!>mme<!>)
a.foo(me)
a.foo(mme as MutableMap.MutableEntry<Any, Any>)
a.foo(me as Map.Entry<Any, Any>)
// Lists of lists
a.foo1(<!JAVA_TYPE_MISMATCH!>mll<!>)
a.foo1(ll)
a.foo1(mll as MutableList<MutableList<Any>>)
a.foo1(ll as List<List<Any>>)
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_VARIABLE
// FILE: A.java
@@ -11,6 +11,6 @@ public class A {
fun main(a: A, ml: Any) {
if (ml is <!CANNOT_CHECK_FOR_ERASED!>MutableList<String><!>) {
a.foo(<!JAVA_TYPE_MISMATCH!>ml<!>)
a.foo(ml as List<Any>)
a.foo(ml <!UNCHECKED_CAST!>as List<Any><!>)
}
}
@@ -1,11 +0,0 @@
// KT-307 Unresolved reference
open class AL {
fun get(i : Int) : Any? = i
}
interface ALE<T> : <!INTERFACE_WITH_SUPERCLASS!>AL<!> {
fun getOrNull(index: Int, value: T) : T {
return get(index) as? T ?: value
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// KT-307 Unresolved reference
open class AL {
@@ -4,5 +4,5 @@
class IdUnavailableException() : Exception() {}
fun <T : Any> T.getJavaClass() : Class<T> {
return ((this as Object).getClass()) as Class<T> // Some error here, because of Exception() used above. ?!!!
}
return ((this as Object).getClass()) <!UNCHECKED_CAST!>as Class<T><!> // Some error here, because of Exception() used above. ?!!!
}
@@ -6,7 +6,7 @@ fun <T> typeinfo() : TypeInfo<T> = null <!CAST_NEVER_SUCCEEDS!>as<!> TypeInfo<T>
fun <T> TypeInfo<T>.getJavaClass() : java.lang.Class<T> {
val t : java.lang.Object = this as java.lang.Object
return t.getClass() as java.lang.Class<T> // inferred type is Object but Serializable was expected
return t.getClass() <!UNCHECKED_CAST!>as java.lang.Class<T><!> // inferred type is Object but Serializable was expected
}
fun <T> getJavaClass() = typeinfo<T>().getJavaClass()
@@ -9,12 +9,12 @@ fun test2() = J { x: String -> x }
fun test3() = H.bar { x: String -> x }
fun test4(a: Any) {
a as J<String>
a <!UNCHECKED_CAST!>as J<String><!>
H.bar(a)
}
fun test5(a: Any) {
a as (String) -> String
a <!UNCHECKED_CAST!>as (String) -> String<!>
H.bar(a)
}
@@ -23,7 +23,7 @@ fun <T> test6(a: (T) -> T) {
}
fun <T> test7(a: Any) {
a as (T) -> T
a <!UNCHECKED_CAST!>as (T) -> T<!>
H.bar(a)
}
@@ -55,4 +55,4 @@ public interface J2X<T3> extends J2<String, T3> {
public class H {
public static <X> void bar(J<X> j) {}
public static <Y> void bar2x(J2X<Y> j2x) {}
}
}
@@ -37,18 +37,18 @@ fun test5(a: Any) {
fun test5x(a: Any) {
if (a is Runnable) {
a as () -> Unit
a <!UNCHECKED_CAST!>as () -> Unit<!>
J().run1(a)
}
}
fun test6(a: Any) {
a as () -> Unit
a <!UNCHECKED_CAST!>as () -> Unit<!>
J().run1(a)
}
fun test7(a: (Int) -> Int) {
a as () -> Unit
a <!UNCHECKED_CAST!>as () -> Unit<!>
J().run1(a)
}
@@ -69,4 +69,4 @@ public class J {
public void run2(Runnable r1, Runnable r2) {}
public static <T> T id(T x) { return x; }
}
}
@@ -3,12 +3,12 @@
class Qwe<T : Any>(val a: T?) {
fun test1(obj: Any) {
obj as Qwe<T>
obj <!UNCHECKED_CAST!>as Qwe<T><!>
check(obj.a)
}
fun test1(obj: Qwe<*>) {
obj as Qwe<T>
obj <!UNCHECKED_CAST!>as Qwe<T><!>
check(obj.a)
}
@@ -1,8 +0,0 @@
// Works already in M11
fun test(c : Class<*>) {
val sc = c as Class<String>
// No ambiguous overload
c.getAnnotations();
sc.getAnnotations();
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// Works already in M11
fun test(c : Class<*>) {
@@ -1,8 +0,0 @@
package h
public class MyClass<S, T>(param: MyClass<S, T>) {
fun test() {
val result: MyClass<Any, Any>? = null
MyClass<S, Any>(result as MyClass<S, Any>)
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
package h
public class MyClass<S, T>(param: MyClass<S, T>) {
@@ -1,18 +0,0 @@
// SKIP_TXT
class StateMachine<Q> internal constructor() {
fun getInputStub(): Q = null as Q
}
fun <T> stateMachine(block: suspend StateMachine<T>.() -> Unit): StateMachine<T> {
return StateMachine<T>()
}
class Problem<F>(){
fun getInputStub(): F = null as F
fun createStateMachine(): StateMachine<F> = stateMachine {
val letter = getInputStub()
if (letter is Any)
println("yes")
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// SKIP_TXT
class StateMachine<Q> internal constructor() {
fun getInputStub(): Q = null <!UNCHECKED_CAST!>as Q<!>
@@ -21,7 +21,7 @@ fun foo() {
val x = { 1 }
builder(x)
builder({1} as (suspend () -> Int))
builder({1} <!UNCHECKED_CAST!>as (suspend () -> Int)<!>)
var i: Int = 1
i = genericBuilder({ 1 })
@@ -1,124 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER, -UNUSED_EXPRESSION, -UNUSED_VARIABLE
// !LANGUAGE: +InlineClasses -AllowResultInReturnType, -JvmInlineValueClasses
typealias ResultAlias<T> = Result<T>
inline class InlineResult<out T>(private val r: Result<T>)
fun params(
r1: Result<Int>,
r2: Result<Int>?,
r3: ResultAlias<String>,
r4: List<Result<Int>>,
r5: InlineResult<Int>,
<!FORBIDDEN_VARARG_PARAMETER_TYPE!>vararg<!> r6: Result<Int>
) {}
class CtorParams(r1: Result<Int>)
fun returnTypePublic(): Result<Int> = TODO()
internal fun returnTypeInternal(): Result<Int> = TODO()
private fun returnTypePrivate(): Result<Int> = TODO()
fun returnTypeNullable(): Result<Int>? = TODO()
fun returnTypeAlias(): ResultAlias<Int> = TODO()
fun returnInferred(r1: Result<Int>, r2: ResultAlias<Int>, b: Boolean) = if (b) r1 else r2
fun returnTypeInline(): InlineResult<Int> = TODO()
fun returnContainer(): List<Result<Int>> = TODO()
val topLevelP: Result<Int> = TODO()
val topLevelPInferred = topLevelP
internal val topLevelPInternal: Result<Int> = TODO()
private val topLevelPPrivate: Result<Int> = TODO()
private val topLevelPPrivateInferred = topLevelP
private val topLevelPPrivateCustomGetter: Result<Int>
get() = TODO()
val asFunctional: () -> Result<Int> = TODO()
open class PublicCls(
val r1: Result<String>,
val r2: Result<Int>?,
val r3: ResultAlias<Int>,
val r4: ResultAlias<Int>?,
val r5: InlineResult<Int>,
internal val r6: Result<Int>,
private val r7: Result<Int>,
val r8: List<Result<Int>>
) {
val p1: Result<Int> = TODO()
var p2: Result<Int> = TODO()
val p3: ResultAlias<Int>? = TODO()
val p4 = p1
internal val p5: Result<Int> = TODO()
private var p6: Result<Int> = TODO()
internal val p7 = p1
protected val p8 = p1
fun returnInCls(): Result<Int> = TODO()
protected fun returnInClsProtected(): Result<Int> = TODO()
private fun returnInClsPrivate(): Result<Int> = TODO()
}
internal open class InternalCls(
val r1: Result<Int>,
val r2: ResultAlias<Int>?,
val r3: List<Result<Int>>
) {
companion object {
val cr1: Result<Int> = TODO()
private val cr2: Result<Int> = TODO()
}
val p1 = r1
val p2: Result<String> = TODO()
protected val p3 = p1
fun returnInInternal(): Result<Int> = TODO()
protected fun returnInClsProtected(): Result<Int> = TODO()
}
private class PrivateCls(
val r1: Result<Int>,
val r2: ResultAlias<Int>?,
val r3: List<Result<Int>>
) {
companion object {
val cr1: Result<Int> = TODO()
private val cr2: Result<Int> = TODO()
}
val p1 = r1
val p2: Result<String> = TODO()
fun returnInPrivate(): Result<Int> = TODO()
}
fun local(r: Result<Int>) {
val l1: Result<Int>? = null
val l2 = r
fun localFun(): Result<Int> = TODO()
class F {
val p1: Result<Int> = r
val p2 = r
}
}
fun <T> resultInGenericFun(r: Result<Int>): T = r as T
val asFunPublic: () -> Result<Int> = TODO()
private val asFun: () -> Result<Int>? = TODO()
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER, -UNUSED_EXPRESSION, -UNUSED_VARIABLE
// !LANGUAGE: +InlineClasses -AllowResultInReturnType, -JvmInlineValueClasses
@@ -1,124 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER, -UNUSED_EXPRESSION, -UNUSED_VARIABLE
// !LANGUAGE: +InlineClasses +AllowResultInReturnType, -JvmInlineValueClasses
typealias ResultAlias<T> = Result<T>
inline class InlineResult<out T>(private val r: Result<T>)
fun params(
r1: Result<Int>,
r2: Result<Int>?,
r3: ResultAlias<String>,
r4: List<Result<Int>>,
r5: InlineResult<Int>,
<!FORBIDDEN_VARARG_PARAMETER_TYPE!>vararg<!> r6: Result<Int>
) {}
class CtorParams(r1: Result<Int>)
fun returnTypePublic(): Result<Int> = TODO()
internal fun returnTypeInternal(): Result<Int> = TODO()
private fun returnTypePrivate(): Result<Int> = TODO()
fun returnTypeNullable(): Result<Int>? = TODO()
fun returnTypeAlias(): ResultAlias<Int> = TODO()
fun returnInferred(r1: Result<Int>, r2: ResultAlias<Int>, b: Boolean) = if (b) r1 else r2
fun returnTypeInline(): InlineResult<Int> = TODO()
fun returnContainer(): List<Result<Int>> = TODO()
val topLevelP: Result<Int> = TODO()
val topLevelPInferred = topLevelP
internal val topLevelPInternal: Result<Int> = TODO()
private val topLevelPPrivate: Result<Int> = TODO()
private val topLevelPPrivateInferred = topLevelP
private val topLevelPPrivateCustomGetter: Result<Int>
get() = TODO()
val asFunctional: () -> Result<Int> = TODO()
open class PublicCls(
val r1: Result<String>,
val r2: Result<Int>?,
val r3: ResultAlias<Int>,
val r4: ResultAlias<Int>?,
val r5: InlineResult<Int>,
internal val r6: Result<Int>,
private val r7: Result<Int>,
val r8: List<Result<Int>>
) {
val p1: Result<Int> = TODO()
var p2: Result<Int> = TODO()
val p3: ResultAlias<Int>? = TODO()
val p4 = p1
internal val p5: Result<Int> = TODO()
private var p6: Result<Int> = TODO()
internal val p7 = p1
protected val p8 = p1
fun returnInCls(): Result<Int> = TODO()
protected fun returnInClsProtected(): Result<Int> = TODO()
private fun returnInClsPrivate(): Result<Int> = TODO()
}
internal open class InternalCls(
val r1: Result<Int>,
val r2: ResultAlias<Int>?,
val r3: List<Result<Int>>
) {
companion object {
val cr1: Result<Int> = TODO()
private val cr2: Result<Int> = TODO()
}
val p1 = r1
val p2: Result<String> = TODO()
protected val p3 = p1
fun returnInInternal(): Result<Int> = TODO()
protected fun returnInClsProtected(): Result<Int> = TODO()
}
private class PrivateCls(
val r1: Result<Int>,
val r2: ResultAlias<Int>?,
val r3: List<Result<Int>>
) {
companion object {
val cr1: Result<Int> = TODO()
private val cr2: Result<Int> = TODO()
}
val p1 = r1
val p2: Result<String> = TODO()
fun returnInPrivate(): Result<Int> = TODO()
}
fun local(r: Result<Int>) {
val l1: Result<Int>? = null
val l2 = r
fun localFun(): Result<Int> = TODO()
class F {
val p1: Result<Int> = r
val p2 = r
}
}
fun <T> resultInGenericFun(r: Result<Int>): T = r as T
val asFunPublic: () -> Result<Int> = TODO()
private val asFun: () -> Result<Int>? = TODO()
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER, -UNUSED_EXPRESSION, -UNUSED_VARIABLE
// !LANGUAGE: +InlineClasses +AllowResultInReturnType, -JvmInlineValueClasses
@@ -1,371 +0,0 @@
import java.util.HashMap
private fun <A> unaryOperation(
a: CompileTimeType<A>,
functionName: String,
operation: Function1<A, Any>,
checker: Function1<Long, Long>
) = UnaryOperationKey(a, functionName) to Pair(operation, checker) as Pair<Function1<Any?, Any>, Function1<Long, Long>>
private fun <A, B> binaryOperation(
a: CompileTimeType<A>,
b: CompileTimeType<B>,
functionName: String,
operation: Function2<A, B, Any>,
checker: Function2<BigInteger, BigInteger, BigInteger>
) = BinaryOperationKey(a, b, functionName) to Pair(operation, checker) as Pair<Function2<Any?, Any?, Any>, Function2<BigInteger, BigInteger, BigInteger>>
private data class UnaryOperationKey<A>(val f: CompileTimeType<out A>, val functionName: String)
//HashMap<BinaryOperationKey<*, *>, Pair<Function2<Any?, Any?, Any>, Function2<BigInteger, BigInteger, BigInteger>>>
private data class BinaryOperationKey<A, B>(val f: CompileTimeType<out A>, val g: CompileTimeType<out B>, val functionName: String)
private class CompileTimeType<T>
private val BYTE = CompileTimeType<Byte>()
private val CHAR = CompileTimeType<Char>()
private val BOOLEAN = CompileTimeType<Boolean>()
private val DOUBLE = CompileTimeType<Double>()
private val FLOAT = CompileTimeType<Float>()
private val INT = CompileTimeType<Int>()
private val LONG = CompileTimeType<Long>()
private val SHORT = CompileTimeType<Short>()
private val STRING = CompileTimeType<String>()
private val ANY = CompileTimeType<Any>()
private val emptyBinaryFun: Function2<BigInteger, BigInteger, BigInteger> = { a, b -> BigInteger("0") }
private val emptyUnaryFun: Function1<Long, Long> = { a -> 1.toLong() }
private val unaryOperations: HashMap<UnaryOperationKey<*>, Pair<Function1<Any?, Any>, Function1<Long, Long>>>
= hashMapOf<UnaryOperationKey<*>, Pair<Function1<Any?, Any>, Function1<Long, Long>>>(
unaryOperation(BOOLEAN, "not!", { a -> a.not() }, emptyUnaryFun),
unaryOperation(BYTE, "toInt", { a -> a.toInt() }, emptyUnaryFun),
unaryOperation(BYTE, "minus", { a -> a.unaryMinus() }, { a -> a.unaryMinus() }),
unaryOperation(BYTE, "minus", { a -> a.unaryMinus() }, { a -> a.unaryMinus() }),
unaryOperation(BYTE, "toChar", { a -> a.<!DEPRECATION!>toChar<!>() }, emptyUnaryFun),
unaryOperation(BYTE, "toLong", { a -> a.toLong() }, emptyUnaryFun),
unaryOperation(BYTE, "plus", { a -> a.unaryPlus() }, emptyUnaryFun),
unaryOperation(BYTE, "toFloat", { a -> a.toFloat() }, emptyUnaryFun),
unaryOperation(BYTE, "toDouble", { a -> a.toDouble() }, emptyUnaryFun),
unaryOperation(BYTE, "toShort", { a -> a.toShort() }, emptyUnaryFun),
unaryOperation(BYTE, "toByte", { a -> a.toByte() }, emptyUnaryFun),
unaryOperation(CHAR, "toInt", { a -> a.<!DEPRECATION!>toInt<!>() }, emptyUnaryFun),
unaryOperation(CHAR, "toChar", { a -> a.toChar() }, emptyUnaryFun),
unaryOperation(CHAR, "toLong", { a -> a.<!DEPRECATION!>toLong<!>() }, emptyUnaryFun),
unaryOperation(CHAR, "toFloat", { a -> a.<!DEPRECATION!>toFloat<!>() }, emptyUnaryFun),
unaryOperation(CHAR, "toDouble", { a -> a.<!DEPRECATION!>toDouble<!>() }, emptyUnaryFun),
unaryOperation(CHAR, "toShort", { a -> a.<!DEPRECATION!>toShort<!>() }, emptyUnaryFun),
unaryOperation(CHAR, "toByte", { a -> a.<!DEPRECATION!>toByte<!>() }, emptyUnaryFun),
unaryOperation(DOUBLE, "toInt", { a -> a.toInt() }, emptyUnaryFun),
unaryOperation(DOUBLE, "minus", { a -> a.unaryMinus() }, emptyUnaryFun),
unaryOperation(DOUBLE, "toChar", { a -> a.<!DEPRECATION!>toChar<!>() }, emptyUnaryFun),
unaryOperation(DOUBLE, "toLong", { a -> a.toLong() }, emptyUnaryFun),
unaryOperation(DOUBLE, "plus", { a -> a.unaryPlus() }, emptyUnaryFun),
unaryOperation(DOUBLE, "toFloat", { a -> a.toFloat() }, emptyUnaryFun),
unaryOperation(DOUBLE, "toDouble", { a -> a.toDouble() }, emptyUnaryFun),
unaryOperation(DOUBLE, "toShort", { a -> a.<!DEPRECATION_ERROR!>toShort<!>() }, emptyUnaryFun),
unaryOperation(DOUBLE, "toByte", { a -> a.<!DEPRECATION_ERROR!>toByte<!>() }, emptyUnaryFun),
unaryOperation(FLOAT, "toInt", { a -> a.toInt() }, emptyUnaryFun),
unaryOperation(FLOAT, "minus", { a -> a.unaryMinus() }, emptyUnaryFun),
unaryOperation(FLOAT, "toChar", { a -> a.<!DEPRECATION!>toChar<!>() }, emptyUnaryFun),
unaryOperation(FLOAT, "toLong", { a -> a.toLong() }, emptyUnaryFun),
unaryOperation(FLOAT, "plus", { a -> a.unaryPlus() }, emptyUnaryFun),
unaryOperation(FLOAT, "toFloat", { a -> a.toFloat() }, emptyUnaryFun),
unaryOperation(FLOAT, "toDouble", { a -> a.toDouble() }, emptyUnaryFun),
unaryOperation(FLOAT, "toShort", { a -> a.<!DEPRECATION_ERROR!>toShort<!>() }, emptyUnaryFun),
unaryOperation(FLOAT, "toByte", { a -> a.<!DEPRECATION_ERROR!>toByte<!>() }, emptyUnaryFun),
unaryOperation(INT, "plus", { a -> a.unaryPlus() }, emptyUnaryFun),
unaryOperation(INT, "toShort", { a -> a.toShort() }, emptyUnaryFun),
unaryOperation(INT, "toByte", { a -> a.toByte() }, emptyUnaryFun),
unaryOperation(INT, "inv", { a -> a.inv() }, emptyUnaryFun),
unaryOperation(INT, "toInt", { a -> a.toInt() }, emptyUnaryFun),
unaryOperation(INT, "minus", { a -> a.unaryMinus() }, { a -> a.unaryMinus() }),
unaryOperation(INT, "toChar", { a -> a.toChar() }, emptyUnaryFun),
unaryOperation(INT, "toLong", { a -> a.toLong() }, emptyUnaryFun),
unaryOperation(INT, "toDouble", { a -> a.toDouble() }, emptyUnaryFun),
unaryOperation(INT, "toFloat", { a -> a.toFloat() }, emptyUnaryFun),
unaryOperation(LONG, "plus", { a -> a.unaryPlus() }, emptyUnaryFun),
unaryOperation(LONG, "toShort", { a -> a.toShort() }, emptyUnaryFun),
unaryOperation(LONG, "toByte", { a -> a.toByte() }, emptyUnaryFun),
unaryOperation(LONG, "inv", { a -> a.inv() }, emptyUnaryFun),
unaryOperation(LONG, "toInt", { a -> a.toInt() }, emptyUnaryFun),
unaryOperation(LONG, "minus", { a -> a.unaryMinus() }, { a -> a.unaryMinus() }),
unaryOperation(LONG, "toChar", { a -> a.<!DEPRECATION!>toChar<!>() }, emptyUnaryFun),
unaryOperation(LONG, "toLong", { a -> a.toLong() }, emptyUnaryFun),
unaryOperation(LONG, "toDouble", { a -> a.toDouble() }, emptyUnaryFun),
unaryOperation(LONG, "toFloat", { a -> a.toFloat() }, emptyUnaryFun),
unaryOperation(SHORT, "toInt", { a -> a.toInt() }, emptyUnaryFun),
unaryOperation(SHORT, "minus", { a -> a.unaryMinus() }, { a -> a.unaryMinus() }),
unaryOperation(SHORT, "toChar", { a -> a.<!DEPRECATION!>toChar<!>() }, emptyUnaryFun),
unaryOperation(SHORT, "toLong", { a -> a.toLong() }, emptyUnaryFun),
unaryOperation(SHORT, "plus", { a -> a.unaryPlus() }, emptyUnaryFun),
unaryOperation(SHORT, "toFloat", { a -> a.toFloat() }, emptyUnaryFun),
unaryOperation(SHORT, "toDouble", { a -> a.toDouble() }, emptyUnaryFun),
unaryOperation(SHORT, "toShort", { a -> a.toShort() }, emptyUnaryFun),
unaryOperation(SHORT, "toByte", { a -> a.toByte() }, emptyUnaryFun),
unaryOperation(STRING, "toString", { a -> a.toString() }, emptyUnaryFun)
)
private val binaryOperations: HashMap<BinaryOperationKey<*, *>, Pair<Function2<Any?, Any?, Any>, Function2<BigInteger, BigInteger, BigInteger>>>
= hashMapOf<BinaryOperationKey<*, *>, Pair<Function2<Any?, Any?, Any>, Function2<BigInteger, BigInteger, BigInteger>>>(
binaryOperation(BOOLEAN, BOOLEAN, "xor", { a, b -> a.xor(b) }, emptyBinaryFun),
binaryOperation(BOOLEAN, BOOLEAN, "or", { a, b -> a.or(b) }, emptyBinaryFun),
binaryOperation(BOOLEAN, ANY, "equals", { a, b -> a.equals(b) }, emptyBinaryFun),
binaryOperation(BOOLEAN, BOOLEAN, "and", { a, b -> a.and(b) }, emptyBinaryFun),
binaryOperation(BOOLEAN, BOOLEAN, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun),
binaryOperation(BYTE, BYTE, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }),
binaryOperation(BYTE, DOUBLE, "minus", { a, b -> a.minus(b) }, emptyBinaryFun),
binaryOperation(BYTE, FLOAT, "minus", { a, b -> a.minus(b) }, emptyBinaryFun),
binaryOperation(BYTE, INT, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }),
binaryOperation(BYTE, LONG, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }),
binaryOperation(BYTE, SHORT, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }),
binaryOperation(BYTE, BYTE, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun),
binaryOperation(BYTE, DOUBLE, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun),
binaryOperation(BYTE, FLOAT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun),
binaryOperation(BYTE, INT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun),
binaryOperation(BYTE, LONG, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun),
binaryOperation(BYTE, SHORT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun),
binaryOperation(BYTE, BYTE, "plus", { a, b -> a.plus(b) }, { a, b -> a.add(b) }),
binaryOperation(BYTE, DOUBLE, "plus", { a, b -> a.plus(b) }, emptyBinaryFun),
binaryOperation(BYTE, FLOAT, "plus", { a, b -> a.plus(b) }, emptyBinaryFun),
binaryOperation(BYTE, INT, "plus", { a, b -> a.plus(b) }, { a, b -> a.add(b) }),
binaryOperation(BYTE, LONG, "plus", { a, b -> a.plus(b) }, { a, b -> a.add(b) }),
binaryOperation(BYTE, SHORT, "plus", { a, b -> a.plus(b) }, { a, b -> a.add(b) }),
binaryOperation(BYTE, BYTE, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }),
binaryOperation(BYTE, DOUBLE, "div", { a, b -> a.div(b) }, emptyBinaryFun),
binaryOperation(BYTE, FLOAT, "div", { a, b -> a.div(b) }, emptyBinaryFun),
binaryOperation(BYTE, INT, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }),
binaryOperation(BYTE, LONG, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }),
binaryOperation(BYTE, SHORT, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }),
binaryOperation(BYTE, BYTE, "rem", { a, b -> a.rem(b) }, { a, b -> a.rem(b) }),
binaryOperation(BYTE, DOUBLE, "rem", { a, b -> a.rem(b) }, emptyBinaryFun),
binaryOperation(BYTE, FLOAT, "rem", { a, b -> a.rem(b) }, emptyBinaryFun),
binaryOperation(BYTE, INT, "rem", { a, b -> a.rem(b) }, { a, b -> a.rem(b) }),
binaryOperation(BYTE, LONG, "rem", { a, b -> a.rem(b) }, { a, b -> a.rem(b) }),
binaryOperation(BYTE, SHORT, "rem", { a, b -> a.rem(b) }, { a, b -> a.rem(b) }),
binaryOperation(BYTE, BYTE, "times", { a, b -> a.times(b) }, { a, b -> a.multiply(b) }),
binaryOperation(BYTE, DOUBLE, "times", { a, b -> a.times(b) }, emptyBinaryFun),
binaryOperation(BYTE, FLOAT, "times", { a, b -> a.times(b) }, emptyBinaryFun),
binaryOperation(BYTE, INT, "times", { a, b -> a.times(b) }, { a, b -> a.multiply(b) }),
binaryOperation(BYTE, LONG, "times", { a, b -> a.times(b) }, { a, b -> a.multiply(b) }),
binaryOperation(BYTE, SHORT, "times", { a, b -> a.times(b) }, { a, b -> a.multiply(b) }),
binaryOperation(BYTE, ANY, "equals", { a, b -> a.equals(b) }, emptyBinaryFun),
binaryOperation(CHAR, CHAR, "minus", { a, b -> a.minus(b) }, emptyBinaryFun),
binaryOperation(CHAR, CHAR, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun),
binaryOperation(CHAR, INT, "minus", { a, b -> a.minus(b) }, emptyBinaryFun),
binaryOperation(CHAR, INT, "plus", { a, b -> a.plus(b) }, emptyBinaryFun),
binaryOperation(CHAR, ANY, "equals", { a, b -> a.equals(b) }, emptyBinaryFun),
binaryOperation(DOUBLE, BYTE, "minus", { a, b -> a.minus(b) }, emptyBinaryFun),
binaryOperation(DOUBLE, DOUBLE, "minus", { a, b -> a.minus(b) }, emptyBinaryFun),
binaryOperation(DOUBLE, FLOAT, "minus", { a, b -> a.minus(b) }, emptyBinaryFun),
binaryOperation(DOUBLE, INT, "minus", { a, b -> a.minus(b) }, emptyBinaryFun),
binaryOperation(DOUBLE, LONG, "minus", { a, b -> a.minus(b) }, emptyBinaryFun),
binaryOperation(DOUBLE, SHORT, "minus", { a, b -> a.minus(b) }, emptyBinaryFun),
binaryOperation(DOUBLE, BYTE, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun),
binaryOperation(DOUBLE, DOUBLE, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun),
binaryOperation(DOUBLE, FLOAT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun),
binaryOperation(DOUBLE, INT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun),
binaryOperation(DOUBLE, LONG, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun),
binaryOperation(DOUBLE, SHORT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun),
binaryOperation(DOUBLE, BYTE, "plus", { a, b -> a.plus(b) }, emptyBinaryFun),
binaryOperation(DOUBLE, DOUBLE, "plus", { a, b -> a.plus(b) }, emptyBinaryFun),
binaryOperation(DOUBLE, FLOAT, "plus", { a, b -> a.plus(b) }, emptyBinaryFun),
binaryOperation(DOUBLE, INT, "plus", { a, b -> a.plus(b) }, emptyBinaryFun),
binaryOperation(DOUBLE, LONG, "plus", { a, b -> a.plus(b) }, emptyBinaryFun),
binaryOperation(DOUBLE, SHORT, "plus", { a, b -> a.plus(b) }, emptyBinaryFun),
binaryOperation(DOUBLE, BYTE, "div", { a, b -> a.div(b) }, emptyBinaryFun),
binaryOperation(DOUBLE, DOUBLE, "div", { a, b -> a.div(b) }, emptyBinaryFun),
binaryOperation(DOUBLE, FLOAT, "div", { a, b -> a.div(b) }, emptyBinaryFun),
binaryOperation(DOUBLE, INT, "div", { a, b -> a.div(b) }, emptyBinaryFun),
binaryOperation(DOUBLE, LONG, "div", { a, b -> a.div(b) }, emptyBinaryFun),
binaryOperation(DOUBLE, SHORT, "div", { a, b -> a.div(b) }, emptyBinaryFun),
binaryOperation(DOUBLE, BYTE, "rem", { a, b -> a.rem(b) }, emptyBinaryFun),
binaryOperation(DOUBLE, DOUBLE, "rem", { a, b -> a.rem(b) }, emptyBinaryFun),
binaryOperation(DOUBLE, FLOAT, "rem", { a, b -> a.rem(b) }, emptyBinaryFun),
binaryOperation(DOUBLE, INT, "rem", { a, b -> a.rem(b) }, emptyBinaryFun),
binaryOperation(DOUBLE, LONG, "rem", { a, b -> a.rem(b) }, emptyBinaryFun),
binaryOperation(DOUBLE, SHORT, "rem", { a, b -> a.rem(b) }, emptyBinaryFun),
binaryOperation(DOUBLE, BYTE, "times", { a, b -> a.times(b) }, emptyBinaryFun),
binaryOperation(DOUBLE, DOUBLE, "times", { a, b -> a.times(b) }, emptyBinaryFun),
binaryOperation(DOUBLE, FLOAT, "times", { a, b -> a.times(b) }, emptyBinaryFun),
binaryOperation(DOUBLE, INT, "times", { a, b -> a.times(b) }, emptyBinaryFun),
binaryOperation(DOUBLE, LONG, "times", { a, b -> a.times(b) }, emptyBinaryFun),
binaryOperation(DOUBLE, SHORT, "times", { a, b -> a.times(b) }, emptyBinaryFun),
binaryOperation(DOUBLE, ANY, "equals", { a, b -> a.equals(b) }, emptyBinaryFun),
binaryOperation(FLOAT, BYTE, "minus", { a, b -> a.minus(b) }, emptyBinaryFun),
binaryOperation(FLOAT, DOUBLE, "minus", { a, b -> a.minus(b) }, emptyBinaryFun),
binaryOperation(FLOAT, FLOAT, "minus", { a, b -> a.minus(b) }, emptyBinaryFun),
binaryOperation(FLOAT, INT, "minus", { a, b -> a.minus(b) }, emptyBinaryFun),
binaryOperation(FLOAT, LONG, "minus", { a, b -> a.minus(b) }, emptyBinaryFun),
binaryOperation(FLOAT, SHORT, "minus", { a, b -> a.minus(b) }, emptyBinaryFun),
binaryOperation(FLOAT, BYTE, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun),
binaryOperation(FLOAT, DOUBLE, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun),
binaryOperation(FLOAT, FLOAT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun),
binaryOperation(FLOAT, INT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun),
binaryOperation(FLOAT, LONG, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun),
binaryOperation(FLOAT, SHORT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun),
binaryOperation(FLOAT, BYTE, "plus", { a, b -> a.plus(b) }, emptyBinaryFun),
binaryOperation(FLOAT, DOUBLE, "plus", { a, b -> a.plus(b) }, emptyBinaryFun),
binaryOperation(FLOAT, FLOAT, "plus", { a, b -> a.plus(b) }, emptyBinaryFun),
binaryOperation(FLOAT, INT, "plus", { a, b -> a.plus(b) }, emptyBinaryFun),
binaryOperation(FLOAT, LONG, "plus", { a, b -> a.plus(b) }, emptyBinaryFun),
binaryOperation(FLOAT, SHORT, "plus", { a, b -> a.plus(b) }, emptyBinaryFun),
binaryOperation(FLOAT, BYTE, "div", { a, b -> a.div(b) }, emptyBinaryFun),
binaryOperation(FLOAT, DOUBLE, "div", { a, b -> a.div(b) }, emptyBinaryFun),
binaryOperation(FLOAT, FLOAT, "div", { a, b -> a.div(b) }, emptyBinaryFun),
binaryOperation(FLOAT, INT, "div", { a, b -> a.div(b) }, emptyBinaryFun),
binaryOperation(FLOAT, LONG, "div", { a, b -> a.div(b) }, emptyBinaryFun),
binaryOperation(FLOAT, SHORT, "div", { a, b -> a.div(b) }, emptyBinaryFun),
binaryOperation(FLOAT, BYTE, "rem", { a, b -> a.rem(b) }, emptyBinaryFun),
binaryOperation(FLOAT, DOUBLE, "rem", { a, b -> a.rem(b) }, emptyBinaryFun),
binaryOperation(FLOAT, FLOAT, "rem", { a, b -> a.rem(b) }, emptyBinaryFun),
binaryOperation(FLOAT, INT, "rem", { a, b -> a.rem(b) }, emptyBinaryFun),
binaryOperation(FLOAT, LONG, "rem", { a, b -> a.rem(b) }, emptyBinaryFun),
binaryOperation(FLOAT, SHORT, "rem", { a, b -> a.rem(b) }, emptyBinaryFun),
binaryOperation(FLOAT, BYTE, "times", { a, b -> a.times(b) }, emptyBinaryFun),
binaryOperation(FLOAT, DOUBLE, "times", { a, b -> a.times(b) }, emptyBinaryFun),
binaryOperation(FLOAT, FLOAT, "times", { a, b -> a.times(b) }, emptyBinaryFun),
binaryOperation(FLOAT, INT, "times", { a, b -> a.times(b) }, emptyBinaryFun),
binaryOperation(FLOAT, LONG, "times", { a, b -> a.times(b) }, emptyBinaryFun),
binaryOperation(FLOAT, SHORT, "times", { a, b -> a.times(b) }, emptyBinaryFun),
binaryOperation(FLOAT, ANY, "equals", { a, b -> a.equals(b) }, emptyBinaryFun),
binaryOperation(INT, BYTE, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun),
binaryOperation(INT, DOUBLE, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun),
binaryOperation(INT, FLOAT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun),
binaryOperation(INT, INT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun),
binaryOperation(INT, LONG, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun),
binaryOperation(INT, SHORT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun),
binaryOperation(INT, BYTE, "plus", { a, b -> a.plus(b) }, { a, b -> a.add(b) }),
binaryOperation(INT, DOUBLE, "plus", { a, b -> a.plus(b) }, emptyBinaryFun),
binaryOperation(INT, FLOAT, "plus", { a, b -> a.plus(b) }, emptyBinaryFun),
binaryOperation(INT, INT, "plus", { a, b -> a.plus(b) }, { a, b -> a.add(b) }),
binaryOperation(INT, LONG, "plus", { a, b -> a.plus(b) }, { a, b -> a.add(b) }),
binaryOperation(INT, SHORT, "plus", { a, b -> a.plus(b) }, { a, b -> a.add(b) }),
binaryOperation(INT, INT, "shl", { a, b -> a.shl(b) }, emptyBinaryFun),
binaryOperation(INT, INT, "ushr", { a, b -> a.ushr(b) }, emptyBinaryFun),
binaryOperation(INT, BYTE, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }),
binaryOperation(INT, DOUBLE, "div", { a, b -> a.div(b) }, emptyBinaryFun),
binaryOperation(INT, FLOAT, "div", { a, b -> a.div(b) }, emptyBinaryFun),
binaryOperation(INT, INT, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }),
binaryOperation(INT, LONG, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }),
binaryOperation(INT, SHORT, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }),
binaryOperation(INT, INT, "shr", { a, b -> a.shr(b) }, emptyBinaryFun),
binaryOperation(INT, BYTE, "rem", { a, b -> a.rem(b) }, { a, b -> a.rem(b) }),
binaryOperation(INT, DOUBLE, "rem", { a, b -> a.rem(b) }, emptyBinaryFun),
binaryOperation(INT, FLOAT, "rem", { a, b -> a.rem(b) }, emptyBinaryFun),
binaryOperation(INT, INT, "rem", { a, b -> a.rem(b) }, { a, b -> a.rem(b) }),
binaryOperation(INT, LONG, "rem", { a, b -> a.rem(b) }, { a, b -> a.rem(b) }),
binaryOperation(INT, SHORT, "rem", { a, b -> a.rem(b) }, { a, b -> a.rem(b) }),
binaryOperation(INT, BYTE, "times", { a, b -> a.times(b) }, { a, b -> a.multiply(b) }),
binaryOperation(INT, DOUBLE, "times", { a, b -> a.times(b) }, emptyBinaryFun),
binaryOperation(INT, FLOAT, "times", { a, b -> a.times(b) }, emptyBinaryFun),
binaryOperation(INT, INT, "times", { a, b -> a.times(b) }, { a, b -> a.multiply(b) }),
binaryOperation(INT, LONG, "times", { a, b -> a.times(b) }, { a, b -> a.multiply(b) }),
binaryOperation(INT, SHORT, "times", { a, b -> a.times(b) }, { a, b -> a.multiply(b) }),
binaryOperation(INT, INT, "or", { a, b -> a.or(b) }, { a, b -> a.or(b) }),
binaryOperation(INT, BYTE, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }),
binaryOperation(INT, DOUBLE, "minus", { a, b -> a.minus(b) }, emptyBinaryFun),
binaryOperation(INT, FLOAT, "minus", { a, b -> a.minus(b) }, emptyBinaryFun),
binaryOperation(INT, INT, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }),
binaryOperation(INT, LONG, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }),
binaryOperation(INT, SHORT, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }),
binaryOperation(INT, INT, "and", { a, b -> a.and(b) }, { a, b -> a.and(b) }),
binaryOperation(INT, INT, "xor", { a, b -> a.xor(b) }, { a, b -> a.xor(b) }),
binaryOperation(INT, ANY, "equals", { a, b -> a.equals(b) }, emptyBinaryFun),
binaryOperation(LONG, BYTE, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun),
binaryOperation(LONG, DOUBLE, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun),
binaryOperation(LONG, FLOAT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun),
binaryOperation(LONG, INT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun),
binaryOperation(LONG, LONG, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun),
binaryOperation(LONG, SHORT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun),
binaryOperation(LONG, BYTE, "plus", { a, b -> a.plus(b) }, { a, b -> a.add(b) }),
binaryOperation(LONG, DOUBLE, "plus", { a, b -> a.plus(b) }, emptyBinaryFun),
binaryOperation(LONG, FLOAT, "plus", { a, b -> a.plus(b) }, emptyBinaryFun),
binaryOperation(LONG, INT, "plus", { a, b -> a.plus(b) }, { a, b -> a.add(b) }),
binaryOperation(LONG, LONG, "plus", { a, b -> a.plus(b) }, { a, b -> a.add(b) }),
binaryOperation(LONG, SHORT, "plus", { a, b -> a.plus(b) }, { a, b -> a.add(b) }),
binaryOperation(LONG, INT, "shl", { a, b -> a.shl(b) }, emptyBinaryFun),
binaryOperation(LONG, INT, "ushr", { a, b -> a.ushr(b) }, emptyBinaryFun),
binaryOperation(LONG, BYTE, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }),
binaryOperation(LONG, DOUBLE, "div", { a, b -> a.div(b) }, emptyBinaryFun),
binaryOperation(LONG, FLOAT, "div", { a, b -> a.div(b) }, emptyBinaryFun),
binaryOperation(LONG, INT, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }),
binaryOperation(LONG, LONG, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }),
binaryOperation(LONG, SHORT, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }),
binaryOperation(LONG, INT, "shr", { a, b -> a.shr(b) }, emptyBinaryFun),
binaryOperation(LONG, BYTE, "rem", { a, b -> a.rem(b) }, { a, b -> a.rem(b) }),
binaryOperation(LONG, DOUBLE, "rem", { a, b -> a.rem(b) }, emptyBinaryFun),
binaryOperation(LONG, FLOAT, "rem", { a, b -> a.rem(b) }, emptyBinaryFun),
binaryOperation(LONG, INT, "rem", { a, b -> a.rem(b) }, { a, b -> a.rem(b) }),
binaryOperation(LONG, LONG, "rem", { a, b -> a.rem(b) }, { a, b -> a.rem(b) }),
binaryOperation(LONG, SHORT, "rem", { a, b -> a.rem(b) }, { a, b -> a.rem(b) }),
binaryOperation(LONG, BYTE, "times", { a, b -> a.times(b) }, { a, b -> a.multiply(b) }),
binaryOperation(LONG, DOUBLE, "times", { a, b -> a.times(b) }, emptyBinaryFun),
binaryOperation(LONG, FLOAT, "times", { a, b -> a.times(b) }, emptyBinaryFun),
binaryOperation(LONG, INT, "times", { a, b -> a.times(b) }, { a, b -> a.multiply(b) }),
binaryOperation(LONG, LONG, "times", { a, b -> a.times(b) }, { a, b -> a.multiply(b) }),
binaryOperation(LONG, SHORT, "times", { a, b -> a.times(b) }, { a, b -> a.multiply(b) }),
binaryOperation(LONG, LONG, "or", { a, b -> a.or(b) }, { a, b -> a.or(b) }),
binaryOperation(LONG, BYTE, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }),
binaryOperation(LONG, DOUBLE, "minus", { a, b -> a.minus(b) }, emptyBinaryFun),
binaryOperation(LONG, FLOAT, "minus", { a, b -> a.minus(b) }, emptyBinaryFun),
binaryOperation(LONG, INT, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }),
binaryOperation(LONG, LONG, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }),
binaryOperation(LONG, SHORT, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }),
binaryOperation(LONG, LONG, "and", { a, b -> a.and(b) }, { a, b -> a.and(b) }),
binaryOperation(LONG, LONG, "xor", { a, b -> a.xor(b) }, { a, b -> a.xor(b) }),
binaryOperation(LONG, ANY, "equals", { a, b -> a.equals(b) }, emptyBinaryFun),
binaryOperation(SHORT, BYTE, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }),
binaryOperation(SHORT, DOUBLE, "minus", { a, b -> a.minus(b) }, emptyBinaryFun),
binaryOperation(SHORT, FLOAT, "minus", { a, b -> a.minus(b) }, emptyBinaryFun),
binaryOperation(SHORT, INT, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }),
binaryOperation(SHORT, LONG, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }),
binaryOperation(SHORT, SHORT, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }),
binaryOperation(SHORT, BYTE, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun),
binaryOperation(SHORT, DOUBLE, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun),
binaryOperation(SHORT, FLOAT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun),
binaryOperation(SHORT, INT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun),
binaryOperation(SHORT, LONG, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun),
binaryOperation(SHORT, SHORT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun),
binaryOperation(SHORT, BYTE, "plus", { a, b -> a.plus(b) }, { a, b -> a.add(b) }),
binaryOperation(SHORT, DOUBLE, "plus", { a, b -> a.plus(b) }, emptyBinaryFun),
binaryOperation(SHORT, FLOAT, "plus", { a, b -> a.plus(b) }, emptyBinaryFun),
binaryOperation(SHORT, INT, "plus", { a, b -> a.plus(b) }, { a, b -> a.add(b) }),
binaryOperation(SHORT, LONG, "plus", { a, b -> a.plus(b) }, { a, b -> a.add(b) }),
binaryOperation(SHORT, SHORT, "plus", { a, b -> a.plus(b) }, { a, b -> a.add(b) }),
binaryOperation(SHORT, BYTE, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }),
binaryOperation(SHORT, DOUBLE, "div", { a, b -> a.div(b) }, emptyBinaryFun),
binaryOperation(SHORT, FLOAT, "div", { a, b -> a.div(b) }, emptyBinaryFun),
binaryOperation(SHORT, INT, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }),
binaryOperation(SHORT, LONG, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }),
binaryOperation(SHORT, SHORT, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }),
binaryOperation(SHORT, BYTE, "rem", { a, b -> a.rem(b) }, { a, b -> a.rem(b) }),
binaryOperation(SHORT, DOUBLE, "rem", { a, b -> a.rem(b) }, emptyBinaryFun),
binaryOperation(SHORT, FLOAT, "rem", { a, b -> a.rem(b) }, emptyBinaryFun),
binaryOperation(SHORT, INT, "rem", { a, b -> a.rem(b) }, { a, b -> a.rem(b) }),
binaryOperation(SHORT, LONG, "rem", { a, b -> a.rem(b) }, { a, b -> a.rem(b) }),
binaryOperation(SHORT, SHORT, "rem", { a, b -> a.rem(b) }, { a, b -> a.rem(b) }),
binaryOperation(SHORT, BYTE, "times", { a, b -> a.times(b) }, { a, b -> a.multiply(b) }),
binaryOperation(SHORT, DOUBLE, "times", { a, b -> a.times(b) }, emptyBinaryFun),
binaryOperation(SHORT, FLOAT, "times", { a, b -> a.times(b) }, emptyBinaryFun),
binaryOperation(SHORT, INT, "times", { a, b -> a.times(b) }, { a, b -> a.multiply(b) }),
binaryOperation(SHORT, LONG, "times", { a, b -> a.times(b) }, { a, b -> a.multiply(b) }),
binaryOperation(SHORT, SHORT, "times", { a, b -> a.times(b) }, { a, b -> a.multiply(b) }),
binaryOperation(SHORT, ANY, "equals", { a, b -> a.equals(b) }, emptyBinaryFun),
binaryOperation(STRING, ANY, "plus", { a, b -> a.plus(b) }, emptyBinaryFun),
binaryOperation(STRING, INT, "get", { a, b -> a.get(b) }, emptyBinaryFun),
binaryOperation(STRING, ANY, "equals", { a, b -> a.equals(b) }, emptyBinaryFun),
binaryOperation(STRING, STRING, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun)
)
//from library
class BigInteger(val value: String) {
fun add(o: BigInteger): BigInteger = o
fun divide(o: BigInteger): BigInteger = o
fun rem(o: BigInteger): BigInteger = o
fun multiply(o: BigInteger): BigInteger = o
fun subtract(o: BigInteger): BigInteger = o
fun or(o: BigInteger): BigInteger = o
fun and(o: BigInteger): BigInteger = o
fun xor(o: BigInteger): BigInteger = o
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
import java.util.HashMap
private fun <A> unaryOperation(
@@ -140,8 +140,8 @@ fun case_12(value_1: Int, value_2: Collection<Int>, value_3: Collection<Int>?) {
when {
value_1 == 1 -> value_2 as List<Int>
value_1 == 2 -> value_2 as? List<Int>
value_1 == 3 -> value_3 as? MutableMap<Int, Int>
value_1 == 4 -> (value_2 as? Map<Int, Int>) as MutableMap<Int, Int>
value_1 == 3 -> value_3 <!UNCHECKED_CAST!>as? MutableMap<Int, Int><!>
value_1 == 4 -> (value_2 <!UNCHECKED_CAST!>as? Map<Int, Int><!>) as MutableMap<Int, Int>
}
}
@@ -143,8 +143,8 @@ fun case_12(value_1: Int, value_2: Collection<Int>, value_3: Collection<Int>?) {
when (value_1) {
1 -> value_2 as List<Int>
2 -> value_2 as? List<Int>
3 -> value_3 as? MutableMap<Int, Int>
4 -> (value_2 as? Map<Int, Int>) as MutableMap<Int, Int>
3 -> value_3 <!UNCHECKED_CAST!>as? MutableMap<Int, Int><!>
4 -> (value_2 <!UNCHECKED_CAST!>as? Map<Int, Int><!>) as MutableMap<Int, Int>
}
}
@@ -105,8 +105,8 @@ fun case_10(value_1: Collection<Int>, value_2: Collection<Int>, value_3: Collect
when (value_1) {
value_2 as List<Int> -> {}
value_2 as? List<Int> -> {}
value_3 as? MutableMap<Int, Int> -> {}
(value_2 as? Map<Int, Int>) as MutableMap<Int, Int> -> {}
value_3 <!UNCHECKED_CAST!>as? MutableMap<Int, Int><!> -> {}
(value_2 <!UNCHECKED_CAST!>as? Map<Int, Int><!>) as MutableMap<Int, Int> -> {}
}
}
@@ -81,7 +81,7 @@ fun case_9(value_1: Any) {
fun case_10(value_1: Collection<Int>, value_2: Collection<Int>, value_3: Collection<Int>?) {
when (value_1) {
value_2 as List<Int>, value_2 as? List<Int> -> {}
value_3 as? MutableMap<Int, Int>, (value_2 as? Map<Int, Int>) as MutableMap<Int, Int> -> {}
value_3 <!UNCHECKED_CAST!>as? MutableMap<Int, Int><!>, (value_2 <!UNCHECKED_CAST!>as? Map<Int, Int><!>) as MutableMap<Int, Int> -> {}
}
}
@@ -4,8 +4,8 @@
// TESTCASE NUMBER: 1
fun <T, K> case_1(x: T?, y: K?) {
x as T
y as K
x <!UNCHECKED_CAST!>as T<!>
y <!UNCHECKED_CAST!>as K<!>
val z = <!DEBUG_INFO_EXPRESSION_TYPE("T? & T")!>x<!> ?: <!DEBUG_INFO_EXPRESSION_TYPE("K? & K")!>y<!>
<!DEBUG_INFO_EXPRESSION_TYPE("T? & T")!>x<!><!UNSAFE_CALL!>.<!>equals(10)
@@ -4,7 +4,7 @@
// TESTCASE NUMBER: 1
fun <T> case_1(x: Any?) where T: CharSequence {
x as T
x <!UNCHECKED_CAST!>as T<!>
class Case1<K> where K : T {
inline fun <reified T : Number> case_1() {
if (x is T) {
@@ -10,9 +10,9 @@ open class Case1<K : Number> {
open inner class Case1_1<L>: Case1<Int>() where L : CharSequence {
inner class Case1_2<M>: Case1<K>.Case1_1<<!UPPER_BOUND_VIOLATED!>M<!>>() where M : Map<K, L> {
inline fun <reified T>case_1(x: Any?) {
x as M
x as L
x as K
x <!UNCHECKED_CAST!>as M<!>
x <!UNCHECKED_CAST!>as L<!>
x <!UNCHECKED_CAST!>as K<!>
if (x is T) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any? & M & L & K & T!!")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any? & M & L & K & T!!")!>x<!>.toByte()
@@ -10,9 +10,9 @@ open class Case1<K : Number> {
open inner class Case1_1<L>: Case1<Int>() where L : CharSequence {
inner class Case1_2<M>: Case1<K>.Case1_1<<!UPPER_BOUND_VIOLATED!>M<!>>() where M : Map<K, L> {
inline fun <reified T>case_1(x: Any?) {
x as M
x as L
x as K
x <!UNCHECKED_CAST!>as M<!>
x <!UNCHECKED_CAST!>as L<!>
x <!UNCHECKED_CAST!>as K<!>
if (x is T) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any? & M & L & K & T!!")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any? & M & L & K & T!!")!>x<!>.toByte()
@@ -10,9 +10,9 @@ open class Case1<K : Number> {
open inner class Case1_1<L>: Case1<Int>() where L : CharSequence {
inner class Case1_2<M>: Case1<K>.Case1_1<<!UPPER_BOUND_VIOLATED!>M<!>>() where M : Map<K, L> {
inline fun <reified T>case_1(x: Any?) {
x as M
x as L
x as K
x <!UNCHECKED_CAST!>as M<!>
x <!UNCHECKED_CAST!>as L<!>
x <!UNCHECKED_CAST!>as K<!>
if (x is T) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any? & M & L & K & T!!")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any? & M & L & K & T!!")!>x<!>.toByte()
@@ -85,7 +85,7 @@ fun <T> Inv<out T>.case_7() {
// TESTCASE NUMBER: 8
fun <T> T.case_8() {
this as MutableList<T>
this <!UNCHECKED_CAST!>as MutableList<T><!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.reflect.KFunction1<kotlin.Any?, kotlin.Boolean>")!>this::equals<!>
this.equals(10)
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.reflect.KFunction1<kotlin.Any?, kotlin.Boolean>")!>::equals<!>
@@ -9,7 +9,7 @@
*/
fun case_1() {
val list = mutableListOf<String>()
val ints = list as MutableList<Int>
val ints = list <!UNCHECKED_CAST!>as MutableList<Int><!>
val strs = list as MutableList<String>
strs.add("two")
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.collections.MutableList<kotlin.String> & kotlin.collections.MutableList<kotlin.Int> & kotlin.collections.MutableList<kotlin.String>")!>list<!>