Check field signature name
This commit is contained in:
+11
@@ -17,6 +17,8 @@
|
|||||||
package org.jetbrains.jet.lang.resolve.java.kotlinSignature;
|
package org.jetbrains.jet.lang.resolve.java.kotlinSignature;
|
||||||
|
|
||||||
import com.intellij.openapi.project.Project;
|
import com.intellij.openapi.project.Project;
|
||||||
|
import com.intellij.psi.PsiNamedElement;
|
||||||
|
import com.intellij.util.containers.ComparatorUtil;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor;
|
import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptorImpl;
|
import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptorImpl;
|
||||||
@@ -48,6 +50,7 @@ public class AlternativeFieldSignatureData extends ElementAlternativeSignatureDa
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
checkForSyntaxErrors(altPropertyDeclaration);
|
checkForSyntaxErrors(altPropertyDeclaration);
|
||||||
|
checkEqualNames(altPropertyDeclaration, field);
|
||||||
altReturnType = computeReturnType(originalReturnType, altPropertyDeclaration.getTypeRef(),
|
altReturnType = computeReturnType(originalReturnType, altPropertyDeclaration.getTypeRef(),
|
||||||
new HashMap<TypeParameterDescriptor, TypeParameterDescriptorImpl>());
|
new HashMap<TypeParameterDescriptor, TypeParameterDescriptorImpl>());
|
||||||
}
|
}
|
||||||
@@ -66,4 +69,12 @@ public class AlternativeFieldSignatureData extends ElementAlternativeSignatureDa
|
|||||||
public String getSignature() {
|
public String getSignature() {
|
||||||
return field.getPsiField().getText();
|
return field.getPsiField().getText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void checkEqualNames(PsiNamedElement namedElement, PsiFieldWrapper fieldWrapper) {
|
||||||
|
if (!ComparatorUtil.equalsNullable(fieldWrapper.getName(), namedElement.getName())) {
|
||||||
|
throw new AlternativeSignatureMismatchException(
|
||||||
|
"Field name mismatch, original: %s, alternative: %s",
|
||||||
|
fieldWrapper.getName(), namedElement.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package test;
|
||||||
|
|
||||||
|
import jet.runtime.typeinfo.KotlinSignature;
|
||||||
|
|
||||||
|
import java.lang.String;
|
||||||
|
|
||||||
|
public class WrongFieldName {
|
||||||
|
@KotlinSignature("val bar: String")
|
||||||
|
public String foo;
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
public open class WrongFieldName : Object() {
|
||||||
|
public val foo : String? = ""
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
namespace test
|
||||||
|
|
||||||
|
public open class test.WrongFieldName : java.lang.Object {
|
||||||
|
public final /*constructor*/ fun <init>(): test.WrongFieldName
|
||||||
|
public final val foo: jet.String?
|
||||||
|
}
|
||||||
@@ -338,6 +338,11 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest {
|
|||||||
doTest("compiler/testData/loadJava/kotlinSignature/error/VarargReplacedWithNotVararg.java");
|
doTest("compiler/testData/loadJava/kotlinSignature/error/VarargReplacedWithNotVararg.java");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("WrongFieldName.java")
|
||||||
|
public void testWrongFieldName() throws Exception {
|
||||||
|
doTest("compiler/testData/loadJava/kotlinSignature/error/WrongFieldName.java");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("WrongMethodName.java")
|
@TestMetadata("WrongMethodName.java")
|
||||||
public void testWrongMethodName() throws Exception {
|
public void testWrongMethodName() throws Exception {
|
||||||
doTest("compiler/testData/loadJava/kotlinSignature/error/WrongMethodName.java");
|
doTest("compiler/testData/loadJava/kotlinSignature/error/WrongMethodName.java");
|
||||||
|
|||||||
+5
@@ -1223,6 +1223,11 @@ public class LazyResolveNamespaceComparingTestGenerated extends AbstractLazyReso
|
|||||||
doTestSinglePackage("compiler/testData/loadJava/kotlinSignature/error/VarargReplacedWithNotVararg.kt");
|
doTestSinglePackage("compiler/testData/loadJava/kotlinSignature/error/VarargReplacedWithNotVararg.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("WrongFieldName.kt")
|
||||||
|
public void testWrongFieldName() throws Exception {
|
||||||
|
doTestSinglePackage("compiler/testData/loadJava/kotlinSignature/error/WrongFieldName.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("WrongMethodName.kt")
|
@TestMetadata("WrongMethodName.kt")
|
||||||
public void testWrongMethodName() throws Exception {
|
public void testWrongMethodName() throws Exception {
|
||||||
doTestSinglePackage("compiler/testData/loadJava/kotlinSignature/error/WrongMethodName.kt");
|
doTestSinglePackage("compiler/testData/loadJava/kotlinSignature/error/WrongMethodName.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user