JVM_IR KT-43877 fix generic signatures for SAM-converted lambdas

This commit is contained in:
Dmitry Petrov
2020-12-11 15:41:02 +03:00
parent dc11c2de77
commit b7330a9e14
56 changed files with 1014 additions and 59 deletions
@@ -1075,11 +1075,13 @@ private fun makeKotlinType(
classDescriptor.defaultType.replace(newArguments = kotlinTypeArguments).makeNullableAsSpecified(hasQuestionMark)
} catch (e: Throwable) {
throw RuntimeException(
"Classifier: $classDescriptor\n" +
"Classifier: ${classifier.owner.render()}\n" +
"Type parameters:\n" +
classDescriptor.defaultType.constructor.parameters.withIndex()
.joinToString(separator = "\n") {
"${it.index}: ${(it.value as IrBasedTypeParameterDescriptor).owner.render()}"
val irTypeParameter = (it.value as IrBasedTypeParameterDescriptor).owner
"${it.index}: ${irTypeParameter.render()} " +
"of ${irTypeParameter.parent.render()}"
} +
"\nType arguments:\n" +
arguments.withIndex()
@@ -18,8 +18,10 @@ import org.jetbrains.kotlin.ir.symbols.IrTypeParameterSymbol
import org.jetbrains.kotlin.ir.types.impl.*
import org.jetbrains.kotlin.ir.util.defaultType
import org.jetbrains.kotlin.ir.util.fqNameWhenAvailable
import org.jetbrains.kotlin.ir.util.isAnonymousObject
import org.jetbrains.kotlin.ir.util.isPropertyAccessor
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.SpecialNames
import org.jetbrains.kotlin.types.*
import org.jetbrains.kotlin.types.typeUtil.makeNotNullable
import org.jetbrains.kotlin.types.typeUtil.makeNullable
@@ -177,6 +179,10 @@ val IrClass.typeConstructorParameters: Sequence<IrTypeParameter>
// Ideally this should be fixed in FE.
null
}
current.isAnonymousObject -> {
// Anonymous classes don't capture type parameters.
null
}
parent is IrClass && current is IrClass && !current.isInner ->
null
else ->