Add a warning for a user-defined entries property call
^KT-53153
This commit is contained in:
committed by
Space Team
parent
695a538529
commit
989fc886e1
+30
@@ -10319,11 +10319,41 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
|||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/enum/entries"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/enum/entries"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("entriesPropertyAsExtensionClash.kt")
|
||||||
|
public void testEntriesPropertyAsExtensionClash() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/enum/entries/entriesPropertyAsExtensionClash.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("entriesPropertyImportedClash.kt")
|
||||||
|
public void testEntriesPropertyImportedClash() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/enum/entries/entriesPropertyImportedClash.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("entriesPropertyInCompanionClash.kt")
|
||||||
|
public void testEntriesPropertyInCompanionClash() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/enum/entries/entriesPropertyInCompanionClash.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("entriesPropertyWithJvmStaticClash.kt")
|
||||||
|
public void testEntriesPropertyWithJvmStaticClash() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/enum/entries/entriesPropertyWithJvmStaticClash.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("enumEntriesAmbiguity.kt")
|
@TestMetadata("enumEntriesAmbiguity.kt")
|
||||||
public void testEnumEntriesAmbiguity() throws Exception {
|
public void testEnumEntriesAmbiguity() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/enum/entries/enumEntriesAmbiguity.kt");
|
runTest("compiler/testData/diagnostics/tests/enum/entries/enumEntriesAmbiguity.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("genericEntriesPropertyClash.kt")
|
||||||
|
public void testGenericEntriesPropertyClash() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/enum/entries/genericEntriesPropertyClash.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
|
|||||||
+30
@@ -10325,11 +10325,41 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
|||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/enum/entries"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/enum/entries"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("entriesPropertyAsExtensionClash.kt")
|
||||||
|
public void testEntriesPropertyAsExtensionClash() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/enum/entries/entriesPropertyAsExtensionClash.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("entriesPropertyImportedClash.kt")
|
||||||
|
public void testEntriesPropertyImportedClash() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/enum/entries/entriesPropertyImportedClash.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("entriesPropertyInCompanionClash.kt")
|
||||||
|
public void testEntriesPropertyInCompanionClash() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/enum/entries/entriesPropertyInCompanionClash.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("entriesPropertyWithJvmStaticClash.kt")
|
||||||
|
public void testEntriesPropertyWithJvmStaticClash() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/enum/entries/entriesPropertyWithJvmStaticClash.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("enumEntriesAmbiguity.kt")
|
@TestMetadata("enumEntriesAmbiguity.kt")
|
||||||
public void testEnumEntriesAmbiguity() throws Exception {
|
public void testEnumEntriesAmbiguity() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/enum/entries/enumEntriesAmbiguity.kt");
|
runTest("compiler/testData/diagnostics/tests/enum/entries/enumEntriesAmbiguity.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("genericEntriesPropertyClash.kt")
|
||||||
|
public void testGenericEntriesPropertyClash() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/enum/entries/genericEntriesPropertyClash.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
|
|||||||
+30
@@ -10319,11 +10319,41 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
|||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/enum/entries"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/enum/entries"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("entriesPropertyAsExtensionClash.kt")
|
||||||
|
public void testEntriesPropertyAsExtensionClash() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/enum/entries/entriesPropertyAsExtensionClash.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("entriesPropertyImportedClash.kt")
|
||||||
|
public void testEntriesPropertyImportedClash() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/enum/entries/entriesPropertyImportedClash.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("entriesPropertyInCompanionClash.kt")
|
||||||
|
public void testEntriesPropertyInCompanionClash() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/enum/entries/entriesPropertyInCompanionClash.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("entriesPropertyWithJvmStaticClash.kt")
|
||||||
|
public void testEntriesPropertyWithJvmStaticClash() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/enum/entries/entriesPropertyWithJvmStaticClash.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("enumEntriesAmbiguity.kt")
|
@TestMetadata("enumEntriesAmbiguity.kt")
|
||||||
public void testEnumEntriesAmbiguity() throws Exception {
|
public void testEnumEntriesAmbiguity() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/enum/entries/enumEntriesAmbiguity.kt");
|
runTest("compiler/testData/diagnostics/tests/enum/entries/enumEntriesAmbiguity.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("genericEntriesPropertyClash.kt")
|
||||||
|
public void testGenericEntriesPropertyClash() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/enum/entries/genericEntriesPropertyClash.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
|
|||||||
@@ -142,6 +142,8 @@ public interface Errors {
|
|||||||
|
|
||||||
DiagnosticFactory1<PsiElement, PropertyDescriptor> DEPRECATED_ACCESS_TO_ENUM_COMPANION_PROPERTY = DiagnosticFactory1.create(WARNING);
|
DiagnosticFactory1<PsiElement, PropertyDescriptor> DEPRECATED_ACCESS_TO_ENUM_COMPANION_PROPERTY = DiagnosticFactory1.create(WARNING);
|
||||||
|
|
||||||
|
DiagnosticFactory0<PsiElement> DEPRECATED_ACCESS_TO_ENUM_ENTRY_COMPANION_PROPERTY = DiagnosticFactory0.create(WARNING);
|
||||||
|
|
||||||
DiagnosticFactory2<PsiElement, PropertyDescriptor, ClassDescriptor> DEPRECATED_RESOLVE_WITH_AMBIGUOUS_ENUM_ENTRY = DiagnosticFactory2.create(WARNING);
|
DiagnosticFactory2<PsiElement, PropertyDescriptor, ClassDescriptor> DEPRECATED_RESOLVE_WITH_AMBIGUOUS_ENUM_ENTRY = DiagnosticFactory2.create(WARNING);
|
||||||
|
|
||||||
DiagnosticFactory1<PsiElement, ConstructorDescriptor> PROTECTED_CONSTRUCTOR_NOT_IN_SUPER_CALL = DiagnosticFactory1.create(ERROR);
|
DiagnosticFactory1<PsiElement, ConstructorDescriptor> PROTECTED_CONSTRUCTOR_NOT_IN_SUPER_CALL = DiagnosticFactory1.create(ERROR);
|
||||||
|
|||||||
+1
@@ -73,6 +73,7 @@ public class DefaultErrorMessages {
|
|||||||
MAP.put(INVISIBLE_MEMBER, "Cannot access ''{0}'': it is {1} in {2}", NAME, VISIBILITY, NAME_OF_CONTAINING_DECLARATION_OR_FILE);
|
MAP.put(INVISIBLE_MEMBER, "Cannot access ''{0}'': it is {1} in {2}", NAME, VISIBILITY, NAME_OF_CONTAINING_DECLARATION_OR_FILE);
|
||||||
MAP.put(DEPRECATED_ACCESS_BY_SHORT_NAME, "Access to this type by short name is deprecated, and soon is going to be removed. Please, add explicit qualifier or import", NAME);
|
MAP.put(DEPRECATED_ACCESS_BY_SHORT_NAME, "Access to this type by short name is deprecated, and soon is going to be removed. Please, add explicit qualifier or import", NAME);
|
||||||
MAP.put(DEPRECATED_ACCESS_TO_ENUM_COMPANION_PROPERTY, "Ambiguous access to companion''s property ''{0}'' in enum is deprecated. Please, add explicit Companion qualifier to the class name", NAME);
|
MAP.put(DEPRECATED_ACCESS_TO_ENUM_COMPANION_PROPERTY, "Ambiguous access to companion''s property ''{0}'' in enum is deprecated. Please, add explicit Companion qualifier to the class name", NAME);
|
||||||
|
MAP.put(DEPRECATED_ACCESS_TO_ENUM_ENTRY_COMPANION_PROPERTY, "Ambiguous access to companion''s property 'entries' in enum is deprecated. Please, add explicit Companion qualifier to the class name");
|
||||||
MAP.put(DEPRECATED_RESOLVE_WITH_AMBIGUOUS_ENUM_ENTRY, "Ambiguous access to property ''{0}'' is deprecated because similar enum entry ''{1}'' is available. Please add explicit named import or use fully qualified name", FQ_NAME, FQ_NAME);
|
MAP.put(DEPRECATED_RESOLVE_WITH_AMBIGUOUS_ENUM_ENTRY, "Ambiguous access to property ''{0}'' is deprecated because similar enum entry ''{1}'' is available. Please add explicit named import or use fully qualified name", FQ_NAME, FQ_NAME);
|
||||||
|
|
||||||
MAP.put(PROTECTED_CONSTRUCTOR_NOT_IN_SUPER_CALL, "Protected constructor ''{0}'' from other classes can only be used in super-call", Renderers.SHORT_NAMES_IN_TYPES);
|
MAP.put(PROTECTED_CONSTRUCTOR_NOT_IN_SUPER_CALL, "Protected constructor ''{0}'' from other classes can only be used in super-call", Renderers.SHORT_NAMES_IN_TYPES);
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ private val DEFAULT_CALL_CHECKERS = listOf(
|
|||||||
NewSchemeOfIntegerOperatorResolutionChecker, EnumEntryVsCompanionPriorityCallChecker, CompanionInParenthesesLHSCallChecker,
|
NewSchemeOfIntegerOperatorResolutionChecker, EnumEntryVsCompanionPriorityCallChecker, CompanionInParenthesesLHSCallChecker,
|
||||||
ResolutionToPrivateConstructorOfSealedClassChecker, EqualityCallChecker, UnsupportedUntilOperatorChecker,
|
ResolutionToPrivateConstructorOfSealedClassChecker, EqualityCallChecker, UnsupportedUntilOperatorChecker,
|
||||||
BuilderInferenceAssignmentChecker, IncorrectCapturedApproximationCallChecker, CompanionIncorrectlyUnboundedWhenUsedAsLHSCallChecker,
|
BuilderInferenceAssignmentChecker, IncorrectCapturedApproximationCallChecker, CompanionIncorrectlyUnboundedWhenUsedAsLHSCallChecker,
|
||||||
|
CustomEnumEntriesMigrationCallChecker,
|
||||||
)
|
)
|
||||||
private val DEFAULT_TYPE_CHECKERS = emptyList<AdditionalTypeChecker>()
|
private val DEFAULT_TYPE_CHECKERS = emptyList<AdditionalTypeChecker>()
|
||||||
private val DEFAULT_CLASSIFIER_USAGE_CHECKERS = listOf(
|
private val DEFAULT_CLASSIFIER_USAGE_CHECKERS = listOf(
|
||||||
|
|||||||
+46
@@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* 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.resolve.calls.checkers
|
||||||
|
|
||||||
|
import com.intellij.psi.PsiElement
|
||||||
|
import org.jetbrains.kotlin.builtins.StandardNames
|
||||||
|
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||||
|
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||||
|
import org.jetbrains.kotlin.diagnostics.Errors
|
||||||
|
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||||
|
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||||
|
import org.jetbrains.kotlin.resolve.descriptorUtil.isCompanionObject
|
||||||
|
import org.jetbrains.kotlin.resolve.scopes.receivers.ClassValueReceiver
|
||||||
|
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||||
|
|
||||||
|
object CustomEnumEntriesMigrationCallChecker : CallChecker {
|
||||||
|
override fun check(resolvedCall: ResolvedCall<*>, reportOn: PsiElement, context: CallCheckerContext) {
|
||||||
|
val descriptor = resolvedCall.resultingDescriptor
|
||||||
|
if (descriptor !is PropertyDescriptor) return
|
||||||
|
if (descriptor.name != StandardNames.ENUM_ENTRIES) return
|
||||||
|
|
||||||
|
if (resolvedCall.isExtensionWithEnumClassQualifier() ||
|
||||||
|
resolvedCall.isCallViaCompanionOnEnumClassQualifier(descriptor)
|
||||||
|
) {
|
||||||
|
context.trace.report(Errors.DEPRECATED_ACCESS_TO_ENUM_ENTRY_COMPANION_PROPERTY.on(reportOn))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun ResolvedCall<*>.isExtensionWithEnumClassQualifier(): Boolean {
|
||||||
|
val receiver = extensionReceiver ?: return false
|
||||||
|
return receiver is ClassValueReceiver && DescriptorUtils.isEnumClass(receiver.classQualifier.descriptor)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun ResolvedCall<*>.isCallViaCompanionOnEnumClassQualifier(descriptor: PropertyDescriptor): Boolean {
|
||||||
|
val containingDeclaration = descriptor.containingDeclaration
|
||||||
|
if (!containingDeclaration.isCompanionObject()) return false
|
||||||
|
|
||||||
|
val grandParent = containingDeclaration.containingDeclaration ?: return false
|
||||||
|
if (grandParent !is ClassDescriptor || !DescriptorUtils.isEnumClass(grandParent)) return false
|
||||||
|
|
||||||
|
return dispatchReceiver.isQualifierFor(grandParent)
|
||||||
|
}
|
||||||
|
}
|
||||||
+6
-6
@@ -43,10 +43,10 @@ object EnumEntryVsCompanionPriorityCallChecker : CallChecker {
|
|||||||
val foundDescriptor = unsubstitutedMemberScope.getContributedClassifier(name, NoLookupLocation.FOR_ALREADY_TRACKED)
|
val foundDescriptor = unsubstitutedMemberScope.getContributedClassifier(name, NoLookupLocation.FOR_ALREADY_TRACKED)
|
||||||
return foundDescriptor is ClassDescriptor && foundDescriptor.kind == ClassKind.ENUM_ENTRY
|
return foundDescriptor is ClassDescriptor && foundDescriptor.kind == ClassKind.ENUM_ENTRY
|
||||||
}
|
}
|
||||||
|
}
|
||||||
private fun ReceiverValue?.isQualifierFor(classDescriptor: ClassDescriptor): Boolean {
|
|
||||||
if (this !is ClassValueReceiver) return false
|
internal fun ReceiverValue?.isQualifierFor(classDescriptor: ClassDescriptor): Boolean {
|
||||||
val thisClass = this.classQualifier.descriptor as? ClassDescriptor ?: return false
|
if (this !is ClassValueReceiver) return false
|
||||||
return thisClass.typeConstructor == classDescriptor.typeConstructor
|
val thisClass = this.classQualifier.descriptor as? ClassDescriptor ?: return false
|
||||||
}
|
return thisClass.typeConstructor == classDescriptor.typeConstructor
|
||||||
}
|
}
|
||||||
|
|||||||
+28
@@ -0,0 +1,28 @@
|
|||||||
|
// !LANGUAGE: -EnumEntries
|
||||||
|
|
||||||
|
package pckg
|
||||||
|
|
||||||
|
enum class A {
|
||||||
|
;
|
||||||
|
|
||||||
|
companion object
|
||||||
|
}
|
||||||
|
|
||||||
|
val A.Companion.entries: Int get() = 0
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
A.entries
|
||||||
|
A.Companion.entries
|
||||||
|
|
||||||
|
with(A) {
|
||||||
|
this.entries
|
||||||
|
entries
|
||||||
|
}
|
||||||
|
|
||||||
|
with(A.Companion) {
|
||||||
|
entries
|
||||||
|
}
|
||||||
|
|
||||||
|
val aCompanion = A.Companion
|
||||||
|
aCompanion.entries
|
||||||
|
}
|
||||||
+28
@@ -0,0 +1,28 @@
|
|||||||
|
// !LANGUAGE: -EnumEntries
|
||||||
|
|
||||||
|
package pckg
|
||||||
|
|
||||||
|
enum class A {
|
||||||
|
;
|
||||||
|
|
||||||
|
companion object
|
||||||
|
}
|
||||||
|
|
||||||
|
val A.Companion.entries: Int get() = 0
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
A.<!DEBUG_INFO_CALL("fqName: pckg.entries; typeCall: variable"), DEPRECATED_ACCESS_TO_ENUM_ENTRY_COMPANION_PROPERTY!>entries<!>
|
||||||
|
A.Companion.<!DEBUG_INFO_CALL("fqName: pckg.entries; typeCall: variable")!>entries<!>
|
||||||
|
|
||||||
|
with(A) {
|
||||||
|
this.entries
|
||||||
|
<!DEBUG_INFO_CALL("fqName: pckg.entries; typeCall: variable")!>entries<!>
|
||||||
|
}
|
||||||
|
|
||||||
|
with(A.Companion) {
|
||||||
|
<!DEBUG_INFO_CALL("fqName: pckg.entries; typeCall: variable")!>entries<!>
|
||||||
|
}
|
||||||
|
|
||||||
|
val aCompanion = A.Companion
|
||||||
|
aCompanion.<!DEBUG_INFO_CALL("fqName: pckg.entries; typeCall: variable")!>entries<!>
|
||||||
|
}
|
||||||
+30
@@ -0,0 +1,30 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
package pckg {
|
||||||
|
public val pckg.A.Companion.entries: kotlin.Int
|
||||||
|
public fun test(): kotlin.Unit
|
||||||
|
|
||||||
|
public final enum class A : kotlin.Enum<pckg.A> {
|
||||||
|
private constructor A()
|
||||||
|
@kotlin.internal.IntrinsicConstEvaluation public final override /*1*/ /*fake_override*/ val name: kotlin.String
|
||||||
|
public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int
|
||||||
|
protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any
|
||||||
|
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: pckg.A): kotlin.Int
|
||||||
|
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
protected/*protected and package*/ final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun finalize(): kotlin.Unit
|
||||||
|
public final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun getDeclaringClass(): java.lang.Class<pckg.A!>!
|
||||||
|
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
|
public companion object Companion {
|
||||||
|
private constructor Companion()
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
// Static members
|
||||||
|
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): pckg.A
|
||||||
|
public final /*synthesized*/ fun values(): kotlin.Array<pckg.A>
|
||||||
|
}
|
||||||
|
}
|
||||||
+21
@@ -0,0 +1,21 @@
|
|||||||
|
// !LANGUAGE: -EnumEntries
|
||||||
|
|
||||||
|
package foo
|
||||||
|
|
||||||
|
import foo.A.Companion.entries
|
||||||
|
|
||||||
|
enum class A {
|
||||||
|
;
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
val entries = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
A.entries
|
||||||
|
|
||||||
|
with(A) {
|
||||||
|
entries
|
||||||
|
}
|
||||||
|
}
|
||||||
+21
@@ -0,0 +1,21 @@
|
|||||||
|
// !LANGUAGE: -EnumEntries
|
||||||
|
|
||||||
|
package foo
|
||||||
|
|
||||||
|
import foo.A.Companion.entries
|
||||||
|
|
||||||
|
enum class A {
|
||||||
|
;
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
val entries = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
A.<!DEBUG_INFO_CALL("fqName: foo.A.Companion.entries; typeCall: variable"), DEPRECATED_ACCESS_TO_ENUM_ENTRY_COMPANION_PROPERTY!>entries<!>
|
||||||
|
|
||||||
|
with(A) {
|
||||||
|
<!DEBUG_INFO_CALL("fqName: foo.A.Companion.entries; typeCall: variable")!>entries<!>
|
||||||
|
}
|
||||||
|
}
|
||||||
+30
@@ -0,0 +1,30 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
package foo {
|
||||||
|
public fun test(): kotlin.Unit
|
||||||
|
|
||||||
|
public final enum class A : kotlin.Enum<foo.A> {
|
||||||
|
private constructor A()
|
||||||
|
@kotlin.internal.IntrinsicConstEvaluation public final override /*1*/ /*fake_override*/ val name: kotlin.String
|
||||||
|
public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int
|
||||||
|
protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any
|
||||||
|
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: foo.A): kotlin.Int
|
||||||
|
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
protected/*protected and package*/ final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun finalize(): kotlin.Unit
|
||||||
|
public final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun getDeclaringClass(): java.lang.Class<foo.A!>!
|
||||||
|
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
|
public companion object Companion {
|
||||||
|
private constructor Companion()
|
||||||
|
public final val entries: kotlin.Int = 0
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
// Static members
|
||||||
|
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): foo.A
|
||||||
|
public final /*synthesized*/ fun values(): kotlin.Array<foo.A>
|
||||||
|
}
|
||||||
|
}
|
||||||
+27
@@ -0,0 +1,27 @@
|
|||||||
|
// !LANGUAGE: -EnumEntries
|
||||||
|
|
||||||
|
enum class A {
|
||||||
|
;
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
val entries = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
A.entries
|
||||||
|
A.Companion.entries
|
||||||
|
|
||||||
|
<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>with<!>(A) {
|
||||||
|
entries
|
||||||
|
this.entries
|
||||||
|
<!UNRESOLVED_REFERENCE!>values<!>() // to be sure that we don't resolve into synthetic 'values'
|
||||||
|
}
|
||||||
|
|
||||||
|
with(A.Companion) {
|
||||||
|
entries
|
||||||
|
}
|
||||||
|
|
||||||
|
val aCompanion = A.Companion
|
||||||
|
aCompanion.entries
|
||||||
|
}
|
||||||
+27
@@ -0,0 +1,27 @@
|
|||||||
|
// !LANGUAGE: -EnumEntries
|
||||||
|
|
||||||
|
enum class A {
|
||||||
|
;
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
val entries = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
A.<!DEBUG_INFO_CALL("fqName: A.Companion.entries; typeCall: variable"), DEPRECATED_ACCESS_TO_ENUM_ENTRY_COMPANION_PROPERTY!>entries<!>
|
||||||
|
A.Companion.<!DEBUG_INFO_CALL("fqName: A.Companion.entries; typeCall: variable")!>entries<!>
|
||||||
|
|
||||||
|
with(A) {
|
||||||
|
<!DEBUG_INFO_CALL("fqName: A.Companion.entries; typeCall: variable")!>entries<!>
|
||||||
|
this.entries
|
||||||
|
<!UNRESOLVED_REFERENCE!>values<!>() // to be sure that we don't resolve into synthetic 'values'
|
||||||
|
}
|
||||||
|
|
||||||
|
with(A.Companion) {
|
||||||
|
<!DEBUG_INFO_CALL("fqName: A.Companion.entries; typeCall: variable")!>entries<!>
|
||||||
|
}
|
||||||
|
|
||||||
|
val aCompanion = A.Companion
|
||||||
|
aCompanion.<!DEBUG_INFO_CALL("fqName: A.Companion.entries; typeCall: variable")!>entries<!>
|
||||||
|
}
|
||||||
+28
@@ -0,0 +1,28 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public fun test(): kotlin.Unit
|
||||||
|
|
||||||
|
public final enum class A : kotlin.Enum<A> {
|
||||||
|
private constructor A()
|
||||||
|
@kotlin.internal.IntrinsicConstEvaluation public final override /*1*/ /*fake_override*/ val name: kotlin.String
|
||||||
|
public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int
|
||||||
|
protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any
|
||||||
|
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: A): kotlin.Int
|
||||||
|
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
protected/*protected and package*/ final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun finalize(): kotlin.Unit
|
||||||
|
public final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun getDeclaringClass(): java.lang.Class<A!>!
|
||||||
|
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
|
public companion object Companion {
|
||||||
|
private constructor Companion()
|
||||||
|
public final val entries: kotlin.Int = 0
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
// Static members
|
||||||
|
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): A
|
||||||
|
public final /*synthesized*/ fun values(): kotlin.Array<A>
|
||||||
|
}
|
||||||
+21
@@ -0,0 +1,21 @@
|
|||||||
|
// !LANGUAGE: -EnumEntries
|
||||||
|
// WITH_STDLIB
|
||||||
|
|
||||||
|
enum class A {
|
||||||
|
;
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
@JvmStatic
|
||||||
|
val entries = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
A.<!OPT_IN_USAGE_ERROR!>entries<!>
|
||||||
|
|
||||||
|
with(A) {
|
||||||
|
entries
|
||||||
|
}
|
||||||
|
|
||||||
|
A.Companion.entries
|
||||||
|
}
|
||||||
+21
@@ -0,0 +1,21 @@
|
|||||||
|
// !LANGUAGE: -EnumEntries
|
||||||
|
// WITH_STDLIB
|
||||||
|
|
||||||
|
enum class A {
|
||||||
|
;
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
@JvmStatic
|
||||||
|
val entries = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
A.<!DEBUG_INFO_CALL("fqName: A.Companion.entries; typeCall: variable"), DEPRECATED_ACCESS_TO_ENUM_ENTRY_COMPANION_PROPERTY!>entries<!>
|
||||||
|
|
||||||
|
with(A) {
|
||||||
|
<!DEBUG_INFO_CALL("fqName: A.Companion.entries; typeCall: variable")!>entries<!>
|
||||||
|
}
|
||||||
|
|
||||||
|
A.Companion.<!DEBUG_INFO_CALL("fqName: A.Companion.entries; typeCall: variable")!>entries<!>
|
||||||
|
}
|
||||||
+29
@@ -0,0 +1,29 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public fun test(): kotlin.Unit
|
||||||
|
|
||||||
|
public final enum class A : kotlin.Enum<A> {
|
||||||
|
private constructor A()
|
||||||
|
@kotlin.internal.IntrinsicConstEvaluation public final override /*1*/ /*fake_override*/ val name: kotlin.String
|
||||||
|
public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int
|
||||||
|
protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any
|
||||||
|
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: A): kotlin.Int
|
||||||
|
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
protected/*protected and package*/ final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun finalize(): kotlin.Unit
|
||||||
|
public final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun getDeclaringClass(): java.lang.Class<A!>!
|
||||||
|
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
|
public companion object Companion {
|
||||||
|
private constructor Companion()
|
||||||
|
@kotlin.jvm.JvmStatic public final val entries: kotlin.Int = 0
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
// Static members
|
||||||
|
public final /*synthesized*/ val entries: kotlin.enums.EnumEntries<A>
|
||||||
|
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): A
|
||||||
|
public final /*synthesized*/ fun values(): kotlin.Array<A>
|
||||||
|
}
|
||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
// !LANGUAGE: -EnumEntries
|
||||||
|
|
||||||
|
package pckg
|
||||||
|
|
||||||
|
enum class A {
|
||||||
|
;
|
||||||
|
|
||||||
|
companion object
|
||||||
|
}
|
||||||
|
|
||||||
|
val <T> T.entries: Int get() = 0
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
A.entries
|
||||||
|
A.Companion.entries
|
||||||
|
}
|
||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
// !LANGUAGE: -EnumEntries
|
||||||
|
|
||||||
|
package pckg
|
||||||
|
|
||||||
|
enum class A {
|
||||||
|
;
|
||||||
|
|
||||||
|
companion object
|
||||||
|
}
|
||||||
|
|
||||||
|
val <T> T.entries: Int get() = 0
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
A.<!DEBUG_INFO_CALL("fqName: pckg.entries; typeCall: variable"), DEPRECATED_ACCESS_TO_ENUM_ENTRY_COMPANION_PROPERTY!>entries<!>
|
||||||
|
A.Companion.<!DEBUG_INFO_CALL("fqName: pckg.entries; typeCall: variable")!>entries<!>
|
||||||
|
}
|
||||||
+30
@@ -0,0 +1,30 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
package pckg {
|
||||||
|
public val </*0*/ T> T.entries: kotlin.Int
|
||||||
|
public fun test(): kotlin.Unit
|
||||||
|
|
||||||
|
public final enum class A : kotlin.Enum<pckg.A> {
|
||||||
|
private constructor A()
|
||||||
|
@kotlin.internal.IntrinsicConstEvaluation public final override /*1*/ /*fake_override*/ val name: kotlin.String
|
||||||
|
public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int
|
||||||
|
protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any
|
||||||
|
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: pckg.A): kotlin.Int
|
||||||
|
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
protected/*protected and package*/ final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun finalize(): kotlin.Unit
|
||||||
|
public final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun getDeclaringClass(): java.lang.Class<pckg.A!>!
|
||||||
|
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
|
public companion object Companion {
|
||||||
|
private constructor Companion()
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
// Static members
|
||||||
|
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): pckg.A
|
||||||
|
public final /*synthesized*/ fun values(): kotlin.Array<pckg.A>
|
||||||
|
}
|
||||||
|
}
|
||||||
Generated
+30
@@ -10325,11 +10325,41 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
|||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/enum/entries"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/enum/entries"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("entriesPropertyAsExtensionClash.kt")
|
||||||
|
public void testEntriesPropertyAsExtensionClash() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/enum/entries/entriesPropertyAsExtensionClash.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("entriesPropertyImportedClash.kt")
|
||||||
|
public void testEntriesPropertyImportedClash() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/enum/entries/entriesPropertyImportedClash.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("entriesPropertyInCompanionClash.kt")
|
||||||
|
public void testEntriesPropertyInCompanionClash() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/enum/entries/entriesPropertyInCompanionClash.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("entriesPropertyWithJvmStaticClash.kt")
|
||||||
|
public void testEntriesPropertyWithJvmStaticClash() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/enum/entries/entriesPropertyWithJvmStaticClash.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("enumEntriesAmbiguity.kt")
|
@TestMetadata("enumEntriesAmbiguity.kt")
|
||||||
public void testEnumEntriesAmbiguity() throws Exception {
|
public void testEnumEntriesAmbiguity() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/enum/entries/enumEntriesAmbiguity.kt");
|
runTest("compiler/testData/diagnostics/tests/enum/entries/enumEntriesAmbiguity.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("genericEntriesPropertyClash.kt")
|
||||||
|
public void testGenericEntriesPropertyClash() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/enum/entries/genericEntriesPropertyClash.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
|
|||||||
Reference in New Issue
Block a user