Do not generate metadata for callable reference classes

After an accidental change in 846537b367, we started generating metadata
into anonymous classes for callable references. This metadata contained
the Kotlin representation of the referenced function. In KT-53794, this
led to a problem where Java's protected visibility could not be
represented in Kotlin terms, which crashed the backend.

But also, this metadata is useless because there's no real use case for
interpreting it (since you already have a function reference object at
runtime with all the needed information), so it would take some extra
space in the bytecode.

 #KT-53794 Fixed
This commit is contained in:
Alexander Udalov
2022-08-31 23:37:44 +02:00
parent 24dcad0d9c
commit 19bbcc5869
9 changed files with 63 additions and 1 deletions
@@ -0,0 +1,9 @@
// TARGET_BACKEND: JVM_IR
fun f() {}
fun g() = ::f
// This regexp checks that there's only one class annotated with kotlin.Metadata with the actual data (which is in the `d1` field).
// That class is the file facade. The synthetic class for the reference `::f` should be generated with synthetic metadata, i.e.
// which has nothing in the `d1` field.
// 1 @Lkotlin/Metadata;\(.*d1.*\)