protected & internal are now forbidden in interfaces

This commit is contained in:
Mikhail Glukhikh
2015-10-05 12:05:48 +03:00
committed by Mikhail Glukhikh
parent 5f43628f1b
commit cba6870f52
40 changed files with 44 additions and 462 deletions
@@ -4,7 +4,7 @@ compiler/testData/cli/jvm/multipleTextRangesInDiagnosticsOrder.kt:6:5: error: mo
compiler/testData/cli/jvm/multipleTextRangesInDiagnosticsOrder.kt:6:14: error: cannot weaken access privilege 'public' for 'c' in 'A'
override protected private val c: Int
^
compiler/testData/cli/jvm/multipleTextRangesInDiagnosticsOrder.kt:6:14: error: modifier 'protected' is incompatible with 'private'
compiler/testData/cli/jvm/multipleTextRangesInDiagnosticsOrder.kt:6:14: error: modifier 'protected' is not applicable inside 'interface'
override protected private val c: Int
^
compiler/testData/cli/jvm/multipleTextRangesInDiagnosticsOrder.kt:6:24: error: modifier 'private' is incompatible with 'override'
+4 -3
View File
@@ -6,11 +6,12 @@ interface A {
}
interface B {
protected val c: String
private val c: String
get() = "FAIL"
}
open class C {
private val c: String = "FAIL"
abstract class C {
abstract protected val c: String
}
open class D: C(), A, B {
@@ -1,30 +0,0 @@
interface A {
protected fun foo()
protected fun fooImpl() { }
protected var bar: Int
public var baz: String
public get() = ""
protected set(value) {}
fun test(): String {
foo()
fooImpl()
bar = bar + 1
baz = baz + "1"
return "OK"
}
}
class B : A {
protected override fun foo() {}
protected override var bar: Int = 42
override var baz: String = ""
protected set
}
fun box() = B().test()
@@ -1,11 +0,0 @@
interface Foo {
protected class Bar {
fun box() = "OK"
}
}
class Baz : Foo {
fun box() = Foo.Bar().box()
}
fun box() = Baz().box()
@@ -1,15 +0,0 @@
interface A {
protected fun foo(): String
fun box() = foo()
}
interface B : A
interface C : A {
protected override fun foo() = "OK"
}
class D : B, C
fun box() = D().box()
@@ -0,0 +1,7 @@
interface My {
<!WRONG_MODIFIER_CONTAINING_DECLARATION!>internal<!> val x: Int
<!WRONG_MODIFIER_CONTAINING_DECLARATION!>internal<!> val xxx: Int
get() = 0
<!WRONG_MODIFIER_CONTAINING_DECLARATION!>internal<!> fun foo(): Int
<!WRONG_MODIFIER_CONTAINING_DECLARATION!>internal<!> fun bar() = 42
}
@@ -0,0 +1,11 @@
package
public interface My {
internal abstract val x: kotlin.Int
internal open val xxx: kotlin.Int
internal open fun bar(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
internal 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
}
+1 -1
View File
@@ -17,5 +17,5 @@ enum class Our(protected val x: Int) {
}
interface Their {
<!DEPRECATED_MODIFIER_CONTAINING_DECLARATION!>protected<!> fun foo() = 7
<!WRONG_MODIFIER_CONTAINING_DECLARATION!>protected<!> fun foo() = 7
}
@@ -1,13 +0,0 @@
interface T {
<!DEPRECATED_MODIFIER_CONTAINING_DECLARATION!>internal<!> var foo: Long
}
interface U {
<!DEPRECATED_MODIFIER_CONTAINING_DECLARATION!>protected<!> var foo: Long
}
interface V : T, U {
<!CANNOT_INFER_VISIBILITY!>override var foo: Long<!>
}
interface <!CANNOT_INFER_VISIBILITY!>W<!> : T, U
@@ -1,29 +0,0 @@
package
public interface T {
internal abstract var foo: kotlin.Long
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 U {
protected abstract var foo: kotlin.Long
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 V : T, U {
public abstract override /*2*/ var foo: kotlin.Long
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
}
public interface W : T, U {
public abstract override /*2*/ /*fake_override*/ var foo: kotlin.Long
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -1,13 +0,0 @@
interface T {
public var foo: Short
<!DEPRECATED_MODIFIER_CONTAINING_DECLARATION!>internal<!> set
}
interface U {
public var foo: Short
<!DEPRECATED_MODIFIER_CONTAINING_DECLARATION!>protected<!> set
}
interface V : T, U {
<!CANNOT_INFER_VISIBILITY!>override var foo: Short<!>
}
@@ -1,22 +0,0 @@
package
public interface T {
public abstract var foo: kotlin.Short
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 U {
public abstract var foo: kotlin.Short
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 V : T, U {
public abstract override /*2*/ var foo: kotlin.Short
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
}
+2 -2
View File
@@ -6,7 +6,7 @@ open class C {
}
interface T {
<!DEPRECATED_MODIFIER_CONTAINING_DECLARATION!>protected<!> fun foo() {}
<!WRONG_MODIFIER_CONTAINING_DECLARATION!>protected<!> fun foo() {}
}
class G : C(), T {
@@ -18,7 +18,7 @@ open class A {
}
interface B {
<!DEPRECATED_MODIFIER_CONTAINING_DECLARATION!>protected<!> fun foo() {}
<!WRONG_MODIFIER_CONTAINING_DECLARATION!>protected<!> fun foo() {}
}
interface D {
+3 -3
View File
@@ -1,20 +1,20 @@
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<!>
<!WRONG_MODIFIER_CONTAINING_DECLARATION!>protected<!> val protected_val: <!TYPE_VARIANCE_CONFLICT!>I<!>
<!PRIVATE_PROPERTY_IN_INTERFACE!>private<!> val private_val: I
var interlan_private_set: <!TYPE_VARIANCE_CONFLICT!>O<!>
private set
public var public_private_set: <!TYPE_VARIANCE_CONFLICT!>O<!>
private set
<!DEPRECATED_MODIFIER_CONTAINING_DECLARATION!>protected<!> var protected_private_set: <!TYPE_VARIANCE_CONFLICT!>O<!>
<!WRONG_MODIFIER_CONTAINING_DECLARATION!>protected<!> var protected_private_set: <!TYPE_VARIANCE_CONFLICT!>O<!>
private set
<!PRIVATE_PROPERTY_IN_INTERFACE!>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<!>
<!WRONG_MODIFIER_CONTAINING_DECLARATION!>protected<!> fun protected_fun(i: <!TYPE_VARIANCE_CONFLICT!>O<!>) : <!TYPE_VARIANCE_CONFLICT!>I<!>
<!PRIVATE_FUNCTION_WITH_NO_BODY!>private<!> fun private_fun(i: O) : I
}
@@ -1,14 +0,0 @@
//ALLOW_AST_ACCESS
package test
interface A {
internal fun f() : Int
internal val v : Int
public var p : Int
}
class B : A {
override fun f(): Int = throw UnsupportedOperationException()
public override var p: Int = 0
override val v: Int = 0
}
@@ -1,20 +0,0 @@
package test
public interface A {
public abstract var p: kotlin.Int
public abstract fun <get-p>(): kotlin.Int
public abstract fun <set-p>(/*0*/ <set-?>: kotlin.Int): kotlin.Unit
internal abstract val v: kotlin.Int
internal abstract fun <get-v>(): kotlin.Int
internal abstract fun f(): kotlin.Int
}
public final class B : test.A {
/*primary*/ public constructor B()
public open override /*1*/ var p: kotlin.Int
public open override /*1*/ fun <get-p>(): kotlin.Int
public open override /*1*/ fun <set-p>(/*0*/ <set-?>: kotlin.Int): kotlin.Unit
internal open override /*1*/ val v: kotlin.Int = 0
internal open override /*1*/ fun <get-v>(): kotlin.Int
internal open override /*1*/ fun f(): kotlin.Int
}
@@ -1,8 +0,0 @@
package test
interface A {
internal fun f() : Int
internal val v : Int
public var p : Int
internal set
}
@@ -1,10 +0,0 @@
package test
public interface A {
public abstract var p: kotlin.Int
public abstract fun <get-p>(): kotlin.Int
internal abstract fun <set-p>(/*0*/ <set-?>: kotlin.Int): kotlin.Unit
internal abstract val v: kotlin.Int
internal abstract fun <get-v>(): kotlin.Int
internal abstract fun f(): kotlin.Int
}
@@ -1,14 +0,0 @@
package test
interface A {
internal open fun f() : Int = 0
internal open val v : Int
get() = 0
public var p : Int
get() = 5
internal set(value) {
}
}
class B : A {
}
@@ -1,20 +0,0 @@
package test
public interface A {
public open var p: kotlin.Int
public open fun <get-p>(): kotlin.Int
internal open fun <set-p>(/*0*/ value: kotlin.Int): kotlin.Unit
internal open val v: kotlin.Int
internal open fun <get-v>(): kotlin.Int
internal open fun f(): kotlin.Int
}
public final class B : test.A {
/*primary*/ public constructor B()
public open override /*1*/ /*fake_override*/ var p: kotlin.Int
public open override /*1*/ /*fake_override*/ fun <get-p>(): kotlin.Int
internal open override /*1*/ /*fake_override*/ fun <set-p>(/*0*/ value: kotlin.Int): kotlin.Unit
internal open override /*1*/ /*fake_override*/ val v: kotlin.Int
internal open override /*1*/ /*fake_override*/ fun <get-v>(): kotlin.Int
internal open override /*1*/ /*fake_override*/ fun f(): kotlin.Int
}