psi2ir: type arguments for function references
This commit is contained in:
+2
-2
@@ -72,7 +72,7 @@ class ReflectionReferencesGenerator(statementGenerator: StatementGenerator) : St
|
|||||||
startOffset, endOffset,
|
startOffset, endOffset,
|
||||||
getInferredTypeWithImplicitCastsOrFail(ktCallableReference),
|
getInferredTypeWithImplicitCastsOrFail(ktCallableReference),
|
||||||
referencedDescriptor,
|
referencedDescriptor,
|
||||||
typeArguments = null
|
resolvedCall.typeArguments
|
||||||
).also { irCallableReference ->
|
).also { irCallableReference ->
|
||||||
irCallableReference.dispatchReceiver = dispatchReceiverValue?.loadIfExists()
|
irCallableReference.dispatchReceiver = dispatchReceiverValue?.loadIfExists()
|
||||||
irCallableReference.extensionReceiver = extensionReceiverValue?.loadIfExists()
|
irCallableReference.extensionReceiver = extensionReceiverValue?.loadIfExists()
|
||||||
@@ -150,7 +150,7 @@ class ReflectionReferencesGenerator(statementGenerator: StatementGenerator) : St
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun generateFunctionReference(
|
private fun generateFunctionReference(
|
||||||
startOffset: Int,
|
startOffset: Int,
|
||||||
endOffset: Int,
|
endOffset: Int,
|
||||||
type: KotlinType,
|
type: KotlinType,
|
||||||
|
|||||||
@@ -482,7 +482,7 @@ open class DeepCopyIrTree : IrElementTransformerVoid() {
|
|||||||
return IrFunctionReferenceImpl(
|
return IrFunctionReferenceImpl(
|
||||||
expression.startOffset, expression.endOffset,
|
expression.startOffset, expression.endOffset,
|
||||||
expression.type,
|
expression.type,
|
||||||
newCallee.original,
|
newCallee,
|
||||||
expression.typeArgumentsCount,
|
expression.typeArgumentsCount,
|
||||||
mapStatementOrigin(expression.origin)
|
mapStatementOrigin(expression.origin)
|
||||||
).apply {
|
).apply {
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import Host.objectMember
|
||||||
|
|
||||||
|
object Host {
|
||||||
|
inline fun <reified T> objectMember(x: T) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline fun <reified T> topLevel1(x: T) {}
|
||||||
|
inline fun <reified T> topLevel2(x: List<T>) {}
|
||||||
|
|
||||||
|
val test1: (Int) -> Unit = ::topLevel1
|
||||||
|
|
||||||
|
val test2: (List<String>) -> Unit = ::topLevel2
|
||||||
|
|
||||||
|
val test3: (Int) -> Unit = ::objectMember
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
FILE fqName:<root> fileName:/callableReferenceTypeArguments.kt
|
||||||
|
CLASS OBJECT name:Host modality:FINAL visibility:public flags:
|
||||||
|
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:Host flags:
|
||||||
|
superClasses:
|
||||||
|
CLASS IR_EXTERNAL_DECLARATION_STUB CLASS name:Any modality:OPEN visibility:public flags:
|
||||||
|
CONSTRUCTOR visibility:private <> () returnType:Host flags:primary
|
||||||
|
BLOCK_BODY
|
||||||
|
DELEGATING_CONSTRUCTOR_CALL 'constructor Any()'
|
||||||
|
INSTANCE_INITIALIZER_CALL classDescriptor='Host'
|
||||||
|
FUN name:objectMember visibility:public modality:FINAL <T> ($this:Host, x:T) returnType:Unit flags:inline
|
||||||
|
TYPE_PARAMETER name:T index:0 variance: upperBounds:[kotlin.Any?]
|
||||||
|
superClassifiers:
|
||||||
|
CLASS IR_EXTERNAL_DECLARATION_STUB CLASS name:Any modality:OPEN visibility:public flags:
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:Host flags:
|
||||||
|
VALUE_PARAMETER name:x index:0 type:T flags:
|
||||||
|
BLOCK_BODY
|
||||||
|
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags:
|
||||||
|
overridden:
|
||||||
|
FUN IR_EXTERNAL_DECLARATION_STUB name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags:
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:kotlin.Any flags:
|
||||||
|
VALUE_PARAMETER name:other index:0 type:kotlin.Any? flags:
|
||||||
|
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags:
|
||||||
|
overridden:
|
||||||
|
FUN IR_EXTERNAL_DECLARATION_STUB name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags:
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:kotlin.Any flags:
|
||||||
|
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags:
|
||||||
|
overridden:
|
||||||
|
FUN IR_EXTERNAL_DECLARATION_STUB name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags:
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:kotlin.Any flags:
|
||||||
|
FUN name:topLevel1 visibility:public modality:FINAL <T> (x:T) returnType:Unit flags:inline
|
||||||
|
TYPE_PARAMETER name:T index:0 variance: upperBounds:[kotlin.Any?]
|
||||||
|
superClassifiers:
|
||||||
|
CLASS IR_EXTERNAL_DECLARATION_STUB CLASS name:Any modality:OPEN visibility:public flags:
|
||||||
|
VALUE_PARAMETER name:x index:0 type:T flags:
|
||||||
|
BLOCK_BODY
|
||||||
|
FUN name:topLevel2 visibility:public modality:FINAL <T> (x:kotlin.collections.List<T>) returnType:Unit flags:inline
|
||||||
|
TYPE_PARAMETER name:T index:0 variance: upperBounds:[kotlin.Any?]
|
||||||
|
superClassifiers:
|
||||||
|
CLASS IR_EXTERNAL_DECLARATION_STUB CLASS name:Any modality:OPEN visibility:public flags:
|
||||||
|
VALUE_PARAMETER name:x index:0 type:kotlin.collections.List<T> flags:
|
||||||
|
BLOCK_BODY
|
||||||
|
PROPERTY name:test1 type:(kotlin.Int) -> kotlin.Unit visibility:public modality:FINAL flags:val
|
||||||
|
FIELD PROPERTY_BACKING_FIELD name:test1 type:(kotlin.Int) -> kotlin.Unit visibility:public flags:final
|
||||||
|
EXPRESSION_BODY
|
||||||
|
FUNCTION_REFERENCE 'topLevel1(Int): Unit' type=kotlin.reflect.KFunction1<@kotlin.ParameterName kotlin.Int, kotlin.Unit> origin=null
|
||||||
|
<reified T>: Int
|
||||||
|
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-test1> visibility:public modality:FINAL <> () returnType:Function1<Int, Unit> flags:
|
||||||
|
correspondingProperty: PROPERTY name:test1 type:(kotlin.Int) -> kotlin.Unit visibility:public modality:FINAL flags:val
|
||||||
|
BLOCK_BODY
|
||||||
|
RETURN type=kotlin.Nothing from='<get-test1>(): (Int) -> Unit'
|
||||||
|
GET_FIELD 'test1: (Int) -> Unit' type=(kotlin.Int) -> kotlin.Unit origin=null
|
||||||
|
PROPERTY name:test2 type:(kotlin.collections.List<kotlin.String>) -> kotlin.Unit visibility:public modality:FINAL flags:val
|
||||||
|
FIELD PROPERTY_BACKING_FIELD name:test2 type:(kotlin.collections.List<kotlin.String>) -> kotlin.Unit visibility:public flags:final
|
||||||
|
EXPRESSION_BODY
|
||||||
|
FUNCTION_REFERENCE 'topLevel2(List<String>): Unit' type=kotlin.reflect.KFunction1<@kotlin.ParameterName kotlin.collections.List<kotlin.String>, kotlin.Unit> origin=null
|
||||||
|
<reified T>: String
|
||||||
|
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-test2> visibility:public modality:FINAL <> () returnType:Function1<List<String>, Unit> flags:
|
||||||
|
correspondingProperty: PROPERTY name:test2 type:(kotlin.collections.List<kotlin.String>) -> kotlin.Unit visibility:public modality:FINAL flags:val
|
||||||
|
BLOCK_BODY
|
||||||
|
RETURN type=kotlin.Nothing from='<get-test2>(): (List<String>) -> Unit'
|
||||||
|
GET_FIELD 'test2: (List<String>) -> Unit' type=(kotlin.collections.List<kotlin.String>) -> kotlin.Unit origin=null
|
||||||
|
PROPERTY name:test3 type:(kotlin.Int) -> kotlin.Unit visibility:public modality:FINAL flags:val
|
||||||
|
FIELD PROPERTY_BACKING_FIELD name:test3 type:(kotlin.Int) -> kotlin.Unit visibility:public flags:final
|
||||||
|
EXPRESSION_BODY
|
||||||
|
FUNCTION_REFERENCE 'objectMember(Int): Unit' type=kotlin.reflect.KFunction1<@kotlin.ParameterName kotlin.Int, kotlin.Unit> origin=null
|
||||||
|
<reified T>: Int
|
||||||
|
$this: GET_OBJECT 'Host' type=Host
|
||||||
|
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-test3> visibility:public modality:FINAL <> () returnType:Function1<Int, Unit> flags:
|
||||||
|
correspondingProperty: PROPERTY name:test3 type:(kotlin.Int) -> kotlin.Unit visibility:public modality:FINAL flags:val
|
||||||
|
BLOCK_BODY
|
||||||
|
RETURN type=kotlin.Nothing from='<get-test3>(): (Int) -> Unit'
|
||||||
|
GET_FIELD 'test3: (Int) -> Unit' type=(kotlin.Int) -> kotlin.Unit origin=null
|
||||||
@@ -737,6 +737,11 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase {
|
|||||||
runTest("compiler/testData/ir/irText/expressions/callableReferenceToImportedFromObject.kt");
|
runTest("compiler/testData/ir/irText/expressions/callableReferenceToImportedFromObject.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("callableReferenceTypeArguments.kt")
|
||||||
|
public void testCallableReferenceTypeArguments() throws Exception {
|
||||||
|
runTest("compiler/testData/ir/irText/expressions/callableReferenceTypeArguments.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("calls.kt")
|
@TestMetadata("calls.kt")
|
||||||
public void testCalls() throws Exception {
|
public void testCalls() throws Exception {
|
||||||
runTest("compiler/testData/ir/irText/expressions/calls.kt");
|
runTest("compiler/testData/ir/irText/expressions/calls.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user