Always generate getter and setter
This commit is contained in:
@@ -120,7 +120,8 @@ public class PropertyCodegen extends GenerationStateAware {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void generateGetter(JetNamedDeclaration p, PropertyDescriptor propertyDescriptor, JetPropertyAccessor getter) {
|
private void generateGetter(JetNamedDeclaration p, PropertyDescriptor propertyDescriptor, JetPropertyAccessor getter) {
|
||||||
if (getter != null && getter.getBodyExpression() != null || isExternallyAccessible(propertyDescriptor)) {
|
//TODO: Now it's not enough information to properly resolve property from bytecode without generated getter and setter
|
||||||
|
//if (getter != null && getter.getBodyExpression() != null || isExternallyAccessible(propertyDescriptor)) {
|
||||||
JvmPropertyAccessorSignature signature = typeMapper.mapGetterSignature(propertyDescriptor, kind);
|
JvmPropertyAccessorSignature signature = typeMapper.mapGetterSignature(propertyDescriptor, kind);
|
||||||
PropertyGetterDescriptor getterDescriptor = propertyDescriptor.getGetter();
|
PropertyGetterDescriptor getterDescriptor = propertyDescriptor.getGetter();
|
||||||
getterDescriptor = getterDescriptor != null ? getterDescriptor : DescriptorResolver.createDefaultGetter(propertyDescriptor);
|
getterDescriptor = getterDescriptor != null ? getterDescriptor : DescriptorResolver.createDefaultGetter(propertyDescriptor);
|
||||||
@@ -129,12 +130,13 @@ public class PropertyCodegen extends GenerationStateAware {
|
|||||||
true,
|
true,
|
||||||
signature.getPropertyTypeKotlinSignature(),
|
signature.getPropertyTypeKotlinSignature(),
|
||||||
getterDescriptor);
|
getterDescriptor);
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void generateSetter(JetNamedDeclaration p, PropertyDescriptor propertyDescriptor, JetPropertyAccessor setter) {
|
private void generateSetter(JetNamedDeclaration p, PropertyDescriptor propertyDescriptor, JetPropertyAccessor setter) {
|
||||||
if (setter != null && setter.getBodyExpression() != null
|
//TODO: Now it's not enough information to properly resolve property from bytecode without generated getter and setter
|
||||||
|| isExternallyAccessible(propertyDescriptor) && propertyDescriptor.isVar()) {
|
if (/*setter != null && setter.getBodyExpression() != null
|
||||||
|
|| isExternallyAccessible(propertyDescriptor) &&*/ propertyDescriptor.isVar()) {
|
||||||
JvmPropertyAccessorSignature signature = typeMapper.mapSetterSignature(propertyDescriptor, kind);
|
JvmPropertyAccessorSignature signature = typeMapper.mapSetterSignature(propertyDescriptor, kind);
|
||||||
PropertySetterDescriptor setterDescriptor = propertyDescriptor.getSetter();
|
PropertySetterDescriptor setterDescriptor = propertyDescriptor.getSetter();
|
||||||
setterDescriptor = setterDescriptor != null ? setterDescriptor : DescriptorResolver.createDefaultSetter(propertyDescriptor);
|
setterDescriptor = setterDescriptor != null ? setterDescriptor : DescriptorResolver.createDefaultSetter(propertyDescriptor);
|
||||||
@@ -155,7 +157,7 @@ public class PropertyCodegen extends GenerationStateAware {
|
|||||||
@NotNull CodegenContext context) {
|
@NotNull CodegenContext context) {
|
||||||
|
|
||||||
PropertyDescriptor propertyDescriptor = accessorDescriptor.getCorrespondingProperty();
|
PropertyDescriptor propertyDescriptor = accessorDescriptor.getCorrespondingProperty();
|
||||||
final Type type = typeMapper.mapType(propertyDescriptor);
|
Type type = typeMapper.mapType(propertyDescriptor);
|
||||||
if (accessorDescriptor instanceof PropertyGetterDescriptor) {
|
if (accessorDescriptor instanceof PropertyGetterDescriptor) {
|
||||||
if (kind != OwnerKind.NAMESPACE) {
|
if (kind != OwnerKind.NAMESPACE) {
|
||||||
iv.load(0, OBJECT_TYPE);
|
iv.load(0, OBJECT_TYPE);
|
||||||
@@ -166,7 +168,8 @@ public class PropertyCodegen extends GenerationStateAware {
|
|||||||
propertyDescriptor.getName().getName(),
|
propertyDescriptor.getName().getName(),
|
||||||
type.getDescriptor());
|
type.getDescriptor());
|
||||||
iv.areturn(type);
|
iv.areturn(type);
|
||||||
} else if (accessorDescriptor instanceof PropertySetterDescriptor) {
|
}
|
||||||
|
else if (accessorDescriptor instanceof PropertySetterDescriptor) {
|
||||||
int paramCode = 0;
|
int paramCode = 0;
|
||||||
if (kind != OwnerKind.NAMESPACE) {
|
if (kind != OwnerKind.NAMESPACE) {
|
||||||
iv.load(0, OBJECT_TYPE);
|
iv.load(0, OBJECT_TYPE);
|
||||||
@@ -184,7 +187,7 @@ public class PropertyCodegen extends GenerationStateAware {
|
|||||||
|
|
||||||
iv.visitInsn(RETURN);
|
iv.visitInsn(RETURN);
|
||||||
} else {
|
} else {
|
||||||
assert false;
|
assert false : "Unreachable state";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,10 +13,10 @@ trait MooableTextField : InputTextField {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class SimpleTextField : MooableTextField {
|
class SimpleTextField : MooableTextField {
|
||||||
private var text = ""
|
private var text2 = ""
|
||||||
override fun getText() = text
|
override fun getText() = text2
|
||||||
override fun setText(text: String) {
|
override fun setText(text: String) {
|
||||||
this.text = text
|
this.text2 = text
|
||||||
}
|
}
|
||||||
override fun moo(a: Int, b: Int, c: Int) = a + b + c
|
override fun moo(a: Int, b: Int, c: Int) = a + b + c
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ trait TextField {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class SimpleTextField : TextField {
|
class SimpleTextField : TextField {
|
||||||
private var text = ""
|
private var text2 = ""
|
||||||
override fun getText() = text
|
override fun getText() = text2
|
||||||
override fun setText(text: String) {
|
override fun setText(text: String) {
|
||||||
this.text = text
|
this.text2 = text
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ object State {
|
|||||||
*/
|
*/
|
||||||
public abstract class AbstractIterator<T>: Iterator<T> {
|
public abstract class AbstractIterator<T>: Iterator<T> {
|
||||||
private var state = State.NotReady
|
private var state = State.NotReady
|
||||||
private var next: T? = null
|
private var nextValue: T? = null
|
||||||
|
|
||||||
override fun hasNext(): Boolean {
|
override fun hasNext(): Boolean {
|
||||||
require(state != State.Failed)
|
require(state != State.Failed)
|
||||||
@@ -33,13 +33,13 @@ public abstract class AbstractIterator<T>: Iterator<T> {
|
|||||||
override fun next(): T {
|
override fun next(): T {
|
||||||
if (!hasNext()) throw NoSuchElementException()
|
if (!hasNext()) throw NoSuchElementException()
|
||||||
state = State.NotReady
|
state = State.NotReady
|
||||||
return next as T
|
return nextValue as T
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the next element in the iteration without advancing the iteration */
|
/** Returns the next element in the iteration without advancing the iteration */
|
||||||
fun peek(): T {
|
fun peek(): T {
|
||||||
if (!hasNext()) throw NoSuchElementException()
|
if (!hasNext()) throw NoSuchElementException()
|
||||||
return next as T;
|
return nextValue as T;
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun tryToComputeNext(): Boolean {
|
private fun tryToComputeNext(): Boolean {
|
||||||
@@ -64,7 +64,7 @@ public abstract class AbstractIterator<T>: Iterator<T> {
|
|||||||
* Sets the next value in the iteration, called from the [[computeNext()]] function
|
* Sets the next value in the iteration, called from the [[computeNext()]] function
|
||||||
*/
|
*/
|
||||||
protected fun setNext(value: T): Unit {
|
protected fun setNext(value: T): Unit {
|
||||||
next = value
|
nextValue = value
|
||||||
state = State.Ready
|
state = State.Ready
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user