Changed naming algorithm of accessor name generation: "isXXX" and "kClass" cases affected
This commit is contained in:
@@ -2758,7 +2758,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
JetType type = bindingContext.getType(expression);
|
||||
assert type != null;
|
||||
|
||||
assert state.getReflectionTypes().getkClass().getTypeConstructor().equals(type.getConstructor())
|
||||
assert state.getReflectionTypes().getTEMP_kClass().getTypeConstructor().equals(type.getConstructor())
|
||||
: "::class expression should be type checked to a KClass: " + type;
|
||||
|
||||
return generateClassLiteralReference(typeMapper, KotlinPackage.single(type.getArguments()).getType());
|
||||
|
||||
@@ -336,7 +336,7 @@ public class JetFlowInformationProvider {
|
||||
}
|
||||
if (!(instruction instanceof WriteValueInstruction)) return;
|
||||
WriteValueInstruction writeValueInstruction = (WriteValueInstruction) instruction;
|
||||
JetElement element = writeValueInstruction.getlValue();
|
||||
JetElement element = writeValueInstruction.getTEMP_lValue();
|
||||
boolean error = checkBackingField(ctxt, element);
|
||||
if (!(element instanceof JetExpression)) return;
|
||||
if (!error) {
|
||||
|
||||
@@ -89,7 +89,7 @@ public class PseudocodeUtil {
|
||||
element = ((ReadValueInstruction) instruction).getElement();
|
||||
}
|
||||
else if (instruction instanceof WriteValueInstruction) {
|
||||
element = ((WriteValueInstruction) instruction).getlValue();
|
||||
element = ((WriteValueInstruction) instruction).getTEMP_lValue();
|
||||
}
|
||||
else if (instruction instanceof VariableDeclarationInstruction) {
|
||||
element = ((VariableDeclarationInstruction) instruction).getVariableDeclarationElement();
|
||||
|
||||
+8
-12
@@ -16,18 +16,14 @@
|
||||
|
||||
package org.jetbrains.kotlin.cfg.pseudocode.instructions.eval
|
||||
|
||||
import org.jetbrains.kotlin.psi.JetElement
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.PseudoValue
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.LexicalScope
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.InstructionWithNext
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.descriptors.VariableDescriptor
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.PseudoValueFactory
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.InstructionVisitor
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.InstructionVisitorWithResult
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.InstructionImpl
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.*
|
||||
import org.jetbrains.kotlin.descriptors.VariableDescriptor
|
||||
import org.jetbrains.kotlin.psi.JetElement
|
||||
import org.jetbrains.kotlin.psi.JetNamedDeclaration
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||
|
||||
public sealed class AccessTarget {
|
||||
public data class Declaration(val descriptor: VariableDescriptor): AccessTarget()
|
||||
@@ -95,7 +91,7 @@ public class WriteValueInstruction(
|
||||
lexicalScope: LexicalScope,
|
||||
target: AccessTarget,
|
||||
receiverValues: Map<PseudoValue, ReceiverValue>,
|
||||
public val lValue: JetElement,
|
||||
public val TEMP_lValue: JetElement,
|
||||
public val rValue: PseudoValue
|
||||
) : AccessValueInstruction(assignment, lexicalScope, target, receiverValues) {
|
||||
override val inputValues: List<PseudoValue>
|
||||
@@ -110,10 +106,10 @@ public class WriteValueInstruction(
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
val lhs = (lValue as? JetNamedDeclaration)?.getName() ?: render(lValue)
|
||||
val lhs = (TEMP_lValue as? JetNamedDeclaration)?.getName() ?: render(TEMP_lValue)
|
||||
return "w($lhs|${inputValues.joinToString(", ")})"
|
||||
}
|
||||
|
||||
override fun createCopy(): InstructionImpl =
|
||||
WriteValueInstruction(element, lexicalScope, target, receiverValues, lValue, rValue)
|
||||
WriteValueInstruction(element, lexicalScope, target, receiverValues, TEMP_lValue, rValue)
|
||||
}
|
||||
|
||||
@@ -136,8 +136,8 @@ public object LightClassUtil {
|
||||
public fun getLightClassAccessorMethods(accessor: JetPropertyAccessor): List<PsiMethod> {
|
||||
val property = accessor.getNonStrictParentOfType<JetProperty>() ?: return emptyList()
|
||||
val wrappers = getPsiMethodWrappers(property, true)
|
||||
return wrappers.filter { wrapper -> (accessor.isGetter && !wrapper.name.startsWith(JvmAbi.SETTER_PREFIX)) ||
|
||||
(accessor.isSetter && wrapper.name.startsWith(JvmAbi.SETTER_PREFIX)) }
|
||||
return wrappers.filter { wrapper -> (accessor.isGetter && !JvmAbi.isSetterName(wrapper.name)) ||
|
||||
(accessor.isSetter && JvmAbi.isSetterName(wrapper.name)) }
|
||||
}
|
||||
|
||||
public fun getLightFieldForCompanionObject(companionObject: JetClassOrObject): PsiField? {
|
||||
@@ -296,11 +296,11 @@ public object LightClassUtil {
|
||||
val additionalAccessors = arrayListOf<PsiMethod>()
|
||||
|
||||
val wrappers = getPsiMethodWrappers(jetDeclaration, true).filter {
|
||||
it.name.startsWith(JvmAbi.GETTER_PREFIX) || it.name.startsWith(JvmAbi.SETTER_PREFIX)
|
||||
JvmAbi.isGetterName(it.name) || JvmAbi.isSetterName(it.name)
|
||||
}
|
||||
|
||||
for (wrapper in wrappers) {
|
||||
if (wrapper.getName().startsWith(JvmAbi.SETTER_PREFIX)) {
|
||||
if (JvmAbi.isSetterName(wrapper.getName())) {
|
||||
if (setterWrapper == null || setterWrapper === specialSetter) {
|
||||
setterWrapper = wrapper
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package a
|
||||
|
||||
interface I {
|
||||
var simpleFoo: Int
|
||||
|
||||
var isSomething1: Boolean
|
||||
var isSomethingNullable: Boolean?
|
||||
var isSomethingNonBoolean: String
|
||||
var isHTML: Boolean
|
||||
var is1: Boolean
|
||||
var `is`: Boolean
|
||||
|
||||
var kClassName: String
|
||||
var URL: String
|
||||
var HTTPProtocol: String
|
||||
|
||||
var issueFlag: Boolean
|
||||
}
|
||||
|
||||
// 1 getSimpleFoo
|
||||
// 1 setSimpleFoo
|
||||
// 1 isSomething1
|
||||
// 1 setSomething1
|
||||
// 1 isSomethingNullable
|
||||
// 1 setSomethingNullable
|
||||
// 1 isSomethingNonBoolean
|
||||
// 1 setSomethingNonBoolean
|
||||
// 1 isHTML
|
||||
// 1 setHTML
|
||||
// 1 is1
|
||||
// 1 set1
|
||||
// 2 getIs
|
||||
// 2 setIs
|
||||
// 1 getKClassName
|
||||
// 1 setKClassName
|
||||
// 1 getURL
|
||||
// 1 setURL
|
||||
// 1 getHTTPProtocol
|
||||
// 1 setHTTPProtocol
|
||||
// 1 getIssueFlag
|
||||
// 1 setIssueFlag
|
||||
@@ -37,6 +37,12 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("accessorNaming.kt")
|
||||
public void testAccessorNaming() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/accessorNaming.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInBytecodeText() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/bytecodeText"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user