Forbid private functions with no body and private properties in traits which are abstract by default
This commit is contained in:
@@ -10,4 +10,7 @@ compiler/testData/cli/jvm/multipleTextRangesInDiagnosticsOrder.kt:6:14: error: m
|
||||
compiler/testData/cli/jvm/multipleTextRangesInDiagnosticsOrder.kt:6:24: error: modifier 'private' is incompatible with 'override'
|
||||
override protected private val c: Int
|
||||
^
|
||||
compiler/testData/cli/jvm/multipleTextRangesInDiagnosticsOrder.kt:6:24: error: abstract property in an interface cannot be private
|
||||
override protected private val c: Int
|
||||
^
|
||||
COMPILATION_ERROR
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
interface My {
|
||||
<!PRIVATE_PROPERTY_IN_TRAIT!>private<!> val x: Int
|
||||
<!INCOMPATIBLE_MODIFIERS!>private<!> <!ABSTRACT_MODIFIER_IN_TRAIT, INCOMPATIBLE_MODIFIERS!>abstract<!> val xx: Int
|
||||
private val xxx: Int
|
||||
get() = 0
|
||||
<!FINAL_PROPERTY_IN_TRAIT, DEPRECATED_MODIFIER_CONTAINING_DECLARATION!>final<!> val y: Int
|
||||
<!DEPRECATED_MODIFIER_CONTAINING_DECLARATION!>final<!> val yy: Int
|
||||
get() = 1
|
||||
<!PRIVATE_FUNCTION_WITH_NO_BODY!>private<!> fun foo(): Int
|
||||
// ok
|
||||
private fun bar() = 42
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package
|
||||
|
||||
public interface My {
|
||||
private abstract val x: kotlin.Int
|
||||
private abstract val xx: kotlin.Int
|
||||
private final val xxx: kotlin.Int
|
||||
public final val y: kotlin.Int
|
||||
public final val yy: kotlin.Int
|
||||
private final fun bar(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
private abstract fun foo(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
@@ -2,7 +2,7 @@ interface Test<in I, out O> {
|
||||
val internal_val: <!TYPE_VARIANCE_CONFLICT!>I<!>
|
||||
public val public_val: <!TYPE_VARIANCE_CONFLICT!>I<!>
|
||||
<!DEPRECATED_MODIFIER_CONTAINING_DECLARATION!>protected<!> val protected_val: <!TYPE_VARIANCE_CONFLICT!>I<!>
|
||||
private val private_val: I
|
||||
<!PRIVATE_PROPERTY_IN_TRAIT!>private<!> val private_val: I
|
||||
|
||||
var interlan_private_set: <!TYPE_VARIANCE_CONFLICT!>O<!>
|
||||
private set
|
||||
@@ -10,11 +10,11 @@ interface Test<in I, out O> {
|
||||
private set
|
||||
<!DEPRECATED_MODIFIER_CONTAINING_DECLARATION!>protected<!> var protected_private_set: <!TYPE_VARIANCE_CONFLICT!>O<!>
|
||||
private set
|
||||
private var private_private_set: O
|
||||
<!PRIVATE_PROPERTY_IN_TRAIT!>private<!> var private_private_set: O
|
||||
private set
|
||||
|
||||
fun internal_fun(i: <!TYPE_VARIANCE_CONFLICT!>O<!>) : <!TYPE_VARIANCE_CONFLICT!>I<!>
|
||||
public fun public_fun(i: <!TYPE_VARIANCE_CONFLICT!>O<!>) : <!TYPE_VARIANCE_CONFLICT!>I<!>
|
||||
<!DEPRECATED_MODIFIER_CONTAINING_DECLARATION!>protected<!> fun protected_fun(i: <!TYPE_VARIANCE_CONFLICT!>O<!>) : <!TYPE_VARIANCE_CONFLICT!>I<!>
|
||||
private fun private_fun(i: O) : I
|
||||
<!PRIVATE_FUNCTION_WITH_NO_BODY!>private<!> fun private_fun(i: O) : I
|
||||
}
|
||||
Vendored
+2
-2
@@ -2,11 +2,11 @@ package test
|
||||
|
||||
public interface Super1 {
|
||||
public fun foo(): CharSequence
|
||||
private fun bar(): String
|
||||
private fun bar(): String = ""
|
||||
}
|
||||
|
||||
public interface Super2 {
|
||||
private fun foo(): String
|
||||
private fun foo(): String = ""
|
||||
public fun bar(): CharSequence
|
||||
}
|
||||
|
||||
|
||||
Vendored
+2
-2
@@ -6,11 +6,11 @@ public interface Sub : test.Super1, test.Super2 {
|
||||
}
|
||||
|
||||
public interface Super1 {
|
||||
private abstract fun bar(): kotlin.String
|
||||
private final fun bar(): kotlin.String
|
||||
public abstract fun foo(): kotlin.CharSequence
|
||||
}
|
||||
|
||||
public interface Super2 {
|
||||
public abstract fun bar(): kotlin.CharSequence
|
||||
private abstract fun foo(): kotlin.String
|
||||
private final fun foo(): kotlin.String
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user