[FIR2IR] Properly handle callable references to static functions

This commit is contained in:
Dmitriy Novozhilov
2021-03-25 11:38:28 +03:00
parent 37db27da58
commit 38ab37d7eb
4 changed files with 25 additions and 1 deletions
@@ -292,7 +292,7 @@ internal class AdapterGenerator(
boundDispatchReceiver != null -> irCall.dispatchReceiver = receiverValue
boundExtensionReceiver != null -> irCall.extensionReceiver = receiverValue
}
} else if (callableReferenceAccess.explicitReceiver is FirResolvedQualifier) {
} else if (callableReferenceAccess.explicitReceiver is FirResolvedQualifier && ((firAdaptee as? FirMemberDeclaration)?.isStatic != true)) {
// Unbound callable reference 'A::foo'
val adaptedReceiverParameter = adapterFunction.valueParameters[0]
val adaptedReceiverValue = IrGetValueImpl(
@@ -15098,6 +15098,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fir"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("callableReferenceToStaticFunction.kt")
public void testCallableReferenceToStaticFunction() throws Exception {
runTest("compiler/testData/codegen/box/fir/callableReferenceToStaticFunction.kt");
}
@Test
@TestMetadata("ClassBuilder.kt")
public void testClassBuilder() throws Exception {