JVM IR: Fix test for anonymous object constructors in FunctionCodegen

This commit is contained in:
Steven Schäfer
2019-10-14 15:31:59 +02:00
committed by Alexander Udalov
parent 6560ecc82b
commit bdd5705a30
3 changed files with 6 additions and 5 deletions
@@ -49,8 +49,7 @@ open class FunctionCodegen(
val flags = calculateMethodFlags(functionView.isStatic)
var methodVisitor = createMethod(flags, signature)
val hasSyntheticFlag = flags.and(Opcodes.ACC_SYNTHETIC) != 0
if (state.generateParametersMetadata && !hasSyntheticFlag) {
if (state.generateParametersMetadata && flags.and(Opcodes.ACC_SYNTHETIC) == 0) {
generateParameterNames(irFunction, methodVisitor, signature, state)
}
@@ -65,7 +64,7 @@ open class FunctionCodegen(
// 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
// will throw an exception if we generate any.)
if (irFunction !is IrConstructor || (!hasSyntheticFlag && !irFunction.parentAsClass.isAnonymousObject)) {
if (irFunction !is IrConstructor || !irFunction.parentAsClass.isAnonymousObject) {
generateParameterAnnotations(functionView, methodVisitor, signature, classCodegen, context)
}
@@ -38,6 +38,7 @@ import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid
import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid
import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.name.SpecialNames
import org.jetbrains.kotlin.resolve.DescriptorUtils
internal val callableReferencePhase = makeIrFilePhase(
@@ -175,7 +176,7 @@ internal class CallableReferenceLowering(private val context: JvmBackendContext)
// A callable reference results in a synthetic class, while a lambda is not synthetic.
// We don't produce GENERATED_SAM_IMPLEMENTATION, which is always synthetic.
origin = if (isLambda) JvmLoweredDeclarationOrigin.LAMBDA_IMPL else JvmLoweredDeclarationOrigin.FUNCTION_REFERENCE_IMPL
name = Name.special("<function reference to ${callee.fqNameWhenAvailable}>")
name = SpecialNames.NO_NAME_PROVIDED
}.apply {
parent = currentDeclarationParent
superTypes += superType
@@ -33,6 +33,7 @@ import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid
import org.jetbrains.kotlin.load.java.JavaVisibilities
import org.jetbrains.kotlin.load.java.JvmAbi
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.name.SpecialNames
import org.jetbrains.kotlin.types.Variance
internal val propertyReferencePhase = makeIrFilePhase(
@@ -227,7 +228,7 @@ internal class PropertyReferenceLowering(val context: JvmBackendContext) : Class
val superClass = propertyReferenceKindFor(expression).interfaceSymbol.owner
val referenceClass = buildClass {
setSourceRange(expression)
name = Name.special("<property reference to ${(expression.symbol.owner as IrDeclarationWithName).fqNameWhenAvailable}>")
name = SpecialNames.NO_NAME_PROVIDED
origin = JvmLoweredDeclarationOrigin.GENERATED_PROPERTY_REFERENCE
visibility = Visibilities.LOCAL
}.apply {