// WITH_STDLIB // WORKS_WHEN_VALUE_CLASS // LANGUAGE: +ValueClasses fun underlying(a: IC): T1 = bar(a) { it.value as T1 } fun extension(a: IC): T2 = bar(a) { it.extensionValue() } fun dispatch(a: IC): T3 = bar(a) { it.dispatchValue() } fun normal(a: IC): T4 = bar(a) { normalValue(it) } fun interface FunIFace { fun call(ic: T0): R } fun bar(value: T5, f: FunIFace): R { return f.call(value) } fun IC.extensionValue(): T6 = value as T6 fun normalValue(ic: IC): T7 = ic.value as T7 OPTIONAL_JVM_INLINE_ANNOTATION value class IC(val value: Int) { fun dispatchValue(): T8 = value as T8 } fun box(): String { var res = underlying(IC(40)) + 2 if (res != 42) "FAIL 1: $res" res = extension(IC(40)) + 3 if (res != 43) "FAIL 2: $res" res = dispatch(IC(40)) + 4 if (res != 44) "FAIL 3: $res" res = normal(IC(40)) + 5 if (res != 45) return "FAIL 4: $res" return "OK" }