KAPT+IR: Generate LVT in kapt mode
This commit is contained in:
+26
-21
@@ -221,29 +221,34 @@ class ExpressionCodegen(
|
||||
fun generate() {
|
||||
mv.visitCode()
|
||||
val startLabel = markNewLabel()
|
||||
if (irFunction.isMultifileBridge()) {
|
||||
// Multifile bridges need to have line number 1 to be filtered out by the intellij debugging filters.
|
||||
mv.visitLineNumber(1, startLabel)
|
||||
}
|
||||
val info = BlockInfo()
|
||||
val body = irFunction.body
|
||||
?: error("Function has no body: ${irFunction.render()}")
|
||||
|
||||
generateNonNullAssertions()
|
||||
generateFakeContinuationConstructorIfNeeded()
|
||||
val result = body.accept(this, info)
|
||||
// If this function has an expression body, return the result of that expression.
|
||||
// Otherwise, if it does not end in a return statement, it must be void-returning,
|
||||
// and an explicit return instruction at the end is still required to pass validation.
|
||||
if (body !is IrStatementContainer || body.statements.lastOrNull() !is IrReturn) {
|
||||
// Allow setting a breakpoint on the closing brace of a void-returning function
|
||||
// without an explicit return, or the `class Something(` line of a primary constructor.
|
||||
if (irFunction.origin != JvmLoweredDeclarationOrigin.CLASS_STATIC_INITIALIZER) {
|
||||
irFunction.markLineNumber(startOffset = irFunction is IrConstructor && irFunction.isPrimary)
|
||||
if (context.state.classBuilderMode.generateBodies) {
|
||||
if (irFunction.isMultifileBridge()) {
|
||||
// Multifile bridges need to have line number 1 to be filtered out by the intellij debugging filters.
|
||||
mv.visitLineNumber(1, startLabel)
|
||||
}
|
||||
val (returnType, returnIrType) = irFunction.returnAsmAndIrTypes()
|
||||
result.materializeAt(returnType, returnIrType)
|
||||
mv.areturn(returnType)
|
||||
val body = irFunction.body
|
||||
?: error("Function has no body: ${irFunction.render()}")
|
||||
|
||||
generateNonNullAssertions()
|
||||
generateFakeContinuationConstructorIfNeeded()
|
||||
val result = body.accept(this, info)
|
||||
// If this function has an expression body, return the result of that expression.
|
||||
// Otherwise, if it does not end in a return statement, it must be void-returning,
|
||||
// and an explicit return instruction at the end is still required to pass validation.
|
||||
if (body !is IrStatementContainer || body.statements.lastOrNull() !is IrReturn) {
|
||||
// Allow setting a breakpoint on the closing brace of a void-returning function
|
||||
// without an explicit return, or the `class Something(` line of a primary constructor.
|
||||
if (irFunction.origin != JvmLoweredDeclarationOrigin.CLASS_STATIC_INITIALIZER) {
|
||||
irFunction.markLineNumber(startOffset = irFunction is IrConstructor && irFunction.isPrimary)
|
||||
}
|
||||
val (returnType, returnIrType) = irFunction.returnAsmAndIrTypes()
|
||||
result.materializeAt(returnType, returnIrType)
|
||||
mv.areturn(returnType)
|
||||
}
|
||||
} else {
|
||||
mv.aconst(null)
|
||||
mv.athrow()
|
||||
}
|
||||
val endLabel = markNewLabel()
|
||||
writeLocalVariablesInTable(info, endLabel)
|
||||
|
||||
+1
-1
@@ -104,7 +104,7 @@ class FunctionCodegen(private val irFunction: IrFunction, private val classCodeg
|
||||
// `$$forInline` versions of suspend functions have the same bodies as the originals, but with different
|
||||
// name/flags/annotations and with no state machine.
|
||||
val notForInline = irFunction.suspendForInlineToOriginal()
|
||||
val smap = if (!context.state.classBuilderMode.generateBodies || flags.and(Opcodes.ACC_ABSTRACT) != 0 || irFunction.isExternal) {
|
||||
val smap = if (flags.and(Opcodes.ACC_ABSTRACT) != 0 || irFunction.isExternal) {
|
||||
generateAnnotationDefaultValueIfNeeded(methodVisitor)
|
||||
SMAP(listOf())
|
||||
} else if (notForInline != null) {
|
||||
|
||||
@@ -27,12 +27,12 @@ public final class AnnotationsTest {
|
||||
@Anno(value = "top-level-fun")
|
||||
public static final void topLevelFun(@org.jetbrains.annotations.NotNull()
|
||||
@Anno(value = "top-level-fun-receiver")
|
||||
java.lang.String p0) {
|
||||
java.lang.String $this$topLevelFun) {
|
||||
}
|
||||
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public static final java.lang.String getTopLevelVal(@Anno(value = "top-level-val-receiver")
|
||||
int p0) {
|
||||
int $this$topLevelVal) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
package kapt;
|
||||
|
||||
import java.lang.System;
|
||||
|
||||
@kotlin.Metadata()
|
||||
public final class StaticImport {
|
||||
private final java.util.Collection<java.lang.String> x = null;
|
||||
private final kapt.StaticMethod<java.lang.String> l = null;
|
||||
private final kapt.StaticMethod<java.lang.String> m = null;
|
||||
private final int y = 0;
|
||||
|
||||
public StaticImport() {
|
||||
super();
|
||||
}
|
||||
|
||||
public final java.util.Collection<java.lang.String> getX() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public final kapt.StaticMethod<java.lang.String> getL() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public final kapt.StaticMethod<java.lang.String> getM() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public final int getY() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////
|
||||
|
||||
package kapt;
|
||||
|
||||
public class StaticMethod<T> {
|
||||
|
||||
public static <T>StaticMethod<T> of(T t1) {
|
||||
return new StaticMethod<T>(t1);
|
||||
}
|
||||
|
||||
public static <T>StaticMethod<T> of(T t1, T t2) {
|
||||
return new StaticMethod<T>(t1, t2);
|
||||
}
|
||||
|
||||
public static <T>StaticMethod<T> of2(T t1) {
|
||||
return new StaticMethod<T>(t1);
|
||||
}
|
||||
private final T[] ts;
|
||||
|
||||
private StaticMethod(T... ts) {
|
||||
this.ts = ts;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////
|
||||
|
||||
package my.lib;
|
||||
|
||||
import java.lang.System;
|
||||
|
||||
@kotlin.Metadata()
|
||||
public final class LibKt {
|
||||
|
||||
public LibKt() {
|
||||
super();
|
||||
}
|
||||
|
||||
public static final int func(@org.jetbrains.annotations.NotNull()
|
||||
java.lang.String p0) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -73,7 +73,7 @@ public abstract class NullableBundleProperty<EE extends java.lang.Object> implem
|
||||
super();
|
||||
}
|
||||
|
||||
private final java.lang.String toKey(kotlin.reflect.KProperty<?> p0) {
|
||||
private final java.lang.String toKey(kotlin.reflect.KProperty<?> $this$toKey) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
|
||||
package test.another
|
||||
|
||||
annotation class Anno(val value: String)
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
package test.another;
|
||||
|
||||
import java.lang.System;
|
||||
|
||||
@kotlin.Metadata()
|
||||
@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME)
|
||||
public abstract @interface Anno {
|
||||
|
||||
public abstract java.lang.String value();
|
||||
}
|
||||
|
||||
////////////////////
|
||||
|
||||
package test.another;
|
||||
|
||||
import java.lang.System;
|
||||
|
||||
@kotlin.Metadata()
|
||||
public final class TopLevelKt {
|
||||
|
||||
public TopLevelKt() {
|
||||
super();
|
||||
}
|
||||
private static final int topLevelProperty = 2;
|
||||
public static final int topLevelConstProperty = 2;
|
||||
|
||||
@org.jetbrains.annotations.Nullable()
|
||||
public static final java.lang.String topLevelFunction() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@org.jetbrains.annotations.Nullable()
|
||||
public static final <X extends java.lang.CharSequence, T extends java.util.List<? extends X>>T topLevelGenericFunction() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static final int getTopLevelProperty() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public static final java.lang.String getTopLevelProperty2() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static final void extensionFunction(@org.jetbrains.annotations.NotNull()
|
||||
@Anno(value = "rec")
|
||||
java.lang.String $this$extensionFunction, @org.jetbrains.annotations.NotNull()
|
||||
@Anno(value = "1")
|
||||
java.lang.String a, @org.jetbrains.annotations.NotNull()
|
||||
@Anno(value = "2")
|
||||
java.lang.String b) {
|
||||
}
|
||||
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public static final <T extends java.lang.Object>java.lang.String getExtensionProperty(@org.jetbrains.annotations.NotNull()
|
||||
@Anno(value = "propRec")
|
||||
T $this$extensionProperty) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static final <T extends java.lang.Object>void setExtensionProperty(@org.jetbrains.annotations.NotNull()
|
||||
@Anno(value = "propRec")
|
||||
T $this$extensionProperty, @org.jetbrains.annotations.NotNull()
|
||||
@Anno(value = "setparam")
|
||||
java.lang.String setParamName) {
|
||||
}
|
||||
|
||||
@Anno(value = "extpr")
|
||||
@java.lang.Deprecated()
|
||||
public static void getExtensionProperty$annotations(java.lang.Object p0) {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user