JS: prohibit private inline members of external classes, since KT-14031 was postponed
This commit is contained in:
@@ -17,10 +17,12 @@ external class C {
|
||||
get
|
||||
<!WRONG_EXTERNAL_DECLARATION!>private set<!>
|
||||
|
||||
/*
|
||||
private inline fun inline_a(): Int = 23
|
||||
|
||||
private inline val inline_prop: Int
|
||||
get() = 42
|
||||
*/
|
||||
}
|
||||
|
||||
external object O {
|
||||
@@ -34,10 +36,12 @@ external object O {
|
||||
get
|
||||
set
|
||||
|
||||
/*
|
||||
private inline fun inline_a(): Int = 23
|
||||
|
||||
private inline val inline_prop: Int
|
||||
get() = 42
|
||||
*/
|
||||
}
|
||||
|
||||
external class Outer {
|
||||
@@ -52,10 +56,12 @@ external class Outer {
|
||||
get
|
||||
set
|
||||
|
||||
/*
|
||||
private inline fun inline_a(): Int = 23
|
||||
|
||||
private inline val inline_prop: Int
|
||||
get() = 42
|
||||
*/
|
||||
}
|
||||
|
||||
private class <!WRONG_EXTERNAL_DECLARATION!>PrivateInner<!>
|
||||
|
||||
@@ -1,33 +1,29 @@
|
||||
package
|
||||
|
||||
public final class C {
|
||||
public external final class C {
|
||||
public constructor C()
|
||||
private final val b: kotlin.String
|
||||
private final var c: kotlin.Float
|
||||
private final var d: kotlin.Float
|
||||
public final var e: kotlin.Float
|
||||
private final val inline_prop: kotlin.Int
|
||||
private final fun 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
|
||||
private final inline fun inline_a(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public object O {
|
||||
public external object O {
|
||||
private constructor O()
|
||||
private final val b: kotlin.String
|
||||
private final var c: kotlin.Float
|
||||
private final var d: kotlin.Float
|
||||
private final val inline_prop: kotlin.Int
|
||||
private final fun 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
|
||||
private final inline fun inline_a(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class Outer {
|
||||
public external final class Outer {
|
||||
public constructor Outer()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
@@ -38,11 +34,9 @@ public final class Outer {
|
||||
private final val b: kotlin.String
|
||||
private final var c: kotlin.Float
|
||||
private final var d: kotlin.Float
|
||||
private final val inline_prop: kotlin.Int
|
||||
private final fun 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
|
||||
private final inline fun inline_a(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.jetbrains.kotlin.js.resolve.diagnostics
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticSink
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.js.PredefinedAnnotation
|
||||
import org.jetbrains.kotlin.js.translate.utils.AnnotationsUtils
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
@@ -28,7 +27,10 @@ import org.jetbrains.kotlin.psi.KtProperty
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.checkers.SimpleDeclarationChecker
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.*
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.getSuperClassNotAny
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.getSuperInterfaces
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.isExtension
|
||||
import org.jetbrains.kotlin.utils.singletonOrEmptyList
|
||||
|
||||
class JsExternalChecker : SimpleDeclarationChecker {
|
||||
@@ -51,7 +53,7 @@ class JsExternalChecker : SimpleDeclarationChecker {
|
||||
else if (descriptor is ClassDescriptor && descriptor.isInner) {
|
||||
diagnosticHolder.report(ErrorsJs.WRONG_EXTERNAL_DECLARATION.on(declaration, "inner class"))
|
||||
}
|
||||
else if (isPrivateNonInlineMemberOfExternalClass(descriptor)) {
|
||||
else if (isPrivateMemberOfExternalClass(descriptor)) {
|
||||
diagnosticHolder.report(ErrorsJs.WRONG_EXTERNAL_DECLARATION.on(declaration, "private member of class"))
|
||||
}
|
||||
|
||||
@@ -82,11 +84,9 @@ class JsExternalChecker : SimpleDeclarationChecker {
|
||||
AnnotationsUtils.hasAnnotation(descriptor, PredefinedAnnotation.NATIVE)
|
||||
}
|
||||
|
||||
private fun isPrivateNonInlineMemberOfExternalClass(descriptor: DeclarationDescriptor): Boolean {
|
||||
private fun isPrivateMemberOfExternalClass(descriptor: DeclarationDescriptor): Boolean {
|
||||
if (descriptor is PropertyAccessorDescriptor && descriptor.visibility == descriptor.correspondingProperty.visibility) return false
|
||||
if (descriptor !is MemberDescriptor || descriptor.visibility != Visibilities.PRIVATE) return false
|
||||
if (descriptor is FunctionDescriptor && descriptor.isInline) return false
|
||||
if (descriptor is PropertyDescriptor && descriptor.accessors.all { it.isInline }) return false
|
||||
|
||||
val containingDeclaration = descriptor.containingDeclaration as? ClassDescriptor ?: return false
|
||||
return AnnotationsUtils.isNativeObject(containingDeclaration)
|
||||
|
||||
Reference in New Issue
Block a user