diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java index a5216e3dd40..3298ab9330b 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java @@ -115,6 +115,7 @@ public interface Errors { DiagnosticFactory2 WRONG_MODIFIER_TARGET = DiagnosticFactory2.create(ERROR); DiagnosticFactory2 REDUNDANT_MODIFIER_FOR_TARGET = DiagnosticFactory2.create(WARNING); DiagnosticFactory2 WRONG_MODIFIER_CONTAINING_DECLARATION = DiagnosticFactory2.create(ERROR); + DiagnosticFactory2 DEPRECATED_MODIFIER_CONTAINING_DECLARATION = DiagnosticFactory2.create(WARNING); DiagnosticFactory1 WRONG_ANNOTATION_TARGET = DiagnosticFactory1.create(ERROR); DiagnosticFactory2 WRONG_ANNOTATION_TARGET_WITH_USE_SITE_TARGET = DiagnosticFactory2.create(ERROR); DiagnosticFactory0 REPEATED_ANNOTATION = DiagnosticFactory0.create(ERROR); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java index e45c7df0b10..7c4fa0ea430 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java @@ -122,6 +122,7 @@ public class DefaultErrorMessages { MAP.put(WRONG_MODIFIER_TARGET, "Modifier ''{0}'' is not applicable to ''{1}''", TO_STRING, TO_STRING); MAP.put(REDUNDANT_MODIFIER_FOR_TARGET, "Modifier ''{0}'' is redundant for ''{1}''", TO_STRING, TO_STRING); MAP.put(WRONG_MODIFIER_CONTAINING_DECLARATION, "Modifier ''{0}'' is not applicable inside ''{1}''", TO_STRING, TO_STRING); + MAP.put(DEPRECATED_MODIFIER_CONTAINING_DECLARATION, "Modifier ''{0}'' is deprecated inside ''{1}''", TO_STRING, TO_STRING); MAP.put(WRONG_ANNOTATION_TARGET, "This annotation is not applicable to target ''{0}''", TO_STRING); MAP.put(WRONG_ANNOTATION_TARGET_WITH_USE_SITE_TARGET, "This annotation is not applicable to target ''{0}'' and use site target ''@{1}''", TO_STRING, TO_STRING); MAP.put(REPEATED_ANNOTATION, "This annotation is not repeatable"); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/ModifiersChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/ModifiersChecker.kt index 8dd4efd734e..b07e84709bf 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/ModifiersChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/ModifiersChecker.kt @@ -82,6 +82,12 @@ public object ModifierCheckerCore { COMPANION_KEYWORD to EnumSet.of(CLASS_ONLY, ENUM_CLASS, INTERFACE) ) + private val deprecatedParentTargetMap = mapOf>( + PRIVATE_KEYWORD to EnumSet.of(INTERFACE), + INTERNAL_KEYWORD to EnumSet.of(INTERFACE), + PROTECTED_KEYWORD to EnumSet.of(INTERFACE) + ) + // First modifier in pair should be also first in declaration private val mutualCompatibility = buildCompatibilityMap() @@ -184,6 +190,11 @@ public object ModifierCheckerCore { is FunctionDescriptor -> listOf(FUNCTION) else -> listOf(FILE) } + val deprecatedParents = deprecatedParentTargetMap[modifier] + if (deprecatedParents != null && actualParents.any { it in deprecatedParents }) { + trace.report(Errors.DEPRECATED_MODIFIER_CONTAINING_DECLARATION.on(node.psi, modifier, actualParents.firstOrNull()?.description ?: "this scope")) + return false + } val possibleParents = possibleParentTargetMap[modifier] ?: return true if (possibleParents == KotlinTarget.ALL_TARGET_SET) return true if (actualParents.any { it in possibleParents }) return true diff --git a/compiler/testData/cli/jvm/multipleTextRangesInDiagnosticsOrder.out b/compiler/testData/cli/jvm/multipleTextRangesInDiagnosticsOrder.out index 14a61d6dd91..f705e858565 100644 --- a/compiler/testData/cli/jvm/multipleTextRangesInDiagnosticsOrder.out +++ b/compiler/testData/cli/jvm/multipleTextRangesInDiagnosticsOrder.out @@ -1,9 +1,6 @@ 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' - override protected private val c: Int - ^ compiler/testData/cli/jvm/multipleTextRangesInDiagnosticsOrder.kt:6:24: error: modifier 'private' is incompatible with 'protected' override protected private val c: Int ^ diff --git a/compiler/testData/diagnostics/tests/AbstractInTrait.kt b/compiler/testData/diagnostics/tests/AbstractInTrait.kt index 209dd1d71ff..e58da290703 100644 --- a/compiler/testData/diagnostics/tests/AbstractInTrait.kt +++ b/compiler/testData/diagnostics/tests/AbstractInTrait.kt @@ -7,10 +7,10 @@ interface MyTrait { abstract val a2: Int abstract val a3: Int = 1 - var b: Int private set - var b1: Int = 0; private set - abstract var b2: Int private set - abstract var b3: Int = 0; private set + var b: Int + var b1: Int = 0 + abstract var b2: Int + abstract var b3: Int = 0 var c: Int set(v: Int) { field = v } var c1: Int = 0; set(v: Int) { field = v } diff --git a/compiler/testData/diagnostics/tests/TraitWithConstructor.kt b/compiler/testData/diagnostics/tests/TraitWithConstructor.kt index e2f5807c6ed..eb88b6ab35d 100644 --- a/compiler/testData/diagnostics/tests/TraitWithConstructor.kt +++ b/compiler/testData/diagnostics/tests/TraitWithConstructor.kt @@ -6,7 +6,7 @@ interface T1(val x: String) {} interface T2 constructor() {} -interface T3 private constructor(a: Int) {} +interface T3 constructor(a: Int) {} interface T4 { constructor(a: Int) { @@ -14,5 +14,5 @@ interface T4 { } } -interface T5 private () : T4 {} -interface T6 private : T5 {} +interface T5 private () : T4 {} +interface T6 public : T5 {} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/TraitWithConstructor.txt b/compiler/testData/diagnostics/tests/TraitWithConstructor.txt index 5434725ffbc..414821b49ba 100644 --- a/compiler/testData/diagnostics/tests/TraitWithConstructor.txt +++ b/compiler/testData/diagnostics/tests/TraitWithConstructor.txt @@ -24,7 +24,7 @@ public interface T2 { } public interface T3 { - private constructor T3(/*0*/ a: kotlin.Int) + public constructor T3(/*0*/ a: kotlin.Int) 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 @@ -45,7 +45,7 @@ public interface T5 : T4 { } public interface T6 : T5 { - private constructor T6() + public constructor T6() 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 diff --git a/compiler/testData/diagnostics/tests/delegation/Delegation_MultipleDelegates.kt b/compiler/testData/diagnostics/tests/delegation/Delegation_MultipleDelegates.kt index 26501f0de2e..c1576a5e6ab 100644 --- a/compiler/testData/diagnostics/tests/delegation/Delegation_MultipleDelegates.kt +++ b/compiler/testData/diagnostics/tests/delegation/Delegation_MultipleDelegates.kt @@ -1,7 +1,7 @@ // !DIAGNOSTICS: -CONFLICTING_JVM_DECLARATIONS interface One { public open fun foo() : Int - private fun boo() = 10 + private fun boo() = 10 } interface Two { public open fun foo() : Int diff --git a/compiler/testData/diagnostics/tests/inline/nonVirtualMembersWithInline.kt b/compiler/testData/diagnostics/tests/inline/nonVirtualMembersWithInline.kt index c3a09923a59..ff2118ffab2 100644 --- a/compiler/testData/diagnostics/tests/inline/nonVirtualMembersWithInline.kt +++ b/compiler/testData/diagnostics/tests/inline/nonVirtualMembersWithInline.kt @@ -29,20 +29,19 @@ abstract class A { interface B { - inline private fun good1() {} inline public final fun good2() {} - inline protected final fun good3() {} + inline final fun good3() {} inline final fun good4() {} inline fun wrong1() {} - inline open protected fun wrong2() {} + inline open fun wrong2() {} inline open public fun wrong3() {} inline open fun wrong4() {} - inline protected fun wrong5() + inline fun wrong5() inline public fun wrong6() diff --git a/compiler/testData/diagnostics/tests/inline/nonVirtualMembersWithInline.txt b/compiler/testData/diagnostics/tests/inline/nonVirtualMembersWithInline.txt index e94caec87be..7113bc7bdd1 100644 --- a/compiler/testData/diagnostics/tests/inline/nonVirtualMembersWithInline.txt +++ b/compiler/testData/diagnostics/tests/inline/nonVirtualMembersWithInline.txt @@ -23,17 +23,16 @@ public abstract class A { public interface B { public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - @kotlin.inline() private final fun good1(): kotlin.Unit @kotlin.inline() public final fun good2(): kotlin.Unit - @kotlin.inline() protected final fun good3(): kotlin.Unit + @kotlin.inline() public final fun good3(): kotlin.Unit @kotlin.inline() public final fun good4(): kotlin.Unit public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String @kotlin.inline() public open fun wrong1(): kotlin.Unit - @kotlin.inline() protected open fun wrong2(): kotlin.Unit + @kotlin.inline() public open fun wrong2(): kotlin.Unit @kotlin.inline() public open fun wrong3(): kotlin.Unit @kotlin.inline() public open fun wrong4(): kotlin.Unit - @kotlin.inline() protected abstract fun wrong5(): kotlin.Unit + @kotlin.inline() public abstract fun wrong5(): kotlin.Unit @kotlin.inline() public abstract fun wrong6(): kotlin.Unit @kotlin.inline() public abstract fun wrong7(): kotlin.Unit } diff --git a/compiler/testData/diagnostics/tests/override/AllPrivateFromSuperTypes.kt b/compiler/testData/diagnostics/tests/override/AllPrivateFromSuperTypes.kt index e92b440e116..80f2eaa6f2a 100644 --- a/compiler/testData/diagnostics/tests/override/AllPrivateFromSuperTypes.kt +++ b/compiler/testData/diagnostics/tests/override/AllPrivateFromSuperTypes.kt @@ -1,7 +1,7 @@ package test interface A { - private val a: String + private val a: String get() = "AAAA!" } diff --git a/compiler/testData/diagnostics/tests/override/AllProtectedFromSupertypes.kt b/compiler/testData/diagnostics/tests/override/AllProtectedFromSupertypes.kt deleted file mode 100644 index 7660abbd08e..00000000000 --- a/compiler/testData/diagnostics/tests/override/AllProtectedFromSupertypes.kt +++ /dev/null @@ -1,13 +0,0 @@ -package test - -interface A { - protected val a: String -} - -open class C { - protected val a: String = "" -} - -class Subject : C(), A { - val c = a -} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/override/AllProtectedFromSupertypes.txt b/compiler/testData/diagnostics/tests/override/AllProtectedFromSupertypes.txt deleted file mode 100644 index 52405e28e79..00000000000 --- a/compiler/testData/diagnostics/tests/override/AllProtectedFromSupertypes.txt +++ /dev/null @@ -1,28 +0,0 @@ -package - -package test { - - public interface A { - protected abstract val a: kotlin.String - 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 open class C { - public constructor C() - protected final val a: kotlin.String = "" - 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 class Subject : test.C, test.A { - public constructor Subject() - protected final override /*2*/ /*fake_override*/ val a: kotlin.String - public final val c: kotlin.String - 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 - } -} diff --git a/compiler/testData/diagnostics/tests/override/CannotInferVisibilityForProperty.kt b/compiler/testData/diagnostics/tests/override/CannotInferVisibilityForProperty.kt index 864d1ec4901..3cdaf523ff4 100644 --- a/compiler/testData/diagnostics/tests/override/CannotInferVisibilityForProperty.kt +++ b/compiler/testData/diagnostics/tests/override/CannotInferVisibilityForProperty.kt @@ -1,9 +1,9 @@ interface T { - internal var foo: Long + internal var foo: Long } interface U { - protected var foo: Long + protected var foo: Long } interface V : T, U { diff --git a/compiler/testData/diagnostics/tests/override/CannotInferVisibilityForPropertySetter.kt b/compiler/testData/diagnostics/tests/override/CannotInferVisibilityForPropertySetter.kt index 041675041c8..e07cc06807d 100644 --- a/compiler/testData/diagnostics/tests/override/CannotInferVisibilityForPropertySetter.kt +++ b/compiler/testData/diagnostics/tests/override/CannotInferVisibilityForPropertySetter.kt @@ -1,11 +1,11 @@ interface T { public var foo: Short - internal set + internal set } interface U { public var foo: Short - protected set + protected set } interface V : T, U { diff --git a/compiler/testData/diagnostics/tests/override/ProtectedAndPrivateFromSupertypes.kt b/compiler/testData/diagnostics/tests/override/ProtectedAndPrivateFromSupertypes.kt index e1c459df79d..e4bb3f41098 100644 --- a/compiler/testData/diagnostics/tests/override/ProtectedAndPrivateFromSupertypes.kt +++ b/compiler/testData/diagnostics/tests/override/ProtectedAndPrivateFromSupertypes.kt @@ -1,11 +1,11 @@ package test interface A { - protected val a: String + val a: String } interface B { - protected val a: String + val a: String } open class C { diff --git a/compiler/testData/diagnostics/tests/override/ProtectedAndPrivateFromSupertypes.txt b/compiler/testData/diagnostics/tests/override/ProtectedAndPrivateFromSupertypes.txt index 5aa148e967f..0a04691fa67 100644 --- a/compiler/testData/diagnostics/tests/override/ProtectedAndPrivateFromSupertypes.txt +++ b/compiler/testData/diagnostics/tests/override/ProtectedAndPrivateFromSupertypes.txt @@ -3,14 +3,14 @@ package package test { public interface A { - protected abstract val a: kotlin.String + public abstract val a: kotlin.String 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 B { - protected abstract val a: kotlin.String + public abstract val a: kotlin.String 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 @@ -26,7 +26,7 @@ package test { public final class Subject : test.C, test.A, test.B { public constructor Subject() - protected abstract override /*2*/ /*fake_override*/ val a: kotlin.String + public abstract override /*2*/ /*fake_override*/ val a: kotlin.String public final val c: kotlin.String public open override /*3*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*3*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/override/kt4785.kt b/compiler/testData/diagnostics/tests/override/kt4785.kt index a248fd77428..90eebf90d97 100644 --- a/compiler/testData/diagnostics/tests/override/kt4785.kt +++ b/compiler/testData/diagnostics/tests/override/kt4785.kt @@ -1,5 +1,5 @@ interface T { - internal fun foo() + fun foo() } open class C { diff --git a/compiler/testData/diagnostics/tests/override/kt4785.txt b/compiler/testData/diagnostics/tests/override/kt4785.txt index 9122659656c..729d971ef93 100644 --- a/compiler/testData/diagnostics/tests/override/kt4785.txt +++ b/compiler/testData/diagnostics/tests/override/kt4785.txt @@ -20,7 +20,7 @@ public final class E : C, T { public interface T { public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - internal abstract fun foo(): kotlin.Unit + public abstract fun foo(): kotlin.Unit public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } diff --git a/compiler/testData/diagnostics/tests/override/kt4785classObject.kt b/compiler/testData/diagnostics/tests/override/kt4785classObject.kt deleted file mode 100644 index 9f62206d000..00000000000 --- a/compiler/testData/diagnostics/tests/override/kt4785classObject.kt +++ /dev/null @@ -1,13 +0,0 @@ -interface A { - internal fun foo() -} - -interface B { - protected fun foo() {} -} - -class C { - companion object : A, B { - fun bar() = null - } -} diff --git a/compiler/testData/diagnostics/tests/override/kt4785classObject.txt b/compiler/testData/diagnostics/tests/override/kt4785classObject.txt deleted file mode 100644 index 7ca9a825db2..00000000000 --- a/compiler/testData/diagnostics/tests/override/kt4785classObject.txt +++ /dev/null @@ -1,31 +0,0 @@ -package - -public interface A { - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - internal abstract fun foo(): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String -} - -public interface B { - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - protected open fun foo(): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String -} - -public final class C { - public constructor C() - 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 companion object Companion : A, B { - private constructor Companion() - public final fun bar(): kotlin.Nothing? - public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*2*/ /*fake_override*/ fun foo(): kotlin.Unit - public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String - } -} diff --git a/compiler/testData/diagnostics/tests/override/kt4785delegation.kt b/compiler/testData/diagnostics/tests/override/kt4785delegation.kt deleted file mode 100644 index 8a4d927d59e..00000000000 --- a/compiler/testData/diagnostics/tests/override/kt4785delegation.kt +++ /dev/null @@ -1,9 +0,0 @@ -interface A { - internal fun foo() -} - -interface B { - protected fun foo() -} - -class E(a: A) : A by a, B diff --git a/compiler/testData/diagnostics/tests/override/kt4785delegation.txt b/compiler/testData/diagnostics/tests/override/kt4785delegation.txt deleted file mode 100644 index 57f43cfb5b4..00000000000 --- a/compiler/testData/diagnostics/tests/override/kt4785delegation.txt +++ /dev/null @@ -1,23 +0,0 @@ -package - -public interface A { - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - internal abstract fun foo(): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String -} - -public interface B { - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - protected abstract fun foo(): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String -} - -public final class E : A, B { - public constructor E(/*0*/ a: A) - public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*2*/ /*delegation*/ fun foo(): kotlin.Unit - public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String -} diff --git a/compiler/testData/diagnostics/tests/scopes/VisibilityInheritModifier.kt b/compiler/testData/diagnostics/tests/scopes/VisibilityInheritModifier.kt index b7c6fc5a2c3..2f86e1caab2 100644 --- a/compiler/testData/diagnostics/tests/scopes/VisibilityInheritModifier.kt +++ b/compiler/testData/diagnostics/tests/scopes/VisibilityInheritModifier.kt @@ -69,17 +69,17 @@ class M : L() { } //--------------- interface R { - internal protected fun foo() {} + fun foo() {} } interface P : R { - internal override fun foo() {} + override fun foo() {} } interface Q : R { - protected override fun foo() {} + override fun foo() {} } class S : P, Q { - internal override fun foo() {} + internal override fun foo() {} } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/scopes/VisibilityInheritModifier.txt b/compiler/testData/diagnostics/tests/scopes/VisibilityInheritModifier.txt index b27b8a4e89c..ec20320e413 100644 --- a/compiler/testData/diagnostics/tests/scopes/VisibilityInheritModifier.txt +++ b/compiler/testData/diagnostics/tests/scopes/VisibilityInheritModifier.txt @@ -110,21 +110,21 @@ package b { public interface P : b.R { public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - internal open override /*1*/ fun foo(): kotlin.Unit + public open override /*1*/ fun foo(): kotlin.Unit public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } public interface Q : b.R { public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - protected open override /*1*/ fun foo(): kotlin.Unit + public open override /*1*/ fun foo(): kotlin.Unit public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } public interface R { public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - protected open fun foo(): kotlin.Unit + public open fun foo(): kotlin.Unit public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } diff --git a/compiler/testData/diagnostics/tests/scopes/kt151.kt b/compiler/testData/diagnostics/tests/scopes/kt151.kt index 182c835bf31..a5e83453fc1 100644 --- a/compiler/testData/diagnostics/tests/scopes/kt151.kt +++ b/compiler/testData/diagnostics/tests/scopes/kt151.kt @@ -20,7 +20,7 @@ open class C { } interface T { - protected fun foo() {} + fun foo() {} } class D : C(), T { @@ -28,7 +28,7 @@ class D : C(), T { } class E : C(), T { - internal override fun foo() {} + internal override fun foo() {} } class F : C(), T { diff --git a/compiler/testData/diagnostics/tests/scopes/kt151.txt b/compiler/testData/diagnostics/tests/scopes/kt151.txt index 6de236f848a..150ff524a7b 100644 --- a/compiler/testData/diagnostics/tests/scopes/kt151.txt +++ b/compiler/testData/diagnostics/tests/scopes/kt151.txt @@ -61,7 +61,7 @@ package kt151 { public interface T { public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - protected open fun foo(): kotlin.Unit + public open fun foo(): kotlin.Unit public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } diff --git a/compiler/testData/diagnostics/tests/scopes/kt1822.kt b/compiler/testData/diagnostics/tests/scopes/kt1822.kt index 85a07b95ec1..b6857aa1b81 100644 --- a/compiler/testData/diagnostics/tests/scopes/kt1822.kt +++ b/compiler/testData/diagnostics/tests/scopes/kt1822.kt @@ -6,7 +6,7 @@ open class C { } interface T { - protected fun foo() {} + protected fun foo() {} } class G : C(), T { @@ -18,7 +18,7 @@ open class A { } interface B { - protected fun foo() {} + protected fun foo() {} } interface D { diff --git a/compiler/testData/diagnostics/tests/variance/Visibility.kt b/compiler/testData/diagnostics/tests/variance/Visibility.kt index 55d8c56afe0..d63a1282833 100644 --- a/compiler/testData/diagnostics/tests/variance/Visibility.kt +++ b/compiler/testData/diagnostics/tests/variance/Visibility.kt @@ -1,20 +1,20 @@ interface Test { val internal_val: I public val public_val: I - protected val protected_val: I - private val private_val: I + protected val protected_val: I + private val private_val: I var interlan_private_set: O - private set + private set public var public_private_set: O - private set - protected var protected_private_set: O - private set - private var private_private_set: O - private set + private set + protected var protected_private_set: O + private set + private var private_private_set: O + private set fun internal_fun(i: O) : I public fun public_fun(i: O) : I - protected fun protected_fun(i: O) : I - private fun private_fun(i: O) : I + protected fun protected_fun(i: O) : I + private fun private_fun(i: O) : I } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/variance/privateToThis/Trait.kt b/compiler/testData/diagnostics/tests/variance/privateToThis/Abstract.kt similarity index 77% rename from compiler/testData/diagnostics/tests/variance/privateToThis/Trait.kt rename to compiler/testData/diagnostics/tests/variance/privateToThis/Abstract.kt index 3e72d50861e..d46d0e62dc8 100644 --- a/compiler/testData/diagnostics/tests/variance/privateToThis/Trait.kt +++ b/compiler/testData/diagnostics/tests/variance/privateToThis/Abstract.kt @@ -1,4 +1,4 @@ -internal interface Test { +internal abstract class Test { private/*private to this*/ final fun foo(): I { throw Exception() } diff --git a/compiler/testData/diagnostics/tests/variance/privateToThis/Trait.txt b/compiler/testData/diagnostics/tests/variance/privateToThis/Abstract.txt similarity index 81% rename from compiler/testData/diagnostics/tests/variance/privateToThis/Trait.txt rename to compiler/testData/diagnostics/tests/variance/privateToThis/Abstract.txt index e5d296595d1..9d72d8ce285 100644 --- a/compiler/testData/diagnostics/tests/variance/privateToThis/Trait.txt +++ b/compiler/testData/diagnostics/tests/variance/privateToThis/Abstract.txt @@ -1,6 +1,7 @@ package -internal interface Test { +internal abstract class Test { + public constructor Test() private/*private to this*/ final val i: I public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean private/*private to this*/ final fun foo(): I diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java index 6a6373e9ed0..8e95511002f 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java @@ -10107,12 +10107,6 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { doTest(fileName); } - @TestMetadata("AllProtectedFromSupertypes.kt") - public void testAllProtectedFromSupertypes() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/override/AllProtectedFromSupertypes.kt"); - doTest(fileName); - } - @TestMetadata("CannotInferVisibilityForProperty.kt") public void testCannotInferVisibilityForProperty() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/override/CannotInferVisibilityForProperty.kt"); @@ -10257,18 +10251,6 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { doTest(fileName); } - @TestMetadata("kt4785classObject.kt") - public void testKt4785classObject() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/override/kt4785classObject.kt"); - doTest(fileName); - } - - @TestMetadata("kt4785delegation.kt") - public void testKt4785delegation() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/override/kt4785delegation.kt"); - doTest(fileName); - } - @TestMetadata("kt880.kt") public void testKt880() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/override/kt880.kt"); @@ -15538,6 +15520,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) public static class PrivateToThis extends AbstractJetDiagnosticsTest { + @TestMetadata("Abstract.kt") + public void testAbstract() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/variance/privateToThis/Abstract.kt"); + doTest(fileName); + } + public void testAllFilesPresentInPrivateToThis() throws Exception { JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/variance/privateToThis"), Pattern.compile("^(.+)\\.kt$"), true); } @@ -15560,12 +15548,6 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { doTest(fileName); } - @TestMetadata("Trait.kt") - public void testTrait() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/variance/privateToThis/Trait.kt"); - doTest(fileName); - } - @TestMetadata("ValReassigned.kt") public void testValReassigned() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/variance/privateToThis/ValReassigned.kt"); diff --git a/idea/testData/checker/Abstract.kt b/idea/testData/checker/Abstract.kt index c6f05487255..b5314698fd8 100644 --- a/idea/testData/checker/Abstract.kt +++ b/idea/testData/checker/Abstract.kt @@ -70,10 +70,10 @@ interface MyTrait { abstract val a2: Int abstract val a3: Int = 1 - var b: Int private set - var b1: Int = 0; private set - abstract var b2: Int private set - abstract var b3: Int = 0; private set + var b: Int + var b1: Int = 0; + abstract var b2: Int + abstract var b3: Int = 0; var c: Int set(v: Int) { field = v } var c1: Int = 0; set(v: Int) { field = v }