Type Enhancement for Java fields and constructors supported as well

This commit is contained in:
Andrey Breslav
2015-05-05 18:51:35 +03:00
committed by Denis Zharkov
parent 8c78739983
commit 694af022c8
12 changed files with 113 additions and 14 deletions
@@ -21,7 +21,9 @@ import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl
import org.jetbrains.kotlin.load.java.descriptors.JavaMethodDescriptor
import org.jetbrains.kotlin.load.java.descriptors.JavaCallableMemberDescriptor
import org.jetbrains.kotlin.load.java.descriptors.JavaConstructorDescriptor
import org.jetbrains.kotlin.load.java.descriptors.JavaPropertyDescriptor
import org.jetbrains.kotlin.types.JetType
fun <D : CallableMemberDescriptor> enhanceSignatures(platformSignatures: Collection<D>): Collection<D> {
@@ -46,7 +48,7 @@ fun <D : CallableMemberDescriptor> D.enhance(): D {
val enhancedReturnType = parts { it.getReturnType()!!.toReturnTypePart() }.enhance()
if (this is JavaMethodDescriptor) {
if (this is JavaCallableMemberDescriptor) {
@suppress("UNCHECKED_CAST")
return this.enhance(enhancedReceiverType, enhancedValueParameters, enhancedReturnType) as D
}
@@ -2,5 +2,5 @@ package test
public open class NotNullField {
public constructor NotNullField()
org.jetbrains.annotations.NotNull() public final var hi: kotlin.String!
org.jetbrains.annotations.NotNull() public final var hi: kotlin.String
}
@@ -0,0 +1,10 @@
package test;
import org.jetbrains.annotations.NotNull;
import java.lang.String;
public class ConstructorWithAnnotations {
public ConstructorWithAnnotations(Runnable r, @NotNull String s) {
}
}
@@ -0,0 +1,6 @@
package test
public open class ConstructorWithAnnotations {
public /*synthesized*/ constructor ConstructorWithAnnotations(/*0*/ p0: (() -> kotlin.Unit)!, /*1*/ org.jetbrains.annotations.NotNull() p1: kotlin.String)
public constructor ConstructorWithAnnotations(/*0*/ p0: java.lang.Runnable!, /*1*/ org.jetbrains.annotations.NotNull() p1: kotlin.String)
}
@@ -1568,6 +1568,12 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest {
doTestCompiledJava(fileName);
}
@TestMetadata("ConstructorWithAnnotations.java")
public void testConstructorWithAnnotations() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/compiledJava/sam/adapters/ConstructorWithAnnotations.java");
doTestCompiledJava(fileName);
}
@TestMetadata("DeepSamLoop.java")
public void testDeepSamLoop() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/compiledJava/sam/adapters/DeepSamLoop.java");