Protected in allowed in companion objects but forbidden in other objects, relevant test fixes
This commit is contained in:
@@ -99,7 +99,7 @@ public object ModifierCheckerCore {
|
||||
INNER_KEYWORD to EnumSet.of(CLASS_ONLY, INNER_CLASS, LOCAL_CLASS, ENUM_CLASS),
|
||||
OVERRIDE_KEYWORD to EnumSet.of(CLASS_ONLY, INNER_CLASS, LOCAL_CLASS, OBJECT, OBJECT_LITERAL,
|
||||
INTERFACE, ENUM_CLASS, ENUM_ENTRY),
|
||||
PROTECTED_KEYWORD to EnumSet.of(CLASS_ONLY, INNER_CLASS, LOCAL_CLASS, ENUM_CLASS, OBJECT),
|
||||
PROTECTED_KEYWORD to EnumSet.of(CLASS_ONLY, INNER_CLASS, LOCAL_CLASS, ENUM_CLASS, COMPANION_OBJECT),
|
||||
INTERNAL_KEYWORD to EnumSet.of(CLASS_ONLY, INNER_CLASS, LOCAL_CLASS, OBJECT, OBJECT_LITERAL,
|
||||
ENUM_CLASS, ENUM_ENTRY, FILE),
|
||||
PRIVATE_KEYWORD to EnumSet.of(CLASS_ONLY, INNER_CLASS, LOCAL_CLASS, OBJECT, OBJECT_LITERAL,
|
||||
@@ -109,10 +109,7 @@ public object ModifierCheckerCore {
|
||||
ENUM_CLASS, ENUM_ENTRY, ANNOTATION_CLASS, FILE)
|
||||
)
|
||||
|
||||
val deprecatedParentTargetMap = mapOf<KtModifierKeywordToken, Set<KotlinTarget>>(
|
||||
// Deprecated in M15
|
||||
PROTECTED_KEYWORD to EnumSet.of(OBJECT)
|
||||
)
|
||||
val deprecatedParentTargetMap = mapOf<KtModifierKeywordToken, Set<KotlinTarget>>()
|
||||
|
||||
// First modifier in pair should be also first in declaration
|
||||
private val mutualCompatibility = buildCompatibilityMap()
|
||||
|
||||
@@ -6,7 +6,6 @@ public const val publicConst: Int = 3
|
||||
|
||||
public object A {
|
||||
private const val privateConst: Int = 1
|
||||
protected const val protectedConst: Int = 2
|
||||
public const val publicConst: Int = 3
|
||||
}
|
||||
|
||||
@@ -39,7 +38,7 @@ fun check(clazz: Class<*>, expectProtected: Boolean = true) {
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
check(A::class.java)
|
||||
check(A::class.java, false)
|
||||
check(B::class.java)
|
||||
check(Class.forName("XYZ"), false)
|
||||
|
||||
|
||||
@@ -46,14 +46,12 @@ class AWithCompanion {
|
||||
object Object {
|
||||
@JvmField public val publicField = "OK";
|
||||
@JvmField internal val internalField = "OK";
|
||||
@JvmField protected val protectedfield = "OK";
|
||||
|
||||
operator fun get(name: String) = Object::class.members.single { it.name == name } as KProperty<*>
|
||||
|
||||
fun testVisibilities() {
|
||||
checkVisibility(this["publicField"].javaField!!, Modifier.PUBLIC)
|
||||
checkVisibility(this["internalField"].javaField!!, Modifier.PUBLIC)
|
||||
checkVisibility(this["protectedfield"].javaField!!, Modifier.PROTECTED)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ class My(protected val x: Int) {
|
||||
}
|
||||
|
||||
object Your {
|
||||
<!DEPRECATED_MODIFIER_CONTAINING_DECLARATION!>protected<!> fun foo() = 3
|
||||
<!WRONG_MODIFIER_CONTAINING_DECLARATION!>protected<!> fun foo() = 3
|
||||
}
|
||||
|
||||
annotation class His(<!WRONG_MODIFIER_CONTAINING_DECLARATION!>protected<!> val x: Int)
|
||||
|
||||
@@ -5,7 +5,7 @@ open class A {
|
||||
val internal_val = 1
|
||||
public val public_val: Int = 2
|
||||
private val private_val = 3
|
||||
<!DEPRECATED_MODIFIER_CONTAINING_DECLARATION!>protected<!> val protected_val: Int = 5
|
||||
protected val protected_val: Int = 5
|
||||
}
|
||||
|
||||
fun fromClass() {
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ package test
|
||||
const private val topLevel = 1
|
||||
|
||||
object A {
|
||||
const protected val inObject = 2
|
||||
const internal val inObject = 2
|
||||
}
|
||||
|
||||
class B {
|
||||
|
||||
@@ -5,8 +5,8 @@ private const val topLevel: kotlin.Int = 1
|
||||
|
||||
public object A {
|
||||
/*primary*/ private constructor A()
|
||||
protected const final val inObject: kotlin.Int = 2
|
||||
protected final fun <get-inObject>(): kotlin.Int
|
||||
internal const final val inObject: kotlin.Int = 2
|
||||
internal final fun <get-inObject>(): kotlin.Int
|
||||
}
|
||||
|
||||
public final class B {
|
||||
|
||||
Reference in New Issue
Block a user