K2: add checker detecting protected Java field shadowed by a property
This commit is contained in:
committed by
teamcity
parent
6234da4c86
commit
949a39b80f
+8
@@ -4737,6 +4737,14 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert
|
|||||||
token,
|
token,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
add(FirJvmErrors.JAVA_SHADOWED_PROTECTED_FIELD_REFERENCE) { firDiagnostic ->
|
||||||
|
JavaShadowedProtectedFieldReferenceImpl(
|
||||||
|
firDiagnostic.a,
|
||||||
|
firDiagnostic.b,
|
||||||
|
firDiagnostic as KtPsiDiagnostic,
|
||||||
|
token,
|
||||||
|
)
|
||||||
|
}
|
||||||
add(FirJsErrors.IMPLEMENTING_FUNCTION_INTERFACE) { firDiagnostic ->
|
add(FirJsErrors.IMPLEMENTING_FUNCTION_INTERFACE) { firDiagnostic ->
|
||||||
ImplementingFunctionInterfaceImpl(
|
ImplementingFunctionInterfaceImpl(
|
||||||
firDiagnostic as KtPsiDiagnostic,
|
firDiagnostic as KtPsiDiagnostic,
|
||||||
|
|||||||
+6
@@ -3294,6 +3294,12 @@ sealed class KtFirDiagnostic<PSI : PsiElement> : KtDiagnosticWithPsi<PSI> {
|
|||||||
override val diagnosticClass get() = JavaSamInterfaceConstructorReference::class
|
override val diagnosticClass get() = JavaSamInterfaceConstructorReference::class
|
||||||
}
|
}
|
||||||
|
|
||||||
|
abstract class JavaShadowedProtectedFieldReference : KtFirDiagnostic<PsiElement>() {
|
||||||
|
override val diagnosticClass get() = JavaShadowedProtectedFieldReference::class
|
||||||
|
abstract val containerClass: ClassId
|
||||||
|
abstract val shadowingClass: ClassId
|
||||||
|
}
|
||||||
|
|
||||||
abstract class ImplementingFunctionInterface : KtFirDiagnostic<KtClassOrObject>() {
|
abstract class ImplementingFunctionInterface : KtFirDiagnostic<KtClassOrObject>() {
|
||||||
override val diagnosticClass get() = ImplementingFunctionInterface::class
|
override val diagnosticClass get() = ImplementingFunctionInterface::class
|
||||||
}
|
}
|
||||||
|
|||||||
+7
@@ -3986,6 +3986,13 @@ internal class JavaSamInterfaceConstructorReferenceImpl(
|
|||||||
override val token: KtLifetimeToken,
|
override val token: KtLifetimeToken,
|
||||||
) : KtFirDiagnostic.JavaSamInterfaceConstructorReference(), KtAbstractFirDiagnostic<PsiElement>
|
) : KtFirDiagnostic.JavaSamInterfaceConstructorReference(), KtAbstractFirDiagnostic<PsiElement>
|
||||||
|
|
||||||
|
internal class JavaShadowedProtectedFieldReferenceImpl(
|
||||||
|
override val containerClass: ClassId,
|
||||||
|
override val shadowingClass: ClassId,
|
||||||
|
override val firDiagnostic: KtPsiDiagnostic,
|
||||||
|
override val token: KtLifetimeToken,
|
||||||
|
) : KtFirDiagnostic.JavaShadowedProtectedFieldReference(), KtAbstractFirDiagnostic<PsiElement>
|
||||||
|
|
||||||
internal class ImplementingFunctionInterfaceImpl(
|
internal class ImplementingFunctionInterfaceImpl(
|
||||||
override val firDiagnostic: KtPsiDiagnostic,
|
override val firDiagnostic: KtPsiDiagnostic,
|
||||||
override val token: KtLifetimeToken,
|
override val token: KtLifetimeToken,
|
||||||
|
|||||||
+18
@@ -405,6 +405,24 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
|||||||
runTest("compiler/testData/diagnostics/tests/IsExpressions.kt");
|
runTest("compiler/testData/diagnostics/tests/IsExpressions.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("javaFieldKotlinPropertyJavaFieldInPackagePrivate.kt")
|
||||||
|
public void testJavaFieldKotlinPropertyJavaFieldInPackagePrivate() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/javaFieldKotlinPropertyJavaFieldInPackagePrivate.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("javaFieldKotlinPropertyJavaPackagePrivateField.kt")
|
||||||
|
public void testJavaFieldKotlinPropertyJavaPackagePrivateField() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/javaFieldKotlinPropertyJavaPackagePrivateField.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("javaProtectedFieldAndKotlinInvisiblePropertyReference.kt")
|
||||||
|
public void testJavaProtectedFieldAndKotlinInvisiblePropertyReference() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/javaProtectedFieldAndKotlinInvisiblePropertyReference.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("kt11167.kt")
|
@TestMetadata("kt11167.kt")
|
||||||
public void testKt11167() throws Exception {
|
public void testKt11167() throws Exception {
|
||||||
|
|||||||
+18
@@ -405,6 +405,24 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
|||||||
runTest("compiler/testData/diagnostics/tests/IsExpressions.kt");
|
runTest("compiler/testData/diagnostics/tests/IsExpressions.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("javaFieldKotlinPropertyJavaFieldInPackagePrivate.kt")
|
||||||
|
public void testJavaFieldKotlinPropertyJavaFieldInPackagePrivate() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/javaFieldKotlinPropertyJavaFieldInPackagePrivate.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("javaFieldKotlinPropertyJavaPackagePrivateField.kt")
|
||||||
|
public void testJavaFieldKotlinPropertyJavaPackagePrivateField() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/javaFieldKotlinPropertyJavaPackagePrivateField.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("javaProtectedFieldAndKotlinInvisiblePropertyReference.kt")
|
||||||
|
public void testJavaProtectedFieldAndKotlinInvisiblePropertyReference() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/javaProtectedFieldAndKotlinInvisiblePropertyReference.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("kt11167.kt")
|
@TestMetadata("kt11167.kt")
|
||||||
public void testKt11167() throws Exception {
|
public void testKt11167() throws Exception {
|
||||||
|
|||||||
+18
@@ -405,6 +405,24 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
|||||||
runTest("compiler/testData/diagnostics/tests/IsExpressions.kt");
|
runTest("compiler/testData/diagnostics/tests/IsExpressions.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("javaFieldKotlinPropertyJavaFieldInPackagePrivate.kt")
|
||||||
|
public void testJavaFieldKotlinPropertyJavaFieldInPackagePrivate() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/javaFieldKotlinPropertyJavaFieldInPackagePrivate.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("javaFieldKotlinPropertyJavaPackagePrivateField.kt")
|
||||||
|
public void testJavaFieldKotlinPropertyJavaPackagePrivateField() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/javaFieldKotlinPropertyJavaPackagePrivateField.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("javaProtectedFieldAndKotlinInvisiblePropertyReference.kt")
|
||||||
|
public void testJavaProtectedFieldAndKotlinInvisiblePropertyReference() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/javaProtectedFieldAndKotlinInvisiblePropertyReference.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("kt11167.kt")
|
@TestMetadata("kt11167.kt")
|
||||||
public void testKt11167() throws Exception {
|
public void testKt11167() throws Exception {
|
||||||
|
|||||||
+7
-4
@@ -6,7 +6,6 @@
|
|||||||
package org.jetbrains.kotlin.fir.checkers.generator.diagnostics
|
package org.jetbrains.kotlin.fir.checkers.generator.diagnostics
|
||||||
|
|
||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
import org.jetbrains.kotlin.config.LanguageFeature
|
|
||||||
import org.jetbrains.kotlin.config.LanguageFeature.*
|
import org.jetbrains.kotlin.config.LanguageFeature.*
|
||||||
import org.jetbrains.kotlin.fir.PrivateForInline
|
import org.jetbrains.kotlin.fir.PrivateForInline
|
||||||
import org.jetbrains.kotlin.fir.checkers.generator.diagnostics.model.DiagnosticList
|
import org.jetbrains.kotlin.fir.checkers.generator.diagnostics.model.DiagnosticList
|
||||||
@@ -21,7 +20,7 @@ import org.jetbrains.kotlin.psi.KtDeclaration
|
|||||||
import org.jetbrains.kotlin.psi.KtElement
|
import org.jetbrains.kotlin.psi.KtElement
|
||||||
import org.jetbrains.kotlin.psi.KtExpression
|
import org.jetbrains.kotlin.psi.KtExpression
|
||||||
|
|
||||||
@Suppress("UNUSED_VARIABLE", "LocalVariableName", "ClassName", "unused")
|
@Suppress("ClassName", "unused")
|
||||||
@OptIn(PrivateForInline::class)
|
@OptIn(PrivateForInline::class)
|
||||||
object JVM_DIAGNOSTICS_LIST : DiagnosticList("FirJvmErrors") {
|
object JVM_DIAGNOSTICS_LIST : DiagnosticList("FirJvmErrors") {
|
||||||
val DECLARATIONS by object : DiagnosticGroup("Declarations") {
|
val DECLARATIONS by object : DiagnosticGroup("Declarations") {
|
||||||
@@ -70,7 +69,7 @@ object JVM_DIAGNOSTICS_LIST : DiagnosticList("FirJvmErrors") {
|
|||||||
ProhibitJvmOverloadsOnConstructorsOfAnnotationClasses
|
ProhibitJvmOverloadsOnConstructorsOfAnnotationClasses
|
||||||
)
|
)
|
||||||
val OVERLOADS_PRIVATE by warning<KtAnnotationEntry>()
|
val OVERLOADS_PRIVATE by warning<KtAnnotationEntry>()
|
||||||
val DEPRECATED_JAVA_ANNOTATION by warning<KtAnnotationEntry>() {
|
val DEPRECATED_JAVA_ANNOTATION by warning<KtAnnotationEntry> {
|
||||||
parameter<FqName>("kotlinName")
|
parameter<FqName>("kotlinName")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,7 +86,7 @@ object JVM_DIAGNOSTICS_LIST : DiagnosticList("FirJvmErrors") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val SUPER by object : DiagnosticGroup("Super") {
|
val SUPER by object : DiagnosticGroup("Super") {
|
||||||
val SUPER_CALL_WITH_DEFAULT_PARAMETERS by error<PsiElement>() {
|
val SUPER_CALL_WITH_DEFAULT_PARAMETERS by error<PsiElement> {
|
||||||
parameter<String>("name")
|
parameter<String>("name")
|
||||||
}
|
}
|
||||||
val INTERFACE_CANT_CALL_DEFAULT_METHOD_VIA_SUPER by error<PsiElement>(PositioningStrategy.REFERENCE_BY_QUALIFIED)
|
val INTERFACE_CANT_CALL_DEFAULT_METHOD_VIA_SUPER by error<PsiElement>(PositioningStrategy.REFERENCE_BY_QUALIFIED)
|
||||||
@@ -191,5 +190,9 @@ object JVM_DIAGNOSTICS_LIST : DiagnosticList("FirJvmErrors") {
|
|||||||
PositioningStrategy.SPREAD_OPERATOR
|
PositioningStrategy.SPREAD_OPERATOR
|
||||||
)
|
)
|
||||||
val JAVA_SAM_INTERFACE_CONSTRUCTOR_REFERENCE by error<PsiElement>()
|
val JAVA_SAM_INTERFACE_CONSTRUCTOR_REFERENCE by error<PsiElement>()
|
||||||
|
val JAVA_SHADOWED_PROTECTED_FIELD_REFERENCE by error<PsiElement> {
|
||||||
|
parameter<ClassId>("containerClass")
|
||||||
|
parameter<ClassId>("shadowingClass")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
@@ -129,6 +129,7 @@ object FirJvmErrors {
|
|||||||
val CONCURRENT_HASH_MAP_CONTAINS_OPERATOR by deprecationError0<PsiElement>(ProhibitConcurrentHashMapContains)
|
val CONCURRENT_HASH_MAP_CONTAINS_OPERATOR by deprecationError0<PsiElement>(ProhibitConcurrentHashMapContains)
|
||||||
val SPREAD_ON_SIGNATURE_POLYMORPHIC_CALL by deprecationError0<PsiElement>(ProhibitSpreadOnSignaturePolymorphicCall, SourceElementPositioningStrategies.SPREAD_OPERATOR)
|
val SPREAD_ON_SIGNATURE_POLYMORPHIC_CALL by deprecationError0<PsiElement>(ProhibitSpreadOnSignaturePolymorphicCall, SourceElementPositioningStrategies.SPREAD_OPERATOR)
|
||||||
val JAVA_SAM_INTERFACE_CONSTRUCTOR_REFERENCE by error0<PsiElement>()
|
val JAVA_SAM_INTERFACE_CONSTRUCTOR_REFERENCE by error0<PsiElement>()
|
||||||
|
val JAVA_SHADOWED_PROTECTED_FIELD_REFERENCE by error2<PsiElement, ClassId, ClassId>()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
RootDiagnosticRendererFactory.registerFactory(FirJvmErrorsDefaultMessages)
|
RootDiagnosticRendererFactory.registerFactory(FirJvmErrorsDefaultMessages)
|
||||||
|
|||||||
+9
@@ -33,6 +33,7 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors.INNER_JVM_
|
|||||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors.INTERFACE_CANT_CALL_DEFAULT_METHOD_VIA_SUPER
|
import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors.INTERFACE_CANT_CALL_DEFAULT_METHOD_VIA_SUPER
|
||||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors.INTERFACE_STATIC_METHOD_CALL_FROM_JAVA6_TARGET
|
import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors.INTERFACE_STATIC_METHOD_CALL_FROM_JAVA6_TARGET
|
||||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors.JAVA_SAM_INTERFACE_CONSTRUCTOR_REFERENCE
|
import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors.JAVA_SAM_INTERFACE_CONSTRUCTOR_REFERENCE
|
||||||
|
import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors.JAVA_SHADOWED_PROTECTED_FIELD_REFERENCE
|
||||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors.JAVA_TYPE_MISMATCH
|
import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors.JAVA_TYPE_MISMATCH
|
||||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors.JVM_DEFAULT_IN_DECLARATION
|
import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors.JVM_DEFAULT_IN_DECLARATION
|
||||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors.JVM_DEFAULT_IN_JVM6_TARGET
|
import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors.JVM_DEFAULT_IN_JVM6_TARGET
|
||||||
@@ -286,6 +287,14 @@ object FirJvmErrorsDefaultMessages : BaseDiagnosticRendererFactory() {
|
|||||||
JAVA_SAM_INTERFACE_CONSTRUCTOR_REFERENCE,
|
JAVA_SAM_INTERFACE_CONSTRUCTOR_REFERENCE,
|
||||||
"Java SAM interface constructor references are prohibited"
|
"Java SAM interface constructor references are prohibited"
|
||||||
)
|
)
|
||||||
|
map.put(
|
||||||
|
JAVA_SHADOWED_PROTECTED_FIELD_REFERENCE,
|
||||||
|
"It's impossible to refer here a protected Java field from class ''{0}'', " +
|
||||||
|
"because an invisible property from class ''{1}'' shadows it. " +
|
||||||
|
"Rename the property from class ''{1}'' or change visibility of the field from class ''{0}''",
|
||||||
|
TO_STRING,
|
||||||
|
TO_STRING
|
||||||
|
)
|
||||||
map.put(
|
map.put(
|
||||||
REDUNDANT_REPEATABLE_ANNOTATION,
|
REDUNDANT_REPEATABLE_ANNOTATION,
|
||||||
"Please, remove the ''{0}'' annotation, as ''{1}'' is already enough",
|
"Please, remove the ''{0}'' annotation, as ''{1}'' is already enough",
|
||||||
|
|||||||
+6
-1
@@ -17,7 +17,12 @@ object JvmExpressionCheckers : ExpressionCheckers() {
|
|||||||
override val qualifiedAccessExpressionCheckers: Set<FirQualifiedAccessExpressionChecker>
|
override val qualifiedAccessExpressionCheckers: Set<FirQualifiedAccessExpressionChecker>
|
||||||
get() = setOf(
|
get() = setOf(
|
||||||
FirInterfaceDefaultMethodCallChecker,
|
FirInterfaceDefaultMethodCallChecker,
|
||||||
FirJavaSamInterfaceConstructorReferenceChecker
|
FirJavaSamInterfaceConstructorReferenceChecker,
|
||||||
|
)
|
||||||
|
|
||||||
|
override val callableReferenceAccessCheckers: Set<FirCallableReferenceAccessChecker>
|
||||||
|
get() = setOf(
|
||||||
|
FirJavaShadowedFieldReferenceChecker,
|
||||||
)
|
)
|
||||||
|
|
||||||
override val functionCallCheckers: Set<FirFunctionCallChecker>
|
override val functionCallCheckers: Set<FirFunctionCallChecker>
|
||||||
|
|||||||
+69
@@ -0,0 +1,69 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.fir.analysis.jvm.checkers.expression
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.descriptors.java.JavaVisibilities
|
||||||
|
import org.jetbrains.kotlin.diagnostics.DiagnosticReporter
|
||||||
|
import org.jetbrains.kotlin.diagnostics.reportOn
|
||||||
|
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
|
||||||
|
import org.jetbrains.kotlin.fir.analysis.checkers.expression.FirCallableReferenceAccessChecker
|
||||||
|
import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors
|
||||||
|
import org.jetbrains.kotlin.fir.containingClassLookupTag
|
||||||
|
import org.jetbrains.kotlin.fir.declarations.utils.hasBackingField
|
||||||
|
import org.jetbrains.kotlin.fir.declarations.utils.visibility
|
||||||
|
import org.jetbrains.kotlin.fir.expressions.FirCallableReferenceAccess
|
||||||
|
import org.jetbrains.kotlin.fir.expressions.impl.FirNoReceiverExpression
|
||||||
|
import org.jetbrains.kotlin.fir.packageFqName
|
||||||
|
import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
|
||||||
|
import org.jetbrains.kotlin.fir.resolve.*
|
||||||
|
import org.jetbrains.kotlin.fir.scopes.FakeOverrideTypeCalculator
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.impl.FirFieldSymbol
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol
|
||||||
|
import org.jetbrains.kotlin.fir.types.coneType
|
||||||
|
import org.jetbrains.kotlin.name.ClassId
|
||||||
|
|
||||||
|
object FirJavaShadowedFieldReferenceChecker : FirCallableReferenceAccessChecker() {
|
||||||
|
override fun check(expression: FirCallableReferenceAccess, context: CheckerContext, reporter: DiagnosticReporter) {
|
||||||
|
val reference = expression.calleeReference as? FirResolvedNamedReference ?: return
|
||||||
|
val referredSymbol = reference.resolvedSymbol as? FirFieldSymbol ?: return
|
||||||
|
if (referredSymbol.visibility != JavaVisibilities.ProtectedAndPackage) return
|
||||||
|
val session = context.session
|
||||||
|
val fieldContainingClassSymbol = referredSymbol.containingClassLookupTag()?.toFirRegularClassSymbol(session) ?: return
|
||||||
|
// Would it be visible, if it would be package private instead of protected-and-package?
|
||||||
|
if (context.containingFile?.packageFqName == fieldContainingClassSymbol.classId.packageFqName) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
val dispatchReceiver = expression.dispatchReceiver.takeIf { it !is FirNoReceiverExpression } ?: return
|
||||||
|
val scope = dispatchReceiver.typeRef.coneType.scope(
|
||||||
|
session, context.sessionHolder.scopeSession, FakeOverrideTypeCalculator.DoNothing
|
||||||
|
) ?: return
|
||||||
|
|
||||||
|
var shadowingPropertyClassId: ClassId? = null
|
||||||
|
scope.processPropertiesByName(referredSymbol.name) {
|
||||||
|
if (it !is FirPropertySymbol) return@processPropertiesByName
|
||||||
|
if (!it.hasBackingField) return@processPropertiesByName
|
||||||
|
val propertyContainingClassSymbol = it.containingClassLookupTag()?.toFirRegularClassSymbol(session)
|
||||||
|
?: return@processPropertiesByName
|
||||||
|
if (propertyContainingClassSymbol.isSubclassOf(
|
||||||
|
fieldContainingClassSymbol.toLookupTag(), session, isStrict = true, lookupInterfaces = false
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
shadowingPropertyClassId = propertyContainingClassSymbol.classId
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
shadowingPropertyClassId?.let {
|
||||||
|
reporter.reportOn(
|
||||||
|
reference.source,
|
||||||
|
FirJvmErrors.JAVA_SHADOWED_PROTECTED_FIELD_REFERENCE,
|
||||||
|
fieldContainingClassSymbol.classId,
|
||||||
|
it,
|
||||||
|
context
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-2
@@ -11,7 +11,6 @@ import org.jetbrains.kotlin.diagnostics.DiagnosticReporter
|
|||||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors
|
import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors
|
||||||
import org.jetbrains.kotlin.diagnostics.reportOn
|
import org.jetbrains.kotlin.diagnostics.reportOn
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirClass
|
import org.jetbrains.kotlin.fir.declarations.FirClass
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirFile
|
|
||||||
import org.jetbrains.kotlin.fir.declarations.getStringArgument
|
import org.jetbrains.kotlin.fir.declarations.getStringArgument
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirAnnotation
|
import org.jetbrains.kotlin.fir.expressions.FirAnnotation
|
||||||
import org.jetbrains.kotlin.fir.types.ConeClassLikeType
|
import org.jetbrains.kotlin.fir.types.ConeClassLikeType
|
||||||
@@ -37,7 +36,7 @@ object FirJvmPackageNameAnnotationsChecker : FirAnnotationChecker() {
|
|||||||
reporter.reportOn(expression.source, FirJvmErrors.JVM_PACKAGE_NAME_MUST_BE_VALID_NAME, context)
|
reporter.reportOn(expression.source, FirJvmErrors.JVM_PACKAGE_NAME_MUST_BE_VALID_NAME, context)
|
||||||
}
|
}
|
||||||
|
|
||||||
val file = context.containingDeclarations.firstOrNull() as? FirFile ?: return
|
val file = context.containingFile ?: return
|
||||||
if (file.declarations.any { it is FirClass }) {
|
if (file.declarations.any { it is FirClass }) {
|
||||||
reporter.reportOn(expression.source, FirJvmErrors.JVM_PACKAGE_NAME_NOT_SUPPORTED_IN_FILES_WITH_CLASSES, context)
|
reporter.reportOn(expression.source, FirJvmErrors.JVM_PACKAGE_NAME_NOT_SUPPORTED_IN_FILES_WITH_CLASSES, context)
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-1
@@ -91,8 +91,11 @@ abstract class CheckerContext : MutableDiagnosticContext() {
|
|||||||
override val languageVersionSettings: LanguageVersionSettings
|
override val languageVersionSettings: LanguageVersionSettings
|
||||||
get() = session.languageVersionSettings
|
get() = session.languageVersionSettings
|
||||||
|
|
||||||
|
val containingFile: FirFile?
|
||||||
|
get() = if (containingDeclarations.isEmpty()) null else containingDeclarations.first() as FirFile
|
||||||
|
|
||||||
override val containingFilePath: String?
|
override val containingFilePath: String?
|
||||||
get() = containingDeclarations.firstOrNull()?.let { (it as? FirFile)?.sourceFile?.path }
|
get() = containingFile?.sourceFile?.path
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+1
-2
@@ -9,7 +9,6 @@ import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
|
|||||||
import org.jetbrains.kotlin.diagnostics.DiagnosticReporter
|
import org.jetbrains.kotlin.diagnostics.DiagnosticReporter
|
||||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors
|
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors
|
||||||
import org.jetbrains.kotlin.diagnostics.reportOn
|
import org.jetbrains.kotlin.diagnostics.reportOn
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirFile
|
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirTypeAlias
|
import org.jetbrains.kotlin.fir.declarations.FirTypeAlias
|
||||||
import org.jetbrains.kotlin.fir.declarations.utils.expandedConeType
|
import org.jetbrains.kotlin.fir.declarations.utils.expandedConeType
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirResolvedQualifier
|
import org.jetbrains.kotlin.fir.expressions.FirResolvedQualifier
|
||||||
@@ -32,7 +31,7 @@ object FirVisibilityQualifierChecker : FirResolvedQualifierChecker() {
|
|||||||
context: CheckerContext,
|
context: CheckerContext,
|
||||||
reporter: DiagnosticReporter
|
reporter: DiagnosticReporter
|
||||||
) {
|
) {
|
||||||
val firFile = context.containingDeclarations.firstOrNull() as? FirFile ?: return
|
val firFile = context.containingFile ?: return
|
||||||
val firClassLikeDeclaration = symbol.fir
|
val firClassLikeDeclaration = symbol.fir
|
||||||
|
|
||||||
if (!context.session.visibilityChecker.isClassLikeVisible(
|
if (!context.session.visibilityChecker.isClassLikeVisible(
|
||||||
|
|||||||
@@ -92,11 +92,22 @@ fun lookupSuperTypes(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun FirClassSymbol<*>.isSubclassOf(
|
||||||
|
ownerLookupTag: ConeClassLikeLookupTag,
|
||||||
|
session: FirSession,
|
||||||
|
isStrict: Boolean,
|
||||||
|
lookupInterfaces: Boolean
|
||||||
|
): Boolean {
|
||||||
|
lazyResolveToPhase(FirResolvePhase.SUPER_TYPES)
|
||||||
|
return fir.isSubclassOf(ownerLookupTag, session, isStrict, SupertypeSupplier.Default, lookupInterfaces)
|
||||||
|
}
|
||||||
|
|
||||||
fun FirClass.isSubclassOf(
|
fun FirClass.isSubclassOf(
|
||||||
ownerLookupTag: ConeClassLikeLookupTag,
|
ownerLookupTag: ConeClassLikeLookupTag,
|
||||||
session: FirSession,
|
session: FirSession,
|
||||||
isStrict: Boolean,
|
isStrict: Boolean,
|
||||||
supertypeSupplier: SupertypeSupplier = SupertypeSupplier.Default
|
supertypeSupplier: SupertypeSupplier = SupertypeSupplier.Default,
|
||||||
|
lookupInterfaces: Boolean = true,
|
||||||
): Boolean {
|
): Boolean {
|
||||||
if (classId.isSame(ownerLookupTag.classId)) {
|
if (classId.isSame(ownerLookupTag.classId)) {
|
||||||
return !isStrict
|
return !isStrict
|
||||||
@@ -104,7 +115,7 @@ fun FirClass.isSubclassOf(
|
|||||||
|
|
||||||
return lookupSuperTypes(
|
return lookupSuperTypes(
|
||||||
this,
|
this,
|
||||||
lookupInterfaces = true,
|
lookupInterfaces = lookupInterfaces,
|
||||||
deep = true,
|
deep = true,
|
||||||
session,
|
session,
|
||||||
substituteTypes = false,
|
substituteTypes = false,
|
||||||
|
|||||||
Vendored
+27
@@ -0,0 +1,27 @@
|
|||||||
|
// FILE: A.java
|
||||||
|
|
||||||
|
package base;
|
||||||
|
|
||||||
|
class A {
|
||||||
|
public String f = "OK";
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: B.kt
|
||||||
|
|
||||||
|
package base
|
||||||
|
|
||||||
|
open class B : <!EXPOSED_SUPER_CLASS!>A<!>() {
|
||||||
|
private val f = "FAIL"
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: C.java
|
||||||
|
|
||||||
|
import base.B;
|
||||||
|
|
||||||
|
public class C extends B {}
|
||||||
|
|
||||||
|
// FILE: test.kt
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
return C().f
|
||||||
|
}
|
||||||
+27
@@ -0,0 +1,27 @@
|
|||||||
|
// FILE: A.java
|
||||||
|
|
||||||
|
package base;
|
||||||
|
|
||||||
|
class A {
|
||||||
|
public String f = "OK";
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: B.kt
|
||||||
|
|
||||||
|
package base
|
||||||
|
|
||||||
|
open class B : <!EXPOSED_SUPER_CLASS!>A()<!> {
|
||||||
|
private val f = "FAIL"
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: C.java
|
||||||
|
|
||||||
|
import base.B;
|
||||||
|
|
||||||
|
public class C extends B {}
|
||||||
|
|
||||||
|
// FILE: test.kt
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
return C().f
|
||||||
|
}
|
||||||
+32
@@ -0,0 +1,32 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public fun box(): kotlin.String
|
||||||
|
|
||||||
|
public open class C : base.B {
|
||||||
|
public constructor C()
|
||||||
|
invisible_fake final override /*1*/ /*fake_override*/ val f: kotlin.String
|
||||||
|
public final override /*1*/ /*fake_override*/ var f: 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
|
||||||
|
}
|
||||||
|
|
||||||
|
package base {
|
||||||
|
|
||||||
|
public/*package*/ open class A {
|
||||||
|
public/*package*/ constructor A()
|
||||||
|
public final var f: 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 B : base.A {
|
||||||
|
public constructor B()
|
||||||
|
private final val f: kotlin.String = "FAIL"
|
||||||
|
public final override /*1*/ /*fake_override*/ var f: 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
|
||||||
|
}
|
||||||
|
}
|
||||||
+27
@@ -0,0 +1,27 @@
|
|||||||
|
// FILE: A.java
|
||||||
|
|
||||||
|
package base;
|
||||||
|
|
||||||
|
public class A {
|
||||||
|
String f = "OK";
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: B.kt
|
||||||
|
|
||||||
|
package base
|
||||||
|
|
||||||
|
open class B : A() {
|
||||||
|
private val f = "FAIL"
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: C.java
|
||||||
|
|
||||||
|
import base.B;
|
||||||
|
|
||||||
|
public class C extends B {}
|
||||||
|
|
||||||
|
// FILE: test.kt
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
return C().<!INVISIBLE_REFERENCE!>f<!>
|
||||||
|
}
|
||||||
+27
@@ -0,0 +1,27 @@
|
|||||||
|
// FILE: A.java
|
||||||
|
|
||||||
|
package base;
|
||||||
|
|
||||||
|
public class A {
|
||||||
|
String f = "OK";
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: B.kt
|
||||||
|
|
||||||
|
package base
|
||||||
|
|
||||||
|
open class B : A() {
|
||||||
|
private val f = "FAIL"
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: C.java
|
||||||
|
|
||||||
|
import base.B;
|
||||||
|
|
||||||
|
public class C extends B {}
|
||||||
|
|
||||||
|
// FILE: test.kt
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
return C().<!INVISIBLE_MEMBER!>f<!>
|
||||||
|
}
|
||||||
+32
@@ -0,0 +1,32 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public fun box(): kotlin.String
|
||||||
|
|
||||||
|
public open class C : base.B {
|
||||||
|
public constructor C()
|
||||||
|
invisible_fake final override /*1*/ /*fake_override*/ val f: kotlin.String
|
||||||
|
invisible_fake final override /*1*/ /*fake_override*/ var f: 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
|
||||||
|
}
|
||||||
|
|
||||||
|
package base {
|
||||||
|
|
||||||
|
public open class A {
|
||||||
|
public constructor A()
|
||||||
|
public/*package*/ final var f: 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 B : base.A {
|
||||||
|
public constructor B()
|
||||||
|
private final val f: kotlin.String = "FAIL"
|
||||||
|
public/*package*/ final override /*1*/ /*fake_override*/ var f: 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
|
||||||
|
}
|
||||||
|
}
|
||||||
Vendored
+94
@@ -0,0 +1,94 @@
|
|||||||
|
// FILE: BaseJava.java
|
||||||
|
|
||||||
|
package base;
|
||||||
|
|
||||||
|
public class BaseJava {
|
||||||
|
protected String a = "TARGET";
|
||||||
|
|
||||||
|
String b = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
class DerivedJava extends BaseKotlin {
|
||||||
|
protected String a = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: Base.kt
|
||||||
|
|
||||||
|
package base
|
||||||
|
|
||||||
|
abstract class BaseKotlin
|
||||||
|
|
||||||
|
open class Intermediate : BaseJava() {
|
||||||
|
private val a = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
class Derived : Intermediate() {
|
||||||
|
fun foo() = this::a // Same package
|
||||||
|
}
|
||||||
|
|
||||||
|
private class DerivedFromDerivedJava : DerivedJava() {
|
||||||
|
fun foo() = this::a // Property class is a subclass of the field class
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: Derived.kt
|
||||||
|
|
||||||
|
package derived
|
||||||
|
|
||||||
|
import base.BaseJava
|
||||||
|
|
||||||
|
open class Intermediate : BaseJava() {
|
||||||
|
private val a = ""
|
||||||
|
|
||||||
|
private val b = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
open class IntermediateWithoutField : BaseJava() {
|
||||||
|
private val a get() = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
open class IntermediatePublic : BaseJava() {
|
||||||
|
val a = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
class Derived : Intermediate() {
|
||||||
|
// This should be the first erroneous place (only in K2)
|
||||||
|
fun foo() = this::<!JAVA_SHADOWED_PROTECTED_FIELD_REFERENCE!>a<!>
|
||||||
|
|
||||||
|
fun bar() = a // Non-reference
|
||||||
|
|
||||||
|
fun baz() = this::<!UNRESOLVED_REFERENCE!>b<!> // Non-protected
|
||||||
|
}
|
||||||
|
|
||||||
|
typealias Alias = Intermediate
|
||||||
|
|
||||||
|
class DerivedAlias : Alias() {
|
||||||
|
// This should be the second erroneous place (only in K2)
|
||||||
|
fun foo() = this::<!JAVA_SHADOWED_PROTECTED_FIELD_REFERENCE!>a<!>
|
||||||
|
}
|
||||||
|
|
||||||
|
fun local() {
|
||||||
|
open class LocalIntermediate : BaseJava() {
|
||||||
|
private val a = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
class LocalDerived : LocalIntermediate() {
|
||||||
|
// This should be the third and the last erroneous place (only in K2)
|
||||||
|
fun foo() = this::<!JAVA_SHADOWED_PROTECTED_FIELD_REFERENCE!>a<!>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class DerivedWithoutBackingField : IntermediateWithoutField() {
|
||||||
|
fun foo() = this::a // No shadowing backing field
|
||||||
|
}
|
||||||
|
|
||||||
|
class DerivedPublic : IntermediatePublic() {
|
||||||
|
fun foo() = this::a // Visible property
|
||||||
|
}
|
||||||
|
|
||||||
|
class DirectlyDerived : BaseJava() {
|
||||||
|
fun foo() = this::a // No property at all
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test(d: Derived) {
|
||||||
|
d::<!UNRESOLVED_REFERENCE!>a<!> // Field is also invisible
|
||||||
|
}
|
||||||
Vendored
+94
@@ -0,0 +1,94 @@
|
|||||||
|
// FILE: BaseJava.java
|
||||||
|
|
||||||
|
package base;
|
||||||
|
|
||||||
|
public class BaseJava {
|
||||||
|
protected String a = "TARGET";
|
||||||
|
|
||||||
|
String b = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
class DerivedJava extends BaseKotlin {
|
||||||
|
protected String a = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: Base.kt
|
||||||
|
|
||||||
|
package base
|
||||||
|
|
||||||
|
abstract class BaseKotlin
|
||||||
|
|
||||||
|
open class Intermediate : BaseJava() {
|
||||||
|
private val a = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
class Derived : Intermediate() {
|
||||||
|
fun foo() = this::a // Same package
|
||||||
|
}
|
||||||
|
|
||||||
|
private class DerivedFromDerivedJava : DerivedJava() {
|
||||||
|
fun foo() = this::a // Property class is a subclass of the field class
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: Derived.kt
|
||||||
|
|
||||||
|
package derived
|
||||||
|
|
||||||
|
import base.BaseJava
|
||||||
|
|
||||||
|
open class Intermediate : BaseJava() {
|
||||||
|
private val a = ""
|
||||||
|
|
||||||
|
private val b = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
open class IntermediateWithoutField : BaseJava() {
|
||||||
|
private val a get() = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
open class IntermediatePublic : BaseJava() {
|
||||||
|
val a = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
class Derived : Intermediate() {
|
||||||
|
// This should be the first erroneous place (only in K2)
|
||||||
|
fun foo() = this::a
|
||||||
|
|
||||||
|
fun bar() = a // Non-reference
|
||||||
|
|
||||||
|
fun baz() = this::<!INVISIBLE_MEMBER!>b<!> // Non-protected
|
||||||
|
}
|
||||||
|
|
||||||
|
typealias Alias = Intermediate
|
||||||
|
|
||||||
|
class DerivedAlias : Alias() {
|
||||||
|
// This should be the second erroneous place (only in K2)
|
||||||
|
fun foo() = this::a
|
||||||
|
}
|
||||||
|
|
||||||
|
fun local() {
|
||||||
|
open class LocalIntermediate : BaseJava() {
|
||||||
|
private val a = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
class LocalDerived : LocalIntermediate() {
|
||||||
|
// This should be the third and the last erroneous place (only in K2)
|
||||||
|
fun foo() = this::a
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class DerivedWithoutBackingField : IntermediateWithoutField() {
|
||||||
|
fun foo() = this::a // No shadowing backing field
|
||||||
|
}
|
||||||
|
|
||||||
|
class DerivedPublic : IntermediatePublic() {
|
||||||
|
fun foo() = this::a // Visible property
|
||||||
|
}
|
||||||
|
|
||||||
|
class DirectlyDerived : BaseJava() {
|
||||||
|
fun foo() = this::a // No property at all
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test(d: Derived) {
|
||||||
|
d::<!INVISIBLE_MEMBER!>a<!> // Field is also invisible
|
||||||
|
}
|
||||||
Vendored
+153
@@ -0,0 +1,153 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
package base {
|
||||||
|
|
||||||
|
public open class BaseJava {
|
||||||
|
public constructor BaseJava()
|
||||||
|
protected/*protected and package*/ final var a: kotlin.String!
|
||||||
|
public/*package*/ final var b: 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 abstract class BaseKotlin {
|
||||||
|
public constructor BaseKotlin()
|
||||||
|
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 Derived : base.Intermediate {
|
||||||
|
public constructor Derived()
|
||||||
|
invisible_fake final override /*1*/ /*fake_override*/ val a: kotlin.String
|
||||||
|
protected/*protected and package*/ final override /*1*/ /*fake_override*/ var a: kotlin.String!
|
||||||
|
public/*package*/ final override /*1*/ /*fake_override*/ var b: kotlin.String!
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public final fun foo(): kotlin.reflect.KMutableProperty0<kotlin.String!>
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
private final class DerivedFromDerivedJava : base.DerivedJava {
|
||||||
|
public constructor DerivedFromDerivedJava()
|
||||||
|
protected/*protected and package*/ final override /*1*/ /*fake_override*/ var a: kotlin.String!
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public final fun foo(): kotlin.reflect.KMutableProperty0<kotlin.String!>
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public/*package*/ open class DerivedJava : base.BaseKotlin {
|
||||||
|
public/*package*/ constructor DerivedJava()
|
||||||
|
protected/*protected and package*/ final var 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 Intermediate : base.BaseJava {
|
||||||
|
public constructor Intermediate()
|
||||||
|
private final val a: kotlin.String = ""
|
||||||
|
protected/*protected and package*/ final override /*1*/ /*fake_override*/ var a: kotlin.String!
|
||||||
|
public/*package*/ final override /*1*/ /*fake_override*/ var b: 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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
package derived {
|
||||||
|
public fun local(): kotlin.Unit
|
||||||
|
public fun test(/*0*/ d: derived.Derived): kotlin.Unit
|
||||||
|
|
||||||
|
public final class Derived : derived.Intermediate {
|
||||||
|
public constructor Derived()
|
||||||
|
invisible_fake final override /*1*/ /*fake_override*/ val a: kotlin.String
|
||||||
|
protected/*protected and package*/ final override /*1*/ /*fake_override*/ var a: kotlin.String!
|
||||||
|
invisible_fake final override /*1*/ /*fake_override*/ val b: kotlin.String
|
||||||
|
invisible_fake final override /*1*/ /*fake_override*/ var b: kotlin.String!
|
||||||
|
public final fun bar(): kotlin.String!
|
||||||
|
public final fun baz(): kotlin.reflect.KMutableProperty0<kotlin.String!>
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public final fun foo(): kotlin.reflect.KMutableProperty0<kotlin.String!>
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class DerivedAlias : derived.Alias /* = derived.Intermediate */ {
|
||||||
|
public constructor DerivedAlias()
|
||||||
|
invisible_fake final override /*1*/ /*fake_override*/ val a: kotlin.String
|
||||||
|
protected/*protected and package*/ final override /*1*/ /*fake_override*/ var a: kotlin.String!
|
||||||
|
invisible_fake final override /*1*/ /*fake_override*/ val b: kotlin.String
|
||||||
|
invisible_fake final override /*1*/ /*fake_override*/ var b: kotlin.String!
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public final fun foo(): kotlin.reflect.KMutableProperty0<kotlin.String!>
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class DerivedPublic : derived.IntermediatePublic {
|
||||||
|
public constructor DerivedPublic()
|
||||||
|
protected/*protected and package*/ final override /*1*/ /*fake_override*/ var a: kotlin.String!
|
||||||
|
public final override /*1*/ /*fake_override*/ val a: kotlin.String
|
||||||
|
invisible_fake final override /*1*/ /*fake_override*/ var b: kotlin.String!
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public final fun foo(): kotlin.reflect.KMutableProperty0<kotlin.String!>
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class DerivedWithoutBackingField : derived.IntermediateWithoutField {
|
||||||
|
public constructor DerivedWithoutBackingField()
|
||||||
|
invisible_fake final override /*1*/ /*fake_override*/ val a: kotlin.String
|
||||||
|
protected/*protected and package*/ final override /*1*/ /*fake_override*/ var a: kotlin.String!
|
||||||
|
invisible_fake final override /*1*/ /*fake_override*/ var b: kotlin.String!
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public final fun foo(): kotlin.reflect.KMutableProperty0<kotlin.String!>
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class DirectlyDerived : base.BaseJava {
|
||||||
|
public constructor DirectlyDerived()
|
||||||
|
protected/*protected and package*/ final override /*1*/ /*fake_override*/ var a: kotlin.String!
|
||||||
|
invisible_fake final override /*1*/ /*fake_override*/ var b: kotlin.String!
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public final fun foo(): kotlin.reflect.KMutableProperty0<kotlin.String!>
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public open class Intermediate : base.BaseJava {
|
||||||
|
public constructor Intermediate()
|
||||||
|
private final val a: kotlin.String = ""
|
||||||
|
protected/*protected and package*/ final override /*1*/ /*fake_override*/ var a: kotlin.String!
|
||||||
|
private final val b: kotlin.String = ""
|
||||||
|
invisible_fake final override /*1*/ /*fake_override*/ var b: 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 IntermediatePublic : base.BaseJava {
|
||||||
|
public constructor IntermediatePublic()
|
||||||
|
public final val a: kotlin.String = ""
|
||||||
|
protected/*protected and package*/ final override /*1*/ /*fake_override*/ var a: kotlin.String!
|
||||||
|
invisible_fake final override /*1*/ /*fake_override*/ var b: 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 IntermediateWithoutField : base.BaseJava {
|
||||||
|
public constructor IntermediateWithoutField()
|
||||||
|
private final val a: kotlin.String
|
||||||
|
protected/*protected and package*/ final override /*1*/ /*fake_override*/ var a: kotlin.String!
|
||||||
|
invisible_fake final override /*1*/ /*fake_override*/ var b: 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 typealias Alias = derived.Intermediate
|
||||||
|
}
|
||||||
Generated
+18
@@ -405,6 +405,24 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
|||||||
runTest("compiler/testData/diagnostics/tests/IsExpressions.kt");
|
runTest("compiler/testData/diagnostics/tests/IsExpressions.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("javaFieldKotlinPropertyJavaFieldInPackagePrivate.kt")
|
||||||
|
public void testJavaFieldKotlinPropertyJavaFieldInPackagePrivate() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/javaFieldKotlinPropertyJavaFieldInPackagePrivate.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("javaFieldKotlinPropertyJavaPackagePrivateField.kt")
|
||||||
|
public void testJavaFieldKotlinPropertyJavaPackagePrivateField() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/javaFieldKotlinPropertyJavaPackagePrivateField.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("javaProtectedFieldAndKotlinInvisiblePropertyReference.kt")
|
||||||
|
public void testJavaProtectedFieldAndKotlinInvisiblePropertyReference() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/javaProtectedFieldAndKotlinInvisiblePropertyReference.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("kt11167.kt")
|
@TestMetadata("kt11167.kt")
|
||||||
public void testKt11167() throws Exception {
|
public void testKt11167() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user