// WITH_STDLIB // WORKS_WHEN_VALUE_CLASS // LANGUAGE: +ValueClasses, +GenericInlineClassParameter OPTIONAL_JVM_INLINE_ANNOTATION value class InlinedComparable(val x: T) : Comparable> { override fun compareTo(other: InlinedComparable): Int { return x.compareTo(other.x) } } fun generic(c: Comparable, element: T) = c.compareTo(element) interface Base { fun Base.foo(a: Base, b: T): Base } OPTIONAL_JVM_INLINE_ANNOTATION value class InlinedBase(val x: T) : Base> { override fun Base>.foo(a: Base>, b: InlinedBase): Base> { return if (a is InlinedBase<*>) InlinedBase((a.x + b.x) as T) else this } fun double(): InlinedBase { return this.foo(this, this) as InlinedBase } } fun box(): String { val a = InlinedComparable(42) if (generic(a, a) != 0) return "Fail 1" val b = InlinedBase(3) if (b.double().x != 6) return "Fail 2" return "OK" }