+16
-4
@@ -56,6 +56,7 @@ import org.jetbrains.kotlin.psi.*
|
|||||||
import org.jetbrains.kotlin.resolve.BindingContext
|
import org.jetbrains.kotlin.resolve.BindingContext
|
||||||
import org.jetbrains.kotlin.resolve.DelegatingBindingTrace
|
import org.jetbrains.kotlin.resolve.DelegatingBindingTrace
|
||||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
|
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
|
||||||
|
import org.jetbrains.kotlin.resolve.calls.callUtil.getType
|
||||||
import org.jetbrains.kotlin.resolve.calls.model.DefaultValueArgument
|
import org.jetbrains.kotlin.resolve.calls.model.DefaultValueArgument
|
||||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedValueArgument
|
import org.jetbrains.kotlin.resolve.calls.model.ResolvedValueArgument
|
||||||
import org.jetbrains.kotlin.resolve.constants.*
|
import org.jetbrains.kotlin.resolve.constants.*
|
||||||
@@ -704,20 +705,31 @@ class ClassFileToSourceStubConverter(val kaptContext: KaptContextForStubGenerati
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun typeFromAsm() = signatureParser.parseFieldSignature(field.signature, treeMaker.Type(type))
|
||||||
|
|
||||||
// Enum type must be an identifier (Javac requirement)
|
// Enum type must be an identifier (Javac requirement)
|
||||||
val typeExpression = if (isEnum(field.access))
|
val typeExpression = if (isEnum(field.access)) {
|
||||||
treeMaker.SimpleName(treeMaker.getQualifiedName(type).substringAfterLast('.'))
|
treeMaker.SimpleName(treeMaker.getQualifiedName(type).substringAfterLast('.'))
|
||||||
else
|
} else if (descriptor is PropertyDescriptor && descriptor.isDelegated) {
|
||||||
getNonErrorType(
|
getNonErrorType(
|
||||||
(descriptor as? CallableDescriptor)?.returnType, RETURN_TYPE,
|
(origin.element as? KtProperty)?.delegateExpression?.getType(kaptContext.bindingContext),
|
||||||
|
RETURN_TYPE,
|
||||||
|
ktTypeProvider = { null },
|
||||||
|
ifNonError = ::typeFromAsm
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
getNonErrorType(
|
||||||
|
(descriptor as? CallableDescriptor)?.returnType,
|
||||||
|
RETURN_TYPE,
|
||||||
ktTypeProvider = {
|
ktTypeProvider = {
|
||||||
val fieldOrigin = (kaptContext.origins[field]?.element as? KtCallableDeclaration)
|
val fieldOrigin = (kaptContext.origins[field]?.element as? KtCallableDeclaration)
|
||||||
?.takeIf { it !is KtFunction }
|
?.takeIf { it !is KtFunction }
|
||||||
|
|
||||||
fieldOrigin?.typeReference
|
fieldOrigin?.typeReference
|
||||||
},
|
},
|
||||||
ifNonError = { signatureParser.parseFieldSignature(field.signature, treeMaker.Type(type)) }
|
ifNonError = ::typeFromAsm
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
lineMappings.registerField(containingClass, field)
|
lineMappings.registerField(containingClass, field)
|
||||||
|
|
||||||
|
|||||||
+5
@@ -119,6 +119,11 @@ public class ClassFileToSourceStubConverterTestGenerated extends AbstractClassFi
|
|||||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/defaultParameterValueOn.kt");
|
runTest("plugins/kapt3/kapt3-compiler/testData/converter/defaultParameterValueOn.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("delegateCorrectErrorTypes.kt")
|
||||||
|
public void testDelegateCorrectErrorTypes() throws Exception {
|
||||||
|
runTest("plugins/kapt3/kapt3-compiler/testData/converter/delegateCorrectErrorTypes.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("deprecated.kt")
|
@TestMetadata("deprecated.kt")
|
||||||
public void testDeprecated() throws Exception {
|
public void testDeprecated() throws Exception {
|
||||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/deprecated.kt");
|
runTest("plugins/kapt3/kapt3-compiler/testData/converter/deprecated.kt");
|
||||||
|
|||||||
+5
@@ -120,6 +120,11 @@ public class IrClassFileToSourceStubConverterTestGenerated extends AbstractIrCla
|
|||||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/defaultParameterValueOn.kt");
|
runTest("plugins/kapt3/kapt3-compiler/testData/converter/defaultParameterValueOn.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("delegateCorrectErrorTypes.kt")
|
||||||
|
public void testDelegateCorrectErrorTypes() throws Exception {
|
||||||
|
runTest("plugins/kapt3/kapt3-compiler/testData/converter/delegateCorrectErrorTypes.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("deprecated.kt")
|
@TestMetadata("deprecated.kt")
|
||||||
public void testDeprecated() throws Exception {
|
public void testDeprecated() throws Exception {
|
||||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/deprecated.kt");
|
runTest("plugins/kapt3/kapt3-compiler/testData/converter/deprecated.kt");
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
// CORRECT_ERROR_TYPES
|
||||||
|
|
||||||
|
@file:Suppress("UNRESOLVED_REFERENCE")
|
||||||
|
|
||||||
|
package test
|
||||||
|
|
||||||
|
class Delegate {
|
||||||
|
operator fun getValue(thisRef: Any, property: KProperty<*>): Any {return Any()}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Bar(delegate: Delegate) {
|
||||||
|
private val unknown: Unknown by delegate
|
||||||
|
}
|
||||||
+38
@@ -0,0 +1,38 @@
|
|||||||
|
package test;
|
||||||
|
|
||||||
|
import java.lang.System;
|
||||||
|
|
||||||
|
@kotlin.Metadata()
|
||||||
|
public final class Bar {
|
||||||
|
private final test.Delegate unknown$delegate = null;
|
||||||
|
|
||||||
|
public Bar(@org.jetbrains.annotations.NotNull()
|
||||||
|
test.Delegate delegate) {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
private final Unknown getUnknown() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////
|
||||||
|
|
||||||
|
package test;
|
||||||
|
|
||||||
|
import java.lang.System;
|
||||||
|
|
||||||
|
@kotlin.Metadata()
|
||||||
|
public final class Delegate {
|
||||||
|
|
||||||
|
public Delegate() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
@org.jetbrains.annotations.NotNull()
|
||||||
|
public final java.lang.Object getValue(@org.jetbrains.annotations.NotNull()
|
||||||
|
java.lang.Object thisRef, @org.jetbrains.annotations.NotNull()
|
||||||
|
KProperty<?> property) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user