JVM_IR: no annotations on parameters of 'property$annotations' methods

This commit is contained in:
Dmitry Petrov
2020-07-02 14:28:08 +03:00
parent 8da988b18e
commit a238d6a890
@@ -86,9 +86,7 @@ class FunctionCodegen(
) )
} }
}.genAnnotations(irFunction, signature.asmMethod.returnType, irFunction.returnType) }.genAnnotations(irFunction, signature.asmMethod.returnType, irFunction.returnType)
// Not generating parameter annotations for default stubs fixes KT-7892, though if (shouldGenerateAnnotationsOnValueParameters()) {
// this certainly looks like a workaround for a javac bug.
if (irFunction !is IrConstructor || !irFunction.parentAsClass.shouldNotGenerateConstructorParameterAnnotations()) {
generateParameterAnnotations(irFunction, methodVisitor, signature, classCodegen, context, skipNullabilityAnnotations) generateParameterAnnotations(irFunction, methodVisitor, signature, classCodegen, context, skipNullabilityAnnotations)
} }
} }
@@ -120,6 +118,18 @@ class FunctionCodegen(
return SMAPAndMethodNode(methodNode, smap) return SMAPAndMethodNode(methodNode, smap)
} }
private fun shouldGenerateAnnotationsOnValueParameters(): Boolean =
when {
irFunction.origin == JvmLoweredDeclarationOrigin.SYNTHETIC_METHOD_FOR_PROPERTY_ANNOTATIONS ->
false
irFunction is IrConstructor && irFunction.parentAsClass.shouldNotGenerateConstructorParameterAnnotations() ->
// Not generating parameter annotations for default stubs fixes KT-7892, though
// this certainly looks like a workaround for a javac bug.
false
else ->
true
}
// Since the only arguments to anonymous object constructors are captured variables and complex // Since the only arguments to anonymous object constructors are captured variables and complex
// super constructor arguments, there shouldn't be any annotations on them other than @NonNull, // super constructor arguments, there shouldn't be any annotations on them other than @NonNull,
// and those are meaningless on synthetic parameters. (Also, the inliner cannot handle them and // and those are meaningless on synthetic parameters. (Also, the inliner cannot handle them and