Implement additional declaration checks for inline classes
- Implementation by delegation is prohibited - Delegated properties are prohibited
This commit is contained in:
+28
@@ -0,0 +1,28 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
|
||||
class Val {
|
||||
operator fun getValue(thisRef: Any?, kProp: Any?) = 1
|
||||
}
|
||||
|
||||
class Var {
|
||||
operator fun getValue(thisRef: Any?, kProp: Any?) = 2
|
||||
operator fun setValue(thisRef: Any?, kProp: Any?, value: Int) {}
|
||||
}
|
||||
|
||||
|
||||
object ValObject {
|
||||
operator fun getValue(thisRef: Any?, kProp: Any?) = 1
|
||||
}
|
||||
|
||||
object VarObject {
|
||||
operator fun getValue(thisRef: Any?, kProp: Any?) = 2
|
||||
operator fun setValue(thisRef: Any?, kProp: Any?, value: Int) {}
|
||||
}
|
||||
|
||||
inline class Z(val data: Int) {
|
||||
val testVal <!DELEGATED_PROPERTY_INSIDE_INLINE_CLASS!>by Val()<!>
|
||||
var testVar <!DELEGATED_PROPERTY_INSIDE_INLINE_CLASS!>by Var()<!>
|
||||
|
||||
val testValBySingleton <!DELEGATED_PROPERTY_INSIDE_INLINE_CLASS!>by ValObject<!>
|
||||
var testVarBySingleton <!DELEGATED_PROPERTY_INSIDE_INLINE_CLASS!>by VarObject<!>
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
package
|
||||
|
||||
public final class Val {
|
||||
public constructor Val()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final operator fun getValue(/*0*/ thisRef: kotlin.Any?, /*1*/ kProp: kotlin.Any?): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public object ValObject {
|
||||
private constructor ValObject()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final operator fun getValue(/*0*/ thisRef: kotlin.Any?, /*1*/ kProp: kotlin.Any?): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class Var {
|
||||
public constructor Var()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final operator fun getValue(/*0*/ thisRef: kotlin.Any?, /*1*/ kProp: kotlin.Any?): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final operator fun setValue(/*0*/ thisRef: kotlin.Any?, /*1*/ kProp: kotlin.Any?, /*2*/ value: kotlin.Int): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public object VarObject {
|
||||
private constructor VarObject()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final operator fun getValue(/*0*/ thisRef: kotlin.Any?, /*1*/ kProp: kotlin.Any?): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final operator fun setValue(/*0*/ thisRef: kotlin.Any?, /*1*/ kProp: kotlin.Any?, /*2*/ value: kotlin.Int): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final inline class Z {
|
||||
public constructor Z(/*0*/ data: kotlin.Int)
|
||||
public final val data: kotlin.Int
|
||||
public final val testVal: kotlin.Int
|
||||
public final val testValBySingleton: kotlin.Int
|
||||
public final var testVar: kotlin.Int
|
||||
public final var testVarBySingleton: kotlin.Int
|
||||
public open override /*1*/ /*synthesized*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*synthesized*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*synthesized*/ fun toString(): kotlin.String
|
||||
}
|
||||
compiler/testData/diagnostics/tests/inlineClasses/inlineClassCannotImplementInterfaceByDelegation.kt
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
|
||||
interface IFoo
|
||||
|
||||
object FooImpl : IFoo
|
||||
|
||||
inline class Test1(val x: Any) : <!INLINE_CLASS_CANNOT_IMPLEMENT_INTERFACE_BY_DELEGATION!>IFoo by FooImpl<!>
|
||||
|
||||
inline class Test2(val x: IFoo) : <!INLINE_CLASS_CANNOT_IMPLEMENT_INTERFACE_BY_DELEGATION!>IFoo by x<!>
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package
|
||||
|
||||
public object FooImpl : IFoo {
|
||||
private constructor FooImpl()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface IFoo {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final inline class Test1 : IFoo {
|
||||
public constructor Test1(/*0*/ x: kotlin.Any)
|
||||
public final val x: kotlin.Any
|
||||
public open override /*1*/ /*synthesized*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*synthesized*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*synthesized*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final inline class Test2 : IFoo {
|
||||
public constructor Test2(/*0*/ x: IFoo)
|
||||
public final val x: IFoo
|
||||
public open override /*1*/ /*synthesized*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*synthesized*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*synthesized*/ fun toString(): kotlin.String
|
||||
}
|
||||
Vendored
+6
@@ -3,6 +3,12 @@
|
||||
inline class Foo<T>(val x: <!INLINE_CLASS_HAS_INAPPLICABLE_PARAMETER_TYPE!>T<!>)
|
||||
inline class FooNullable<T>(val x: <!INLINE_CLASS_HAS_INAPPLICABLE_PARAMETER_TYPE!>T?<!>)
|
||||
|
||||
inline class FooGenericArray<T>(val x: <!INLINE_CLASS_HAS_INAPPLICABLE_PARAMETER_TYPE!>Array<T><!>)
|
||||
inline class FooGenericArray2<T>(val x: <!INLINE_CLASS_HAS_INAPPLICABLE_PARAMETER_TYPE!>Array<Array<T>><!>)
|
||||
|
||||
inline class FooStarProjectedArray(val x: Array<*>)
|
||||
inline class FooStarProjectedArray2(val x: Array<Array<*>>)
|
||||
|
||||
inline class Bar(val u: <!INLINE_CLASS_HAS_INAPPLICABLE_PARAMETER_TYPE!>Unit<!>)
|
||||
inline class BarNullable(val u: Unit?)
|
||||
|
||||
|
||||
Vendored
+32
@@ -40,6 +40,22 @@ public final inline class Foo</*0*/ T> {
|
||||
public open override /*1*/ /*synthesized*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final inline class FooGenericArray</*0*/ T> {
|
||||
public constructor FooGenericArray</*0*/ T>(/*0*/ x: kotlin.Array<T>)
|
||||
public final val x: kotlin.Array<T>
|
||||
public open override /*1*/ /*synthesized*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*synthesized*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*synthesized*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final inline class FooGenericArray2</*0*/ T> {
|
||||
public constructor FooGenericArray2</*0*/ T>(/*0*/ x: kotlin.Array<kotlin.Array<T>>)
|
||||
public final val x: kotlin.Array<kotlin.Array<T>>
|
||||
public open override /*1*/ /*synthesized*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*synthesized*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*synthesized*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final inline class FooNullable</*0*/ T> {
|
||||
public constructor FooNullable</*0*/ T>(/*0*/ x: T?)
|
||||
public final val x: T?
|
||||
@@ -47,3 +63,19 @@ public final inline class FooNullable</*0*/ T> {
|
||||
public open override /*1*/ /*synthesized*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*synthesized*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final inline class FooStarProjectedArray {
|
||||
public constructor FooStarProjectedArray(/*0*/ x: kotlin.Array<*>)
|
||||
public final val x: kotlin.Array<*>
|
||||
public open override /*1*/ /*synthesized*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*synthesized*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*synthesized*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final inline class FooStarProjectedArray2 {
|
||||
public constructor FooStarProjectedArray2(/*0*/ x: kotlin.Array<kotlin.Array<*>>)
|
||||
public final val x: kotlin.Array<kotlin.Array<*>>
|
||||
public open override /*1*/ /*synthesized*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*synthesized*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*synthesized*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user