Fix ClassCastException when data object is being analyzed
#KT-12687 Fixed
This commit is contained in:
@@ -286,7 +286,7 @@ public class OverrideResolver {
|
||||
}
|
||||
}
|
||||
|
||||
private void checkOverridesInAClass(@NotNull ClassDescriptorWithResolutionScopes classDescriptor, @NotNull final KtClassOrObject klass) {
|
||||
private void checkOverridesInAClass(@NotNull ClassDescriptorWithResolutionScopes classDescriptor, @NotNull KtClassOrObject klass) {
|
||||
// Check overrides for internal consistency
|
||||
for (CallableMemberDescriptor member : classDescriptor.getDeclaredCallableMembers()) {
|
||||
checkOverrideForMember(member);
|
||||
@@ -1056,7 +1056,7 @@ public class OverrideResolver {
|
||||
|
||||
@NotNull
|
||||
private static PsiElement findDataModifierForDataClass(@NotNull DeclarationDescriptor dataClass) {
|
||||
KtClass classDeclaration = (KtClass) DescriptorToSourceUtils.getSourceFromDescriptor(dataClass);
|
||||
KtClassOrObject classDeclaration = (KtClassOrObject) DescriptorToSourceUtils.getSourceFromDescriptor(dataClass);
|
||||
if (classDeclaration != null && classDeclaration.getModifierList() != null) {
|
||||
PsiElement modifier = classDeclaration.getModifierList().getModifier(KtTokens.DATA_KEYWORD);
|
||||
if (modifier != null) {
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<!WRONG_MODIFIER_TARGET!>data<!> object Object<!CONSTRUCTOR_IN_OBJECT!>(val x: Int, val y: Int)<!>
|
||||
@@ -0,0 +1,13 @@
|
||||
package
|
||||
|
||||
public data object Object {
|
||||
private constructor Object(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.Int)
|
||||
public final val x: kotlin.Int
|
||||
public final val y: kotlin.Int
|
||||
public final operator /*synthesized*/ fun component1(): kotlin.Int
|
||||
public final operator /*synthesized*/ fun component2(): kotlin.Int
|
||||
public final /*synthesized*/ fun copy(/*0*/ x: kotlin.Int = ..., /*1*/ y: kotlin.Int = ...): Object
|
||||
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
|
||||
}
|
||||
@@ -4164,6 +4164,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("dataObject.kt")
|
||||
public void testDataObject() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/dataClasses/dataObject.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("emptyConstructor.kt")
|
||||
public void testEmptyConstructor() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/dataClasses/emptyConstructor.kt");
|
||||
|
||||
Reference in New Issue
Block a user