// WITH_STDLIB // WORKS_WHEN_VALUE_CLASS // IGNORE_BACKEND: JVM // LANGUAGE: +ValueClasses, +GenericInlineClassParameter fun underlying(a: IC): T = bar(a) { it.value } fun extension(a: IC): T = bar(a) { it.extensionValue() } fun dispatch(a: IC): T = bar(a) { it.dispatchValue() } fun normal(a: IC): T = bar(a) { normalValue(it) } fun IC.extensionValue(): T = value fun normalValue(ic: IC): T = ic.value fun bar(value: T, f: (T) -> R): R { return f(value) } OPTIONAL_JVM_INLINE_ANNOTATION value class IC(val value: T) { fun dispatchValue(): T = value } fun box(): String { var res = underlying(IC(40)) + 2 if (res != 42) return "FAIL 1: $res" res = extension(IC(40)) + 3 if (res != 43) return "FAIL 2: $res" res = dispatch(IC(40)) + 4 if (res != 44) return "FAIL 3: $res" res = normal(IC(40)) + 5 if (res != 45) return "FAIL 4: $res" return "OK" }