Don't rename class property with JvmField annotation, report clashing
This commit is contained in:
@@ -25,6 +25,7 @@ import org.jetbrains.kotlin.codegen.state.JetTypeMapper;
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor;
|
||||
import org.jetbrains.kotlin.resolve.jvm.annotations.AnnotationsPackage;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -64,7 +65,9 @@ public abstract class FieldOwnerContext<T extends DeclarationDescriptor> extends
|
||||
String actualName = descriptor2Name.get(descriptor);
|
||||
if (actualName != null) return actualName;
|
||||
|
||||
String newName = descriptor2Name.isEmpty() ? defaultPropertyName : defaultPropertyName + "$" + descriptor2Name.size();
|
||||
String newName = descriptor2Name.isEmpty() || AnnotationsPackage.hasJvmFieldAnnotation(descriptor)
|
||||
? defaultPropertyName
|
||||
: defaultPropertyName + "$" + descriptor2Name.size();
|
||||
descriptor2Name.put(descriptor, newName);
|
||||
return newName;
|
||||
}
|
||||
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
class A {
|
||||
|
||||
<!CONFLICTING_JVM_DECLARATIONS!>@JvmField val clash<!> = 1;
|
||||
|
||||
companion object {
|
||||
<!CONFLICTING_JVM_DECLARATIONS!>val clash<!> = 1;
|
||||
}
|
||||
}
|
||||
compiler/testData/diagnostics/testsWithStdLib/annotations/jvmField/clashWithCompanionObjectField.txt
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
package
|
||||
|
||||
public final class A {
|
||||
public constructor A()
|
||||
@kotlin.jvm.JvmField() public final val clash: kotlin.Int = 1
|
||||
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 companion object Companion {
|
||||
private constructor Companion()
|
||||
public final val clash: kotlin.Int = 1
|
||||
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
|
||||
}
|
||||
}
|
||||
+6
@@ -330,6 +330,12 @@ public class JetDiagnosticsTestWithStdLibGenerated extends AbstractJetDiagnostic
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmField"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("clashWithCompanionObjectField.kt")
|
||||
public void testClashWithCompanionObjectField() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmField/clashWithCompanionObjectField.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("inMultiFileFacade.kt")
|
||||
public void testInMultiFileFacade() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmField/inMultiFileFacade.kt");
|
||||
|
||||
Reference in New Issue
Block a user