/*
 * Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
 * that can be found in the LICENSE file.
 */

package codegen.interfaceCallsNCasts.conservativeItable

import kotlin.test.*

interface I0 {
    fun foo0(x: Int): Int
}
interface I1 {
    fun foo1(x: Int): Int
}
interface I2 {
    fun foo2(x: Int): Int
}
interface I3 {
    fun foo3(x: Int): Int
}
interface I4 {
    fun foo4(x: Int): Int
}
interface I5 {
    fun foo5(x: Int): Int
}
interface I6 {
    fun foo6(x: Int): Int
}
interface I7 {
    fun foo7(x: Int): Int
}
interface I8 {
    fun foo8(x: Int): Int
}
interface I9 {
    fun foo9(x: Int): Int
}
interface I10 {
    fun foo10(x: Int): Int
}
interface I11 {
    fun foo11(x: Int): Int
}
interface I12 {
    fun foo12(x: Int): Int
}
interface I13 {
    fun foo13(x: Int): Int
}
interface I14 {
    fun foo14(x: Int): Int
}
interface I15 {
    fun foo15(x: Int): Int
}
interface I16 {
    fun foo16(x: Int): Int
}
interface I17 {
    fun foo17(x: Int): Int
}
interface I18 {
    fun foo18(x: Int): Int
}
interface I19 {
    fun foo19(x: Int): Int
}
interface I20 {
    fun foo20(x: Int): Int
}
interface I21 {
    fun foo21(x: Int): Int
}
interface I22 {
    fun foo22(x: Int): Int
}
interface I23 {
    fun foo23(x: Int): Int
}
interface I24 {
    fun foo24(x: Int): Int
}
interface I25 {
    fun foo25(x: Int): Int
}
interface I26 {
    fun foo26(x: Int): Int
}
interface I27 {
    fun foo27(x: Int): Int
}
interface I28 {
    fun foo28(x: Int): Int
}
interface I29 {
    fun foo29(x: Int): Int
}
interface I30 {
    fun foo30(x: Int): Int
}
interface I31 {
    fun foo31(x: Int): Int
}
interface I32 {
    fun foo32(x: Int): Int
}
interface I33 {
    fun foo33(x: Int): Int
}
interface I34 {
    fun foo34(x: Int): Int
}
interface I35 {
    fun foo35(x: Int): Int
}
interface I36 {
    fun foo36(x: Int): Int
}
interface I37 {
    fun foo37(x: Int): Int
}
interface I38 {
    fun foo38(x: Int): Int
}
interface I39 {
    fun foo39(x: Int): Int
}
interface I40 {
    fun foo40(x: Int): Int
}
interface I41 {
    fun foo41(x: Int): Int
}
interface I42 {
    fun foo42(x: Int): Int
}
interface I43 {
    fun foo43(x: Int): Int
}
interface I44 {
    fun foo44(x: Int): Int
}
interface I45 {
    fun foo45(x: Int): Int
}
interface I46 {
    fun foo46(x: Int): Int
}
interface I47 {
    fun foo47(x: Int): Int
}
interface I48 {
    fun foo48(x: Int): Int
}
interface I49 {
    fun foo49(x: Int): Int
}
interface I50 {
    fun foo50(x: Int): Int
}
interface I51 {
    fun foo51(x: Int): Int
}
interface I52 {
    fun foo52(x: Int): Int
}
interface I53 {
    fun foo53(x: Int): Int
}
interface I54 {
    fun foo54(x: Int): Int
}
interface I55 {
    fun foo55(x: Int): Int
}
interface I56 {
    fun foo56(x: Int): Int
}
interface I57 {
    fun foo57(x: Int): Int
}
interface I58 {
    fun foo58(x: Int): Int
}
interface I59 {
    fun foo59(x: Int): Int
}
interface I60 {
    fun foo60(x: Int): Int
}
interface I61 {
    fun foo61(x: Int): Int
}
interface I62 {
    fun foo62(x: Int): Int
}
interface I63 {
    fun foo63(x: Int): Int
}
interface I64 {
    fun foo64(x: Int): Int
}
interface I65 {
    fun foo65(x: Int): Int
}
interface I66 {
    fun foo66(x: Int): Int
}
interface I67 {
    fun foo67(x: Int): Int
}
interface I68 {
    fun foo68(x: Int): Int
}
interface I69 {
    fun foo69(x: Int): Int
}
interface I70 {
    fun foo70(x: Int): Int
}
interface I71 {
    fun foo71(x: Int): Int
}
interface I72 {
    fun foo72(x: Int): Int
}
interface I73 {
    fun foo73(x: Int): Int
}
interface I74 {
    fun foo74(x: Int): Int
}
interface I75 {
    fun foo75(x: Int): Int
}
interface I76 {
    fun foo76(x: Int): Int
}
interface I77 {
    fun foo77(x: Int): Int
}
interface I78 {
    fun foo78(x: Int): Int
}
interface I79 {
    fun foo79(x: Int): Int
}
interface I80 {
    fun foo80(x: Int): Int
}
interface I81 {
    fun foo81(x: Int): Int
}
interface I82 {
    fun foo82(x: Int): Int
}
interface I83 {
    fun foo83(x: Int): Int
}
interface I84 {
    fun foo84(x: Int): Int
}
interface I85 {
    fun foo85(x: Int): Int
}
interface I86 {
    fun foo86(x: Int): Int
}
interface I87 {
    fun foo87(x: Int): Int
}
interface I88 {
    fun foo88(x: Int): Int
}
interface I89 {
    fun foo89(x: Int): Int
}
interface I90 {
    fun foo90(x: Int): Int
}
interface I91 {
    fun foo91(x: Int): Int
}
interface I92 {
    fun foo92(x: Int): Int
}
interface I93 {
    fun foo93(x: Int): Int
}
interface I94 {
    fun foo94(x: Int): Int
}
interface I95 {
    fun foo95(x: Int): Int
}
interface I96 {
    fun foo96(x: Int): Int
}
interface I97 {
    fun foo97(x: Int): Int
}
interface I98 {
    fun foo98(x: Int): Int
}
interface I99 {
    fun foo99(x: Int): Int
}
class Bar : I0, I1, I2, I3, I4, I5, I6, I7, I8, I9, I10, I11, I12, I13, I14, I15, I16, I17, I18, I19, I20, I21, I22,
        I23, I24, I25, I26, I27, I28, I29, I30, I31, I32, I33, I34, I35, I36, I37, I38, I39, I40, I41, I42, I43, I44,
        I45, I46, I47, I48, I49, I50, I51, I52, I53, I54, I55, I56, I57, I58, I59, I60, I61, I62, I63, I64, I65, I66,
        I67, I68, I69, I70, I71, I72, I73, I74, I75, I76, I77, I78, I79, I80, I81, I82, I83, I84, I85, I86, I87, I88,
        I89, I90, I91, I92, I93, I94, I95, I96, I97, I98, I99 {
    override fun foo0(x: Int) = x + 0
    override fun foo1(x: Int) = x + 1
    override fun foo2(x: Int) = x + 2
    override fun foo3(x: Int) = x + 3
    override fun foo4(x: Int) = x + 4
    override fun foo5(x: Int) = x + 5
    override fun foo6(x: Int) = x + 6
    override fun foo7(x: Int) = x + 7
    override fun foo8(x: Int) = x + 8
    override fun foo9(x: Int) = x + 9
    override fun foo10(x: Int) = x + 10
    override fun foo11(x: Int) = x + 11
    override fun foo12(x: Int) = x + 12
    override fun foo13(x: Int) = x + 13
    override fun foo14(x: Int) = x + 14
    override fun foo15(x: Int) = x + 15
    override fun foo16(x: Int) = x + 16
    override fun foo17(x: Int) = x + 17
    override fun foo18(x: Int) = x + 18
    override fun foo19(x: Int) = x + 19
    override fun foo20(x: Int) = x + 20
    override fun foo21(x: Int) = x + 21
    override fun foo22(x: Int) = x + 22
    override fun foo23(x: Int) = x + 23
    override fun foo24(x: Int) = x + 24
    override fun foo25(x: Int) = x + 25
    override fun foo26(x: Int) = x + 26
    override fun foo27(x: Int) = x + 27
    override fun foo28(x: Int) = x + 28
    override fun foo29(x: Int) = x + 29
    override fun foo30(x: Int) = x + 30
    override fun foo31(x: Int) = x + 31
    override fun foo32(x: Int) = x + 32
    override fun foo33(x: Int) = x + 33
    override fun foo34(x: Int) = x + 34
    override fun foo35(x: Int) = x + 35
    override fun foo36(x: Int) = x + 36
    override fun foo37(x: Int) = x + 37
    override fun foo38(x: Int) = x + 38
    override fun foo39(x: Int) = x + 39
    override fun foo40(x: Int) = x + 40
    override fun foo41(x: Int) = x + 41
    override fun foo42(x: Int) = x + 42
    override fun foo43(x: Int) = x + 43
    override fun foo44(x: Int) = x + 44
    override fun foo45(x: Int) = x + 45
    override fun foo46(x: Int) = x + 46
    override fun foo47(x: Int) = x + 47
    override fun foo48(x: Int) = x + 48
    override fun foo49(x: Int) = x + 49
    override fun foo50(x: Int) = x + 50
    override fun foo51(x: Int) = x + 51
    override fun foo52(x: Int) = x + 52
    override fun foo53(x: Int) = x + 53
    override fun foo54(x: Int) = x + 54
    override fun foo55(x: Int) = x + 55
    override fun foo56(x: Int) = x + 56
    override fun foo57(x: Int) = x + 57
    override fun foo58(x: Int) = x + 58
    override fun foo59(x: Int) = x + 59
    override fun foo60(x: Int) = x + 60
    override fun foo61(x: Int) = x + 61
    override fun foo62(x: Int) = x + 62
    override fun foo63(x: Int) = x + 63
    override fun foo64(x: Int) = x + 64
    override fun foo65(x: Int) = x + 65
    override fun foo66(x: Int) = x + 66
    override fun foo67(x: Int) = x + 67
    override fun foo68(x: Int) = x + 68
    override fun foo69(x: Int) = x + 69
    override fun foo70(x: Int) = x + 70
    override fun foo71(x: Int) = x + 71
    override fun foo72(x: Int) = x + 72
    override fun foo73(x: Int) = x + 73
    override fun foo74(x: Int) = x + 74
    override fun foo75(x: Int) = x + 75
    override fun foo76(x: Int) = x + 76
    override fun foo77(x: Int) = x + 77
    override fun foo78(x: Int) = x + 78
    override fun foo79(x: Int) = x + 79
    override fun foo80(x: Int) = x + 80
    override fun foo81(x: Int) = x + 81
    override fun foo82(x: Int) = x + 82
    override fun foo83(x: Int) = x + 83
    override fun foo84(x: Int) = x + 84
    override fun foo85(x: Int) = x + 85
    override fun foo86(x: Int) = x + 86
    override fun foo87(x: Int) = x + 87
    override fun foo88(x: Int) = x + 88
    override fun foo89(x: Int) = x + 89
    override fun foo90(x: Int) = x + 90
    override fun foo91(x: Int) = x + 91
    override fun foo92(x: Int) = x + 92
    override fun foo93(x: Int) = x + 93
    override fun foo94(x: Int) = x + 94
    override fun foo95(x: Int) = x + 95
    override fun foo96(x: Int) = x + 96
    override fun foo97(x: Int) = x + 97
    override fun foo98(x: Int) = x + 98
    override fun foo99(x: Int) = x + 99
}

fun check_is_I0(x: Any) = x is I0
fun check_is_I1(x: Any) = x is I1
fun check_is_I2(x: Any) = x is I2
fun check_is_I3(x: Any) = x is I3
fun check_is_I4(x: Any) = x is I4
fun check_is_I5(x: Any) = x is I5
fun check_is_I6(x: Any) = x is I6
fun check_is_I7(x: Any) = x is I7
fun check_is_I8(x: Any) = x is I8
fun check_is_I9(x: Any) = x is I9
fun check_is_I10(x: Any) = x is I10
fun check_is_I11(x: Any) = x is I11
fun check_is_I12(x: Any) = x is I12
fun check_is_I13(x: Any) = x is I13
fun check_is_I14(x: Any) = x is I14
fun check_is_I15(x: Any) = x is I15
fun check_is_I16(x: Any) = x is I16
fun check_is_I17(x: Any) = x is I17
fun check_is_I18(x: Any) = x is I18
fun check_is_I19(x: Any) = x is I19
fun check_is_I20(x: Any) = x is I20
fun check_is_I21(x: Any) = x is I21
fun check_is_I22(x: Any) = x is I22
fun check_is_I23(x: Any) = x is I23
fun check_is_I24(x: Any) = x is I24
fun check_is_I25(x: Any) = x is I25
fun check_is_I26(x: Any) = x is I26
fun check_is_I27(x: Any) = x is I27
fun check_is_I28(x: Any) = x is I28
fun check_is_I29(x: Any) = x is I29
fun check_is_I30(x: Any) = x is I30
fun check_is_I31(x: Any) = x is I31
fun check_is_I32(x: Any) = x is I32
fun check_is_I33(x: Any) = x is I33
fun check_is_I34(x: Any) = x is I34
fun check_is_I35(x: Any) = x is I35
fun check_is_I36(x: Any) = x is I36
fun check_is_I37(x: Any) = x is I37
fun check_is_I38(x: Any) = x is I38
fun check_is_I39(x: Any) = x is I39
fun check_is_I40(x: Any) = x is I40
fun check_is_I41(x: Any) = x is I41
fun check_is_I42(x: Any) = x is I42
fun check_is_I43(x: Any) = x is I43
fun check_is_I44(x: Any) = x is I44
fun check_is_I45(x: Any) = x is I45
fun check_is_I46(x: Any) = x is I46
fun check_is_I47(x: Any) = x is I47
fun check_is_I48(x: Any) = x is I48
fun check_is_I49(x: Any) = x is I49
fun check_is_I50(x: Any) = x is I50
fun check_is_I51(x: Any) = x is I51
fun check_is_I52(x: Any) = x is I52
fun check_is_I53(x: Any) = x is I53
fun check_is_I54(x: Any) = x is I54
fun check_is_I55(x: Any) = x is I55
fun check_is_I56(x: Any) = x is I56
fun check_is_I57(x: Any) = x is I57
fun check_is_I58(x: Any) = x is I58
fun check_is_I59(x: Any) = x is I59
fun check_is_I60(x: Any) = x is I60
fun check_is_I61(x: Any) = x is I61
fun check_is_I62(x: Any) = x is I62
fun check_is_I63(x: Any) = x is I63
fun check_is_I64(x: Any) = x is I64
fun check_is_I65(x: Any) = x is I65
fun check_is_I66(x: Any) = x is I66
fun check_is_I67(x: Any) = x is I67
fun check_is_I68(x: Any) = x is I68
fun check_is_I69(x: Any) = x is I69
fun check_is_I70(x: Any) = x is I70
fun check_is_I71(x: Any) = x is I71
fun check_is_I72(x: Any) = x is I72
fun check_is_I73(x: Any) = x is I73
fun check_is_I74(x: Any) = x is I74
fun check_is_I75(x: Any) = x is I75
fun check_is_I76(x: Any) = x is I76
fun check_is_I77(x: Any) = x is I77
fun check_is_I78(x: Any) = x is I78
fun check_is_I79(x: Any) = x is I79
fun check_is_I80(x: Any) = x is I80
fun check_is_I81(x: Any) = x is I81
fun check_is_I82(x: Any) = x is I82
fun check_is_I83(x: Any) = x is I83
fun check_is_I84(x: Any) = x is I84
fun check_is_I85(x: Any) = x is I85
fun check_is_I86(x: Any) = x is I86
fun check_is_I87(x: Any) = x is I87
fun check_is_I88(x: Any) = x is I88
fun check_is_I89(x: Any) = x is I89
fun check_is_I90(x: Any) = x is I90
fun check_is_I91(x: Any) = x is I91
fun check_is_I92(x: Any) = x is I92
fun check_is_I93(x: Any) = x is I93
fun check_is_I94(x: Any) = x is I94
fun check_is_I95(x: Any) = x is I95
fun check_is_I96(x: Any) = x is I96
fun check_is_I97(x: Any) = x is I97
fun check_is_I98(x: Any) = x is I98
fun check_is_I99(x: Any) = x is I99

interface I_M1 {
    fun bar(x: Int): Int
}

class Bar2 : I_M1 {
    override fun bar(x: Int) = 497 * x + 42
}

class I42_Impl1 : I42 {
    override fun foo42(x: Int) = x * 2 + 42
}

class I42_Impl2 : I42 {
    override fun foo42(x: Int) = x * 3 + 42
}

class I42_Impl3 : I42 {
    override fun foo42(x: Int) = x * 4 + 42
}

class I42_Impl4 : I42 {
    override fun foo42(x: Int) = x * 5 + 42
}

class I42_Impl5 : I42 {
    override fun foo42(x: Int) = x * 6 + 42
}

class I42_Impl6 : I42 {
    override fun foo42(x: Int) = x * 7 + 42
}

class I42_Impl7 : I42 {
    override fun foo42(x: Int) = x * 8 + 42
}

class I42_Impl8 : I42 {
    override fun foo42(x: Int) = x * 9 + 42
}

fun foo(i42: I42, x: Int) = i42.foo42(x)

fun bar(i_m1: I_M1, x: Int) = i_m1.bar(x)

@Test fun runTest() {
    val y = Bar2()
    println(bar(y, 1))
    val x0 = Bar()
    var t = 0
    if (check_is_I0(x0)) t = t + 1
    if (check_is_I1(x0)) t = t + 2
    if (check_is_I2(x0)) t = t + 3
    if (check_is_I3(x0)) t = t + 4
    if (check_is_I4(x0)) t = t + 5
    if (check_is_I5(x0)) t = t + 6
    if (check_is_I6(x0)) t = t + 7
    if (check_is_I7(x0)) t = t + 8
    if (check_is_I8(x0)) t = t + 9
    if (check_is_I9(x0)) t = t + 10
    if (check_is_I10(x0)) t = t + 11
    if (check_is_I11(x0)) t = t + 12
    if (check_is_I12(x0)) t = t + 13
    if (check_is_I13(x0)) t = t + 14
    if (check_is_I14(x0)) t = t + 15
    if (check_is_I15(x0)) t = t + 16
    if (check_is_I16(x0)) t = t + 17
    if (check_is_I17(x0)) t = t + 18
    if (check_is_I18(x0)) t = t + 19
    if (check_is_I19(x0)) t = t + 20
    if (check_is_I20(x0)) t = t + 21
    if (check_is_I21(x0)) t = t + 22
    if (check_is_I22(x0)) t = t + 23
    if (check_is_I23(x0)) t = t + 24
    if (check_is_I24(x0)) t = t + 25
    if (check_is_I25(x0)) t = t + 26
    if (check_is_I26(x0)) t = t + 27
    if (check_is_I27(x0)) t = t + 28
    if (check_is_I28(x0)) t = t + 29
    if (check_is_I29(x0)) t = t + 30
    if (check_is_I30(x0)) t = t + 31
    if (check_is_I31(x0)) t = t + 32
    if (check_is_I32(x0)) t = t + 33
    if (check_is_I33(x0)) t = t + 34
    if (check_is_I34(x0)) t = t + 35
    if (check_is_I35(x0)) t = t + 36
    if (check_is_I36(x0)) t = t + 37
    if (check_is_I37(x0)) t = t + 38
    if (check_is_I38(x0)) t = t + 39
    if (check_is_I39(x0)) t = t + 40
    if (check_is_I40(x0)) t = t + 41
    if (check_is_I41(x0)) t = t + 42
    if (check_is_I42(x0)) t = t + 43
    if (check_is_I43(x0)) t = t + 44
    if (check_is_I44(x0)) t = t + 45
    if (check_is_I45(x0)) t = t + 46
    if (check_is_I46(x0)) t = t + 47
    if (check_is_I47(x0)) t = t + 48
    if (check_is_I48(x0)) t = t + 49
    if (check_is_I49(x0)) t = t + 50
    if (check_is_I50(x0)) t = t + 51
    if (check_is_I51(x0)) t = t + 52
    if (check_is_I52(x0)) t = t + 53
    if (check_is_I53(x0)) t = t + 54
    if (check_is_I54(x0)) t = t + 55
    if (check_is_I55(x0)) t = t + 56
    if (check_is_I56(x0)) t = t + 57
    if (check_is_I57(x0)) t = t + 58
    if (check_is_I58(x0)) t = t + 59
    if (check_is_I59(x0)) t = t + 60
    if (check_is_I60(x0)) t = t + 61
    if (check_is_I61(x0)) t = t + 62
    if (check_is_I62(x0)) t = t + 63
    if (check_is_I63(x0)) t = t + 64
    if (check_is_I64(x0)) t = t + 65
    if (check_is_I65(x0)) t = t + 66
    if (check_is_I66(x0)) t = t + 67
    if (check_is_I67(x0)) t = t + 68
    if (check_is_I68(x0)) t = t + 69
    if (check_is_I69(x0)) t = t + 70
    if (check_is_I70(x0)) t = t + 71
    if (check_is_I71(x0)) t = t + 72
    if (check_is_I72(x0)) t = t + 73
    if (check_is_I73(x0)) t = t + 74
    if (check_is_I74(x0)) t = t + 75
    if (check_is_I75(x0)) t = t + 76
    if (check_is_I76(x0)) t = t + 77
    if (check_is_I77(x0)) t = t + 78
    if (check_is_I78(x0)) t = t + 79
    if (check_is_I79(x0)) t = t + 80
    if (check_is_I80(x0)) t = t + 81
    if (check_is_I81(x0)) t = t + 82
    if (check_is_I82(x0)) t = t + 83
    if (check_is_I83(x0)) t = t + 84
    if (check_is_I84(x0)) t = t + 85
    if (check_is_I85(x0)) t = t + 86
    if (check_is_I86(x0)) t = t + 87
    if (check_is_I87(x0)) t = t + 88
    if (check_is_I88(x0)) t = t + 89
    if (check_is_I89(x0)) t = t + 90
    if (check_is_I90(x0)) t = t + 91
    if (check_is_I91(x0)) t = t + 92
    if (check_is_I92(x0)) t = t + 93
    if (check_is_I93(x0)) t = t + 94
    if (check_is_I94(x0)) t = t + 95
    if (check_is_I95(x0)) t = t + 96
    if (check_is_I96(x0)) t = t + 97
    if (check_is_I97(x0)) t = t + 98
    if (check_is_I98(x0)) t = t + 99
    if (check_is_I99(x0)) t = t + 100
    println(t)
    val x1 = I42_Impl1()
    val x2 = I42_Impl2()
    val x3 = I42_Impl3()
    val x4 = I42_Impl4()
    val x5 = I42_Impl5()
    val x6 = I42_Impl6()
    val x7 = I42_Impl7()
    val x8 = I42_Impl8()
    t = foo(x0, 1)
    t = foo(x1, t)
    t = foo(x2, t)
    t = foo(x3, t)
    t = foo(x4, t)
    t = foo(x5, t)
    t = foo(x6, t)
    t = foo(x7, t)
    t = foo(x8, t)
    println(t)
}
