Fix for KT-12127: Undeclared type variable on delegated property backing field

#KT-12127 Fixed
This commit is contained in:
Mikhael Bogdanov
2016-05-04 14:32:49 +03:00
parent bac5c4d70b
commit ee7bbbf530
4 changed files with 33 additions and 9 deletions
@@ -348,7 +348,7 @@ public class PropertyCodegen {
FieldVisitor fv = builder.newField( FieldVisitor fv = builder.newField(
JvmDeclarationOriginKt.OtherOrigin(element, propertyDescriptor), modifiers, name, type.getDescriptor(), JvmDeclarationOriginKt.OtherOrigin(element, propertyDescriptor), modifiers, name, type.getDescriptor(),
typeMapper.mapFieldSignature(kotlinType, propertyDescriptor), defaultValue isDelegate ? null : typeMapper.mapFieldSignature(kotlinType, propertyDescriptor), defaultValue
); );
Annotated fieldAnnotated = new AnnotatedWithFakeAnnotations(propertyDescriptor, annotations); Annotated fieldAnnotated = new AnnotatedWithFakeAnnotations(propertyDescriptor, annotations);
@@ -70,12 +70,12 @@ fun box(): String {
val classField5 = clz.getDeclaredField("delegateLazy\$delegate"); val classField5 = clz.getDeclaredField("delegateLazy\$delegate");
if (classField5.getGenericType().toString() != "kotlin.Lazy<Z<TParam>>") if (classField5.getGenericType().toString() != "interface kotlin.Lazy")
return "fail5: " + classField5.getGenericType(); return "fail5: " + classField5.getGenericType();
val classField6 = clz.getDeclaredField("delegateNotNull\$delegate"); val classField6 = clz.getDeclaredField("delegateNotNull\$delegate");
if (classField6.getGenericType().toString() != "kotlin.properties.ReadWriteProperty<java.lang.Object, Z<TParam>>") if (classField6.getGenericType().toString() != "interface kotlin.properties.ReadWriteProperty")
return "fail6: " + classField6.getGenericType(); return "fail6: " + classField6.getGenericType();
@@ -0,0 +1,18 @@
import kotlin.reflect.KProperty
import kotlin.reflect.KProperty1
class DVal<T, R, P: KProperty1<T, R>>(val kmember: P) {
operator fun getValue(t: T, p: KProperty<*>): R {
return kmember.get(t)
}
}
class Value<T>(var text: String? = null)
class Test {
val <T> Value<T>.additionalText by DVal(Value<T>::text)
}
// field: Test::additionalText$delegate
// jvm signature: LDVal;
// generic signature: null
@@ -47,6 +47,12 @@ public class WriteSignatureTestGenerated extends AbstractWriteSignatureTest {
doTest(fileName); doTest(fileName);
} }
@TestMetadata("backingFieldForGenericDelegated.kt")
public void testBackingFieldForGenericDelegated() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/writeSignature/backingFieldForGenericDelegated.kt");
doTest(fileName);
}
@TestMetadata("Comparable.kt") @TestMetadata("Comparable.kt")
public void testComparable() throws Exception { public void testComparable() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/writeSignature/Comparable.kt"); String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/writeSignature/Comparable.kt");