fix for KT-257
This commit is contained in:
@@ -725,7 +725,8 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
if (receiver == StackValue.none()) {
|
||||
receiver = generateThisOrOuter((ClassDescriptor) propertyDescriptor.getContainingDeclaration());
|
||||
}
|
||||
receiver.put(JetTypeMapper.TYPE_OBJECT, v);
|
||||
JetType receiverType = bindingContext.get(BindingContext.EXPRESSION_TYPE, r);
|
||||
receiver.put(receiverType != null ? typeMapper.mapType(receiverType) : JetTypeMapper.TYPE_OBJECT, v);
|
||||
}
|
||||
return iValue;
|
||||
}
|
||||
@@ -772,7 +773,8 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
public StackValue intermediateValueForProperty(PropertyDescriptor propertyDescriptor, final boolean forceField, boolean forceInterface) {
|
||||
DeclarationDescriptor containingDeclaration = propertyDescriptor.getContainingDeclaration();
|
||||
boolean isStatic = containingDeclaration instanceof NamespaceDescriptorImpl;
|
||||
propertyDescriptor = propertyDescriptor.getOriginal();
|
||||
while(propertyDescriptor != propertyDescriptor.getOriginal())
|
||||
propertyDescriptor = propertyDescriptor.getOriginal();
|
||||
final JetType outType = propertyDescriptor.getOutType();
|
||||
boolean isInsideClass = !forceInterface && containingDeclaration == contextType();
|
||||
Method getter;
|
||||
@@ -797,7 +799,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
isInterface = !(containingDeclaration instanceof ClassDescriptor && ((ClassDescriptor) containingDeclaration).isObject());
|
||||
}
|
||||
|
||||
return StackValue.property(propertyDescriptor.getName(), owner, typeMapper.mapType(outType), isStatic, isInterface, getter, setter);
|
||||
return StackValue.property(propertyDescriptor.getName(), owner, typeMapper.mapType(propertyDescriptor.getOutType()), isStatic, isInterface, getter, setter);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
class A<T>(var t: T) {}
|
||||
class B<R>(val r: R) {}
|
||||
|
||||
fun box() : String {
|
||||
val ai = A<Int>(1)
|
||||
val aai = A<A<Int>>(ai)
|
||||
if(aai.t.t != 1) return "fail"
|
||||
|
||||
aai.t.t = 2
|
||||
if(aai.t.t != 2) return "fail"
|
||||
|
||||
if(ai.t != 2) return "fail"
|
||||
if(aai.t != ai) return "fail"
|
||||
if(aai.t !== ai) return "fail"
|
||||
|
||||
val abi = A<B<Int>>(B<Int>(1))
|
||||
if(abi.t.r != 1) return "fail"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -130,4 +130,8 @@ public class PropertyGenTest extends CodegenTestCase {
|
||||
final Class aClass = loadClass("Foo", codegens);
|
||||
assertNotNull(aClass.getMethod("getX"));
|
||||
}
|
||||
|
||||
public void testKt257 () throws Exception {
|
||||
blackBoxFile("regressions/kt257.jet");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user