KNPE fixed in data class checker together with some ID warnings #KT-9296 Fixed #EA-73584 Fixed
This commit is contained in:
@@ -33,13 +33,13 @@ public class DataClassAnnotationChecker : DeclarationChecker {
|
||||
if (declaration !is JetClassOrObject) return
|
||||
|
||||
if (KotlinBuiltIns.isData(descriptor)) {
|
||||
if (descriptor.getUnsubstitutedPrimaryConstructor() == null && descriptor.getConstructors().isNotEmpty()) {
|
||||
diagnosticHolder.report(Errors.PRIMARY_CONSTRUCTOR_REQUIRED_FOR_DATA_CLASS.on(declaration.getNameIdentifier()));
|
||||
if (descriptor.unsubstitutedPrimaryConstructor == null && descriptor.constructors.isNotEmpty()) {
|
||||
declaration.nameIdentifier?.let { diagnosticHolder.report(Errors.PRIMARY_CONSTRUCTOR_REQUIRED_FOR_DATA_CLASS.on(it)) }
|
||||
}
|
||||
val primaryConstructor = declaration.getPrimaryConstructor()
|
||||
val parameters = primaryConstructor?.valueParameters ?: emptyList()
|
||||
if (parameters.isEmpty()) {
|
||||
diagnosticHolder.report(Errors.DATA_CLASS_WITHOUT_PARAMETERS.on(declaration.nameIdentifier!!))
|
||||
declaration.nameIdentifier?.let { diagnosticHolder.report(Errors.DATA_CLASS_WITHOUT_PARAMETERS.on(it)) }
|
||||
}
|
||||
for (parameter in parameters) {
|
||||
if (parameter.isVarArg) {
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
// See EA-73584
|
||||
data class<!SYNTAX!><!> {
|
||||
|
||||
}
|
||||
|
||||
// See KT-9296
|
||||
<!WRONG_MODIFIER_TARGET!>data<!> interface<!SYNTAX!><!> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package
|
||||
|
||||
@kotlin.data() public final class <no name provided> {
|
||||
public constructor <no name provided>()
|
||||
public final /*synthesized*/ fun copy(): <no name provided>
|
||||
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
|
||||
}
|
||||
|
||||
@kotlin.data() public interface <no name provided> {
|
||||
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
|
||||
}
|
||||
@@ -3342,6 +3342,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("dataClassNoName.kt")
|
||||
public void testDataClassNoName() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/dataClasses/dataClassNoName.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("dataClassVarargParam.kt")
|
||||
public void testDataClassVarargParam() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/dataClasses/dataClassVarargParam.kt");
|
||||
|
||||
Reference in New Issue
Block a user