mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Use compiler-provided adapter functions when creating a function reference
This commit is contained in:
@@ -4389,10 +4389,16 @@ open class KotlinFileExtractor(
|
||||
callable: Label<out DbCallable>
|
||||
) {
|
||||
with("function reference", functionReferenceExpr) {
|
||||
val target = functionReferenceExpr.reflectionTarget ?: run {
|
||||
logger.warnElement("Expected to find reflection target for function reference. Using underlying symbol instead.", functionReferenceExpr)
|
||||
functionReferenceExpr.symbol
|
||||
}
|
||||
val target =
|
||||
if (functionReferenceExpr.origin == IrStatementOrigin.ADAPTED_FUNCTION_REFERENCE)
|
||||
// For an adaptation (e.g. to adjust the number or type of arguments or results), the symbol field points at the adapter while `.reflectionTarget` points at the source-level target.
|
||||
functionReferenceExpr.symbol
|
||||
else
|
||||
// TODO: Consider whether we could always target the symbol
|
||||
functionReferenceExpr.reflectionTarget ?: run {
|
||||
logger.warnElement("Expected to find reflection target for function reference. Using underlying symbol instead.", functionReferenceExpr)
|
||||
functionReferenceExpr.symbol
|
||||
}
|
||||
|
||||
/*
|
||||
* Extract generated class:
|
||||
|
||||
@@ -282,9 +282,461 @@ reflection.kt:
|
||||
# 126| 5: [BlockStmt] { ... }
|
||||
# 126| 0: [ReturnStmt] return ...
|
||||
# 126| 0: [MethodAccess] fn1(...)
|
||||
# 126| -1: [TypeAccess] ReflectionKt
|
||||
# 126| -1: [ClassInstanceExpr] new (...)
|
||||
# 126| -3: [TypeAccess] Object
|
||||
# 126| -3: [TypeAccess] Function0<Unit>
|
||||
# 126| 0: [TypeAccess] Unit
|
||||
# 129| 12: [Method] expectsOneParam
|
||||
# 129| 3: [TypeAccess] int
|
||||
#-----| 4: (Parameters)
|
||||
# 129| 0: [Parameter] f
|
||||
# 129| 0: [TypeAccess] Function1<? super Integer,Integer>
|
||||
# 129| 0: [WildcardTypeAccess] ? ...
|
||||
# 129| 1: [TypeAccess] Integer
|
||||
# 129| 1: [TypeAccess] Integer
|
||||
# 129| 5: [BlockStmt] { ... }
|
||||
# 129| 0: [ReturnStmt] return ...
|
||||
# 129| 0: [MethodAccess] invoke(...)
|
||||
# 129| -1: [VarAccess] f
|
||||
# 129| 0: [IntegerLiteral] 0
|
||||
# 131| 13: [Method] takesOptionalParam
|
||||
# 131| 3: [TypeAccess] int
|
||||
#-----| 4: (Parameters)
|
||||
# 131| 0: [Parameter] x
|
||||
# 131| 0: [TypeAccess] int
|
||||
# 131| 1: [Parameter] y
|
||||
# 131| 0: [TypeAccess] int
|
||||
# 131| 5: [BlockStmt] { ... }
|
||||
# 131| 0: [ReturnStmt] return ...
|
||||
# 131| 0: [AddExpr] ... + ...
|
||||
# 131| 0: [VarAccess] x
|
||||
# 131| 1: [VarAccess] y
|
||||
# 131| 14: [Method] takesOptionalParam$default
|
||||
# 131| 3: [TypeAccess] int
|
||||
#-----| 4: (Parameters)
|
||||
# 131| 0: [Parameter] p0
|
||||
# 131| 0: [TypeAccess] int
|
||||
# 131| 1: [Parameter] p1
|
||||
# 131| 0: [TypeAccess] int
|
||||
# 131| 2: [Parameter] p2
|
||||
# 131| 0: [TypeAccess] int
|
||||
# 131| 3: [Parameter] p3
|
||||
# 131| 0: [TypeAccess] Object
|
||||
# 131| 5: [BlockStmt] { ... }
|
||||
# 131| 0: [IfStmt] if (...)
|
||||
# 131| 0: [EQExpr] ... == ...
|
||||
# 131| 0: [AndBitwiseExpr] ... & ...
|
||||
# 131| 0: [IntegerLiteral] 2
|
||||
# 131| 1: [VarAccess] p2
|
||||
# 131| 1: [IntegerLiteral] 0
|
||||
# 131| 1: [ExprStmt] <Expr>;
|
||||
# 131| 0: [AssignExpr] ...=...
|
||||
# 131| 0: [VarAccess] p1
|
||||
# 131| 1: [IntegerLiteral] 0
|
||||
# 131| 1: [ReturnStmt] return ...
|
||||
# 131| 0: [MethodAccess] takesOptionalParam(...)
|
||||
# 131| -1: [TypeAccess] ReflectionKt
|
||||
# 131| 0: [VarAccess] p0
|
||||
# 131| 1: [VarAccess] p1
|
||||
# 133| 15: [Method] adaptedParams
|
||||
# 133| 3: [TypeAccess] Unit
|
||||
# 133| 5: [BlockStmt] { ... }
|
||||
# 134| 0: [ExprStmt] <Expr>;
|
||||
# 134| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
|
||||
# 134| 0: [TypeAccess] Unit
|
||||
# 134| 1: [MethodAccess] expectsOneParam(...)
|
||||
# 134| -1: [TypeAccess] ReflectionKt
|
||||
# 134| 0: [StmtExpr] <Stmt>
|
||||
# 134| 0: [BlockStmt] { ... }
|
||||
# 134| 0: [LocalTypeDeclStmt] class ...
|
||||
# 134| 0: [LocalClass]
|
||||
# 134| 1: [Constructor]
|
||||
# 134| 5: [BlockStmt] { ... }
|
||||
# 134| 0: [SuperConstructorInvocationStmt] super(...)
|
||||
# 134| 2: [Method] takesOptionalParam
|
||||
# 134| 3: [TypeAccess] int
|
||||
#-----| 4: (Parameters)
|
||||
# 134| 0: [Parameter] p0
|
||||
# 134| 0: [TypeAccess] int
|
||||
# 134| 5: [BlockStmt] { ... }
|
||||
# 134| 0: [ReturnStmt] return ...
|
||||
# 134| 0: [MethodAccess] takesOptionalParam$default(...)
|
||||
# 134| -1: [TypeAccess] ReflectionKt
|
||||
# 134| 0: [VarAccess] p0
|
||||
# 1| 1: [IntegerLiteral] 0
|
||||
# 1| 2: [IntegerLiteral] 1
|
||||
# 1| 3: [NullLiteral] null
|
||||
# 134| 1: [ExprStmt] <Expr>;
|
||||
# 134| 0: [MemberRefExpr] ...::...
|
||||
# 134| -4: [AnonymousClass] new Function1<Integer,Integer>(...) { ... }
|
||||
# 134| 1: [Constructor]
|
||||
# 134| 5: [BlockStmt] { ... }
|
||||
# 134| 0: [SuperConstructorInvocationStmt] super(...)
|
||||
# 134| 0: [IntegerLiteral] 1
|
||||
# 134| 2: [Method] invoke
|
||||
#-----| 4: (Parameters)
|
||||
# 134| 0: [Parameter] a0
|
||||
# 134| 5: [BlockStmt] { ... }
|
||||
# 134| 0: [ReturnStmt] return ...
|
||||
# 134| 0: [MethodAccess] takesOptionalParam(...)
|
||||
# 134| -1: [ClassInstanceExpr] new (...)
|
||||
# 134| -3: [TypeAccess] Object
|
||||
# 134| 0: [VarAccess] a0
|
||||
# 134| -3: [TypeAccess] Function1<Integer,Integer>
|
||||
# 134| 0: [TypeAccess] Integer
|
||||
# 134| 1: [TypeAccess] Integer
|
||||
# 137| 16: [Method] expectsOneParamAndReceiver
|
||||
# 137| 3: [TypeAccess] Unit
|
||||
#-----| 4: (Parameters)
|
||||
# 137| 0: [Parameter] f
|
||||
# 137| 0: [TypeAccess] Function2<? super MemberOptionalsTest,? super Integer,Integer>
|
||||
# 137| 0: [WildcardTypeAccess] ? ...
|
||||
# 137| 1: [TypeAccess] MemberOptionalsTest
|
||||
# 137| 1: [WildcardTypeAccess] ? ...
|
||||
# 137| 1: [TypeAccess] Integer
|
||||
# 137| 2: [TypeAccess] Integer
|
||||
# 137| 5: [BlockStmt] { ... }
|
||||
# 143| 17: [Method] memberAdaptedParams
|
||||
# 143| 3: [TypeAccess] Unit
|
||||
#-----| 4: (Parameters)
|
||||
# 143| 0: [Parameter] m
|
||||
# 143| 0: [TypeAccess] MemberOptionalsTest
|
||||
# 143| 5: [BlockStmt] { ... }
|
||||
# 144| 0: [ExprStmt] <Expr>;
|
||||
# 144| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
|
||||
# 144| 0: [TypeAccess] Unit
|
||||
# 144| 1: [MethodAccess] expectsOneParam(...)
|
||||
# 144| -1: [TypeAccess] ReflectionKt
|
||||
# 144| 0: [StmtExpr] <Stmt>
|
||||
# 144| 0: [BlockStmt] { ... }
|
||||
# 144| 0: [LocalTypeDeclStmt] class ...
|
||||
# 144| 0: [LocalClass]
|
||||
# 144| 1: [Constructor]
|
||||
# 144| 5: [BlockStmt] { ... }
|
||||
# 144| 0: [SuperConstructorInvocationStmt] super(...)
|
||||
# 144| 2: [ExtensionMethod] takesOptionalParam
|
||||
# 144| 3: [TypeAccess] int
|
||||
#-----| 4: (Parameters)
|
||||
# 144| 0: [Parameter] receiver
|
||||
# 144| 0: [TypeAccess] MemberOptionalsTest
|
||||
# 144| 1: [Parameter] p0
|
||||
# 144| 0: [TypeAccess] int
|
||||
# 144| 5: [BlockStmt] { ... }
|
||||
# 144| 0: [ReturnStmt] return ...
|
||||
# 144| 0: [MethodAccess] takesOptionalParam$default(...)
|
||||
# 144| -1: [TypeAccess] MemberOptionalsTest
|
||||
# 144| 0: [ExtensionReceiverAccess] this
|
||||
# 144| 1: [VarAccess] p0
|
||||
# 1| 2: [IntegerLiteral] 0
|
||||
# 1| 3: [IntegerLiteral] 1
|
||||
# 1| 4: [NullLiteral] null
|
||||
# 144| 1: [ExprStmt] <Expr>;
|
||||
# 144| 0: [MemberRefExpr] ...::...
|
||||
# 144| -4: [AnonymousClass] new Function1<Integer,Integer>(...) { ... }
|
||||
# 144| 1: [Constructor]
|
||||
#-----| 4: (Parameters)
|
||||
# 144| 0: [Parameter] <extensionReceiver>
|
||||
# 144| 5: [BlockStmt] { ... }
|
||||
# 144| 0: [SuperConstructorInvocationStmt] super(...)
|
||||
# 144| 0: [IntegerLiteral] 1
|
||||
# 144| 1: [ExprStmt] <Expr>;
|
||||
# 144| 0: [AssignExpr] ...=...
|
||||
# 144| 0: [VarAccess] this.<extensionReceiver>
|
||||
# 144| -1: [ThisAccess] this
|
||||
# 144| 1: [VarAccess] <extensionReceiver>
|
||||
# 144| 2: [FieldDeclaration] MemberOptionalsTest <extensionReceiver>;
|
||||
# 144| -1: [TypeAccess] MemberOptionalsTest
|
||||
# 144| 3: [Method] invoke
|
||||
#-----| 4: (Parameters)
|
||||
# 144| 0: [Parameter] a0
|
||||
# 144| 5: [BlockStmt] { ... }
|
||||
# 144| 0: [ReturnStmt] return ...
|
||||
# 144| 0: [MethodAccess] takesOptionalParam(...)
|
||||
# 144| -1: [ClassInstanceExpr] new (...)
|
||||
# 144| -3: [TypeAccess] Object
|
||||
# 144| 0: [VarAccess] this.<extensionReceiver>
|
||||
# 144| -1: [ThisAccess] this
|
||||
# 144| 1: [VarAccess] a0
|
||||
# 144| -3: [TypeAccess] Function1<Integer,Integer>
|
||||
# 144| 0: [TypeAccess] Integer
|
||||
# 144| 1: [TypeAccess] Integer
|
||||
# 144| 0: [VarAccess] m
|
||||
# 145| 1: [ExprStmt] <Expr>;
|
||||
# 145| 0: [MethodAccess] expectsOneParamAndReceiver(...)
|
||||
# 145| -1: [TypeAccess] ReflectionKt
|
||||
# 145| 0: [StmtExpr] <Stmt>
|
||||
# 145| 0: [BlockStmt] { ... }
|
||||
# 145| 0: [LocalTypeDeclStmt] class ...
|
||||
# 145| 0: [LocalClass]
|
||||
# 145| 1: [Constructor]
|
||||
# 145| 5: [BlockStmt] { ... }
|
||||
# 145| 0: [SuperConstructorInvocationStmt] super(...)
|
||||
# 145| 2: [Method] takesOptionalParam
|
||||
# 145| 3: [TypeAccess] int
|
||||
#-----| 4: (Parameters)
|
||||
# 145| 0: [Parameter] p0
|
||||
# 145| 0: [TypeAccess] MemberOptionalsTest
|
||||
# 145| 1: [Parameter] p1
|
||||
# 145| 0: [TypeAccess] int
|
||||
# 145| 5: [BlockStmt] { ... }
|
||||
# 145| 0: [ReturnStmt] return ...
|
||||
# 145| 0: [MethodAccess] takesOptionalParam$default(...)
|
||||
# 145| -1: [TypeAccess] MemberOptionalsTest
|
||||
# 145| 0: [VarAccess] p0
|
||||
# 145| 1: [VarAccess] p1
|
||||
# 1| 2: [IntegerLiteral] 0
|
||||
# 1| 3: [IntegerLiteral] 1
|
||||
# 1| 4: [NullLiteral] null
|
||||
# 145| 1: [ExprStmt] <Expr>;
|
||||
# 145| 0: [MemberRefExpr] ...::...
|
||||
# 145| -4: [AnonymousClass] new Function2<MemberOptionalsTest,Integer,Integer>(...) { ... }
|
||||
# 145| 1: [Constructor]
|
||||
# 145| 5: [BlockStmt] { ... }
|
||||
# 145| 0: [SuperConstructorInvocationStmt] super(...)
|
||||
# 145| 0: [IntegerLiteral] 2
|
||||
# 145| 2: [Method] invoke
|
||||
#-----| 4: (Parameters)
|
||||
# 145| 0: [Parameter] a0
|
||||
# 145| 1: [Parameter] a1
|
||||
# 145| 5: [BlockStmt] { ... }
|
||||
# 145| 0: [ReturnStmt] return ...
|
||||
# 145| 0: [MethodAccess] takesOptionalParam(...)
|
||||
# 145| -1: [ClassInstanceExpr] new (...)
|
||||
# 145| -3: [TypeAccess] Object
|
||||
# 145| 0: [VarAccess] a0
|
||||
# 145| 1: [VarAccess] a1
|
||||
# 145| -3: [TypeAccess] Function2<MemberOptionalsTest,Integer,Integer>
|
||||
# 145| 0: [TypeAccess] MemberOptionalsTest
|
||||
# 145| 1: [TypeAccess] Integer
|
||||
# 145| 2: [TypeAccess] Integer
|
||||
# 148| 18: [Method] expectsOneParamAndExtension
|
||||
# 148| 3: [TypeAccess] Unit
|
||||
#-----| 4: (Parameters)
|
||||
# 148| 0: [Parameter] f
|
||||
# 148| 0: [TypeAccess] Function2<? super String,? super Integer,Integer>
|
||||
# 148| 0: [WildcardTypeAccess] ? ...
|
||||
# 148| 1: [TypeAccess] String
|
||||
# 148| 1: [WildcardTypeAccess] ? ...
|
||||
# 148| 1: [TypeAccess] Integer
|
||||
# 148| 2: [TypeAccess] Integer
|
||||
# 148| 5: [BlockStmt] { ... }
|
||||
# 150| 19: [ExtensionMethod] extTakesOptionalParam
|
||||
# 150| 3: [TypeAccess] int
|
||||
#-----| 4: (Parameters)
|
||||
# 150| 0: [Parameter] <this>
|
||||
# 150| 0: [TypeAccess] String
|
||||
# 150| 1: [Parameter] x
|
||||
# 150| 0: [TypeAccess] int
|
||||
# 150| 2: [Parameter] y
|
||||
# 150| 0: [TypeAccess] int
|
||||
# 150| 5: [BlockStmt] { ... }
|
||||
# 150| 0: [ReturnStmt] return ...
|
||||
# 150| 0: [AddExpr] ... + ...
|
||||
# 150| 0: [VarAccess] x
|
||||
# 150| 1: [VarAccess] y
|
||||
# 150| 20: [Method] extTakesOptionalParam$default
|
||||
# 150| 3: [TypeAccess] int
|
||||
#-----| 4: (Parameters)
|
||||
# 150| 0: [Parameter] p0
|
||||
# 150| 0: [TypeAccess] String
|
||||
# 150| 1: [Parameter] p1
|
||||
# 150| 0: [TypeAccess] int
|
||||
# 150| 2: [Parameter] p2
|
||||
# 150| 0: [TypeAccess] int
|
||||
# 150| 3: [Parameter] p3
|
||||
# 150| 0: [TypeAccess] int
|
||||
# 150| 4: [Parameter] p4
|
||||
# 150| 0: [TypeAccess] Object
|
||||
# 150| 5: [BlockStmt] { ... }
|
||||
# 150| 0: [IfStmt] if (...)
|
||||
# 150| 0: [EQExpr] ... == ...
|
||||
# 150| 0: [AndBitwiseExpr] ... & ...
|
||||
# 150| 0: [IntegerLiteral] 2
|
||||
# 150| 1: [VarAccess] p3
|
||||
# 150| 1: [IntegerLiteral] 0
|
||||
# 150| 1: [ExprStmt] <Expr>;
|
||||
# 150| 0: [AssignExpr] ...=...
|
||||
# 150| 0: [VarAccess] p2
|
||||
# 150| 1: [IntegerLiteral] 0
|
||||
# 150| 1: [ReturnStmt] return ...
|
||||
# 150| 0: [MethodAccess] extTakesOptionalParam(...)
|
||||
# 150| -1: [TypeAccess] ReflectionKt
|
||||
# 150| 0: [VarAccess] p0
|
||||
# 150| 1: [VarAccess] p1
|
||||
# 150| 2: [VarAccess] p2
|
||||
# 152| 21: [Method] extensionAdaptedParams
|
||||
# 152| 3: [TypeAccess] Unit
|
||||
#-----| 4: (Parameters)
|
||||
# 152| 0: [Parameter] s
|
||||
# 152| 0: [TypeAccess] String
|
||||
# 152| 5: [BlockStmt] { ... }
|
||||
# 153| 0: [ExprStmt] <Expr>;
|
||||
# 153| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
|
||||
# 153| 0: [TypeAccess] Unit
|
||||
# 153| 1: [MethodAccess] expectsOneParam(...)
|
||||
# 153| -1: [TypeAccess] ReflectionKt
|
||||
# 153| 0: [StmtExpr] <Stmt>
|
||||
# 153| 0: [BlockStmt] { ... }
|
||||
# 153| 0: [LocalTypeDeclStmt] class ...
|
||||
# 153| 0: [LocalClass]
|
||||
# 153| 1: [Constructor]
|
||||
# 153| 5: [BlockStmt] { ... }
|
||||
# 153| 0: [SuperConstructorInvocationStmt] super(...)
|
||||
# 153| 2: [ExtensionMethod] extTakesOptionalParam
|
||||
# 153| 3: [TypeAccess] int
|
||||
#-----| 4: (Parameters)
|
||||
# 153| 0: [Parameter] receiver
|
||||
# 153| 0: [TypeAccess] String
|
||||
# 153| 1: [Parameter] p0
|
||||
# 153| 0: [TypeAccess] int
|
||||
# 153| 5: [BlockStmt] { ... }
|
||||
# 153| 0: [ReturnStmt] return ...
|
||||
# 153| 0: [MethodAccess] extTakesOptionalParam$default(...)
|
||||
# 153| -1: [TypeAccess] ReflectionKt
|
||||
# 153| 0: [ExtensionReceiverAccess] this
|
||||
# 153| 1: [VarAccess] p0
|
||||
# 1| 2: [IntegerLiteral] 0
|
||||
# 1| 3: [IntegerLiteral] 1
|
||||
# 1| 4: [NullLiteral] null
|
||||
# 153| 1: [ExprStmt] <Expr>;
|
||||
# 153| 0: [MemberRefExpr] ...::...
|
||||
# 153| -4: [AnonymousClass] new Function1<Integer,Integer>(...) { ... }
|
||||
# 153| 1: [Constructor]
|
||||
#-----| 4: (Parameters)
|
||||
# 153| 0: [Parameter] <extensionReceiver>
|
||||
# 153| 5: [BlockStmt] { ... }
|
||||
# 153| 0: [SuperConstructorInvocationStmt] super(...)
|
||||
# 153| 0: [IntegerLiteral] 1
|
||||
# 153| 1: [ExprStmt] <Expr>;
|
||||
# 153| 0: [AssignExpr] ...=...
|
||||
# 153| 0: [VarAccess] this.<extensionReceiver>
|
||||
# 153| -1: [ThisAccess] this
|
||||
# 153| 1: [VarAccess] <extensionReceiver>
|
||||
# 153| 2: [FieldDeclaration] String <extensionReceiver>;
|
||||
# 153| -1: [TypeAccess] String
|
||||
# 153| 3: [Method] invoke
|
||||
#-----| 4: (Parameters)
|
||||
# 153| 0: [Parameter] a0
|
||||
# 153| 5: [BlockStmt] { ... }
|
||||
# 153| 0: [ReturnStmt] return ...
|
||||
# 153| 0: [MethodAccess] extTakesOptionalParam(...)
|
||||
# 153| -1: [ClassInstanceExpr] new (...)
|
||||
# 153| -3: [TypeAccess] Object
|
||||
# 153| 0: [VarAccess] this.<extensionReceiver>
|
||||
# 153| -1: [ThisAccess] this
|
||||
# 153| 1: [VarAccess] a0
|
||||
# 153| -3: [TypeAccess] Function1<Integer,Integer>
|
||||
# 153| 0: [TypeAccess] Integer
|
||||
# 153| 1: [TypeAccess] Integer
|
||||
# 153| 0: [VarAccess] s
|
||||
# 154| 1: [ExprStmt] <Expr>;
|
||||
# 154| 0: [MethodAccess] expectsOneParamAndExtension(...)
|
||||
# 154| -1: [TypeAccess] ReflectionKt
|
||||
# 154| 0: [StmtExpr] <Stmt>
|
||||
# 154| 0: [BlockStmt] { ... }
|
||||
# 154| 0: [LocalTypeDeclStmt] class ...
|
||||
# 154| 0: [LocalClass]
|
||||
# 154| 1: [Constructor]
|
||||
# 154| 5: [BlockStmt] { ... }
|
||||
# 154| 0: [SuperConstructorInvocationStmt] super(...)
|
||||
# 154| 2: [Method] extTakesOptionalParam
|
||||
# 154| 3: [TypeAccess] int
|
||||
#-----| 4: (Parameters)
|
||||
# 154| 0: [Parameter] p0
|
||||
# 154| 0: [TypeAccess] String
|
||||
# 154| 1: [Parameter] p1
|
||||
# 154| 0: [TypeAccess] int
|
||||
# 154| 5: [BlockStmt] { ... }
|
||||
# 154| 0: [ReturnStmt] return ...
|
||||
# 154| 0: [MethodAccess] extTakesOptionalParam$default(...)
|
||||
# 154| -1: [TypeAccess] ReflectionKt
|
||||
# 154| 0: [VarAccess] p0
|
||||
# 154| 1: [VarAccess] p1
|
||||
# 1| 2: [IntegerLiteral] 0
|
||||
# 1| 3: [IntegerLiteral] 1
|
||||
# 1| 4: [NullLiteral] null
|
||||
# 154| 1: [ExprStmt] <Expr>;
|
||||
# 154| 0: [MemberRefExpr] ...::...
|
||||
# 154| -4: [AnonymousClass] new Function2<String,Integer,Integer>(...) { ... }
|
||||
# 154| 1: [Constructor]
|
||||
# 154| 5: [BlockStmt] { ... }
|
||||
# 154| 0: [SuperConstructorInvocationStmt] super(...)
|
||||
# 154| 0: [IntegerLiteral] 2
|
||||
# 154| 2: [Method] invoke
|
||||
#-----| 4: (Parameters)
|
||||
# 154| 0: [Parameter] a0
|
||||
# 154| 1: [Parameter] a1
|
||||
# 154| 5: [BlockStmt] { ... }
|
||||
# 154| 0: [ReturnStmt] return ...
|
||||
# 154| 0: [MethodAccess] extTakesOptionalParam(...)
|
||||
# 154| -1: [ClassInstanceExpr] new (...)
|
||||
# 154| -3: [TypeAccess] Object
|
||||
# 154| 0: [VarAccess] a0
|
||||
# 154| 1: [VarAccess] a1
|
||||
# 154| -3: [TypeAccess] Function2<String,Integer,Integer>
|
||||
# 154| 0: [TypeAccess] String
|
||||
# 154| 1: [TypeAccess] Integer
|
||||
# 154| 2: [TypeAccess] Integer
|
||||
# 159| 22: [Method] expectsOneParamCons
|
||||
# 159| 3: [TypeAccess] ConstructorOptional
|
||||
#-----| 4: (Parameters)
|
||||
# 159| 0: [Parameter] f
|
||||
# 159| 0: [TypeAccess] Function1<? super Integer,ConstructorOptional>
|
||||
# 159| 0: [WildcardTypeAccess] ? ...
|
||||
# 159| 1: [TypeAccess] Integer
|
||||
# 159| 1: [TypeAccess] ConstructorOptional
|
||||
# 159| 5: [BlockStmt] { ... }
|
||||
# 159| 0: [ReturnStmt] return ...
|
||||
# 159| 0: [MethodAccess] invoke(...)
|
||||
# 159| -1: [VarAccess] f
|
||||
# 159| 0: [IntegerLiteral] 0
|
||||
# 161| 23: [Method] constructorAdaptedParams
|
||||
# 161| 3: [TypeAccess] Unit
|
||||
# 161| 5: [BlockStmt] { ... }
|
||||
# 162| 0: [ExprStmt] <Expr>;
|
||||
# 162| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
|
||||
# 162| 0: [TypeAccess] Unit
|
||||
# 162| 1: [MethodAccess] expectsOneParamCons(...)
|
||||
# 162| -1: [TypeAccess] ReflectionKt
|
||||
# 162| 0: [StmtExpr] <Stmt>
|
||||
# 162| 0: [BlockStmt] { ... }
|
||||
# 162| 0: [LocalTypeDeclStmt] class ...
|
||||
# 162| 0: [LocalClass]
|
||||
# 162| 1: [Constructor]
|
||||
# 162| 5: [BlockStmt] { ... }
|
||||
# 162| 0: [SuperConstructorInvocationStmt] super(...)
|
||||
# 162| 2: [Method] <init>
|
||||
# 162| 3: [TypeAccess] ConstructorOptional
|
||||
#-----| 4: (Parameters)
|
||||
# 162| 0: [Parameter] p0
|
||||
# 162| 0: [TypeAccess] int
|
||||
# 162| 5: [BlockStmt] { ... }
|
||||
# 162| 0: [ReturnStmt] return ...
|
||||
# 162| 0: [ClassInstanceExpr] new ConstructorOptional(...)
|
||||
# 162| -3: [TypeAccess] ConstructorOptional
|
||||
# 162| 0: [VarAccess] p0
|
||||
# 1| 1: [IntegerLiteral] 0
|
||||
# 1| 2: [IntegerLiteral] 1
|
||||
# 1| 3: [NullLiteral] null
|
||||
# 162| 1: [ExprStmt] <Expr>;
|
||||
# 162| 0: [MemberRefExpr] ...::...
|
||||
# 162| -4: [AnonymousClass] new Function1<Integer,ConstructorOptional>(...) { ... }
|
||||
# 162| 1: [Constructor]
|
||||
# 162| 5: [BlockStmt] { ... }
|
||||
# 162| 0: [SuperConstructorInvocationStmt] super(...)
|
||||
# 162| 0: [IntegerLiteral] 1
|
||||
# 162| 2: [Method] invoke
|
||||
#-----| 4: (Parameters)
|
||||
# 162| 0: [Parameter] a0
|
||||
# 162| 5: [BlockStmt] { ... }
|
||||
# 162| 0: [ReturnStmt] return ...
|
||||
# 162| 0: [MethodAccess] <init>(...)
|
||||
# 162| -1: [ClassInstanceExpr] new (...)
|
||||
# 162| -3: [TypeAccess] Object
|
||||
# 162| 0: [VarAccess] a0
|
||||
# 162| -3: [TypeAccess] Function1<Integer,ConstructorOptional>
|
||||
# 162| 0: [TypeAccess] Integer
|
||||
# 162| 1: [TypeAccess] ConstructorOptional
|
||||
# 5| 2: [Class] Reflection
|
||||
# 5| 1: [Constructor] Reflection
|
||||
# 5| 5: [BlockStmt] { ... }
|
||||
@@ -1237,3 +1689,83 @@ reflection.kt:
|
||||
# 116| -3: [TypeAccess] Function1<Integer,Unit>
|
||||
# 116| 0: [TypeAccess] Integer
|
||||
# 116| 1: [TypeAccess] Unit
|
||||
# 139| 9: [Class] MemberOptionalsTest
|
||||
# 139| 1: [Constructor] MemberOptionalsTest
|
||||
# 139| 5: [BlockStmt] { ... }
|
||||
# 139| 0: [SuperConstructorInvocationStmt] super(...)
|
||||
# 139| 1: [BlockStmt] { ... }
|
||||
# 140| 2: [Method] takesOptionalParam
|
||||
# 140| 3: [TypeAccess] int
|
||||
#-----| 4: (Parameters)
|
||||
# 140| 0: [Parameter] x
|
||||
# 140| 0: [TypeAccess] int
|
||||
# 140| 1: [Parameter] y
|
||||
# 140| 0: [TypeAccess] int
|
||||
# 140| 5: [BlockStmt] { ... }
|
||||
# 140| 0: [ReturnStmt] return ...
|
||||
# 140| 0: [AddExpr] ... + ...
|
||||
# 140| 0: [VarAccess] x
|
||||
# 140| 1: [VarAccess] y
|
||||
# 140| 3: [Method] takesOptionalParam$default
|
||||
# 140| 3: [TypeAccess] int
|
||||
#-----| 4: (Parameters)
|
||||
# 140| 0: [Parameter] p0
|
||||
# 140| 0: [TypeAccess] MemberOptionalsTest
|
||||
# 140| 1: [Parameter] p1
|
||||
# 140| 0: [TypeAccess] int
|
||||
# 140| 2: [Parameter] p2
|
||||
# 140| 0: [TypeAccess] int
|
||||
# 140| 3: [Parameter] p3
|
||||
# 140| 0: [TypeAccess] int
|
||||
# 140| 4: [Parameter] p4
|
||||
# 140| 0: [TypeAccess] Object
|
||||
# 140| 5: [BlockStmt] { ... }
|
||||
# 140| 0: [IfStmt] if (...)
|
||||
# 140| 0: [EQExpr] ... == ...
|
||||
# 140| 0: [AndBitwiseExpr] ... & ...
|
||||
# 140| 0: [IntegerLiteral] 2
|
||||
# 140| 1: [VarAccess] p3
|
||||
# 140| 1: [IntegerLiteral] 0
|
||||
# 140| 1: [ExprStmt] <Expr>;
|
||||
# 140| 0: [AssignExpr] ...=...
|
||||
# 140| 0: [VarAccess] p2
|
||||
# 140| 1: [IntegerLiteral] 0
|
||||
# 140| 1: [ReturnStmt] return ...
|
||||
# 140| 0: [MethodAccess] takesOptionalParam(...)
|
||||
# 140| -1: [VarAccess] p0
|
||||
# 140| 0: [VarAccess] p1
|
||||
# 140| 1: [VarAccess] p2
|
||||
# 157| 10: [Class] ConstructorOptional
|
||||
# 157| 1: [Constructor] ConstructorOptional
|
||||
#-----| 4: (Parameters)
|
||||
# 157| 0: [Parameter] x
|
||||
# 157| 0: [TypeAccess] int
|
||||
# 157| 1: [Parameter] y
|
||||
# 157| 0: [TypeAccess] int
|
||||
# 157| 5: [BlockStmt] { ... }
|
||||
# 157| 0: [SuperConstructorInvocationStmt] super(...)
|
||||
# 157| 1: [BlockStmt] { ... }
|
||||
# 157| 2: [Constructor] ConstructorOptional
|
||||
#-----| 4: (Parameters)
|
||||
# 157| 0: [Parameter] p0
|
||||
# 157| 0: [TypeAccess] int
|
||||
# 157| 1: [Parameter] p1
|
||||
# 157| 0: [TypeAccess] int
|
||||
# 157| 2: [Parameter] p2
|
||||
# 157| 0: [TypeAccess] int
|
||||
# 157| 3: [Parameter] p3
|
||||
# 157| 0: [TypeAccess] DefaultConstructorMarker
|
||||
# 157| 5: [BlockStmt] { ... }
|
||||
# 157| 0: [IfStmt] if (...)
|
||||
# 157| 0: [EQExpr] ... == ...
|
||||
# 157| 0: [AndBitwiseExpr] ... & ...
|
||||
# 157| 0: [IntegerLiteral] 2
|
||||
# 157| 1: [VarAccess] p2
|
||||
# 157| 1: [IntegerLiteral] 0
|
||||
# 157| 1: [ExprStmt] <Expr>;
|
||||
# 157| 0: [AssignExpr] ...=...
|
||||
# 157| 0: [VarAccess] p1
|
||||
# 157| 1: [IntegerLiteral] 0
|
||||
# 157| 1: [ThisConstructorInvocationStmt] this(...)
|
||||
# 157| 0: [VarAccess] p0
|
||||
# 157| 1: [VarAccess] p1
|
||||
|
||||
@@ -51,7 +51,13 @@ functionReferences
|
||||
| reflection.kt:98:14:98:17 | ...::... | reflection.kt:98:14:98:17 | invoke | reflection.kt:94:1:94:24 | fn |
|
||||
| reflection.kt:99:14:99:29 | ...::... | reflection.kt:99:14:99:29 | invoke | file://<external>/Class2$Inner.class:0:0:0:0 | Inner<String> |
|
||||
| reflection.kt:116:40:116:44 | ...::... | reflection.kt:116:40:116:44 | invoke | reflection.kt:115:9:115:27 | fn1 |
|
||||
| reflection.kt:126:9:126:13 | ...::... | reflection.kt:126:9:126:13 | invoke | reflection.kt:121:1:121:13 | fn1 |
|
||||
| reflection.kt:126:9:126:13 | ...::... | reflection.kt:126:9:126:13 | invoke | reflection.kt:126:9:126:13 | fn1 |
|
||||
| reflection.kt:134:21:134:40 | ...::... | reflection.kt:134:21:134:40 | invoke | reflection.kt:134:21:134:40 | takesOptionalParam |
|
||||
| reflection.kt:144:21:144:41 | ...::... | reflection.kt:144:21:144:41 | invoke | reflection.kt:144:21:144:41 | takesOptionalParam |
|
||||
| reflection.kt:145:32:145:70 | ...::... | reflection.kt:145:32:145:70 | invoke | reflection.kt:145:32:145:70 | takesOptionalParam |
|
||||
| reflection.kt:153:21:153:44 | ...::... | reflection.kt:153:21:153:44 | invoke | reflection.kt:153:21:153:44 | extTakesOptionalParam |
|
||||
| reflection.kt:154:33:154:61 | ...::... | reflection.kt:154:33:154:61 | invoke | reflection.kt:154:33:154:61 | extTakesOptionalParam |
|
||||
| reflection.kt:162:25:162:45 | ...::... | reflection.kt:162:25:162:45 | invoke | reflection.kt:162:25:162:45 | <init> |
|
||||
propertyGetReferences
|
||||
| reflection.kt:10:38:10:42 | ...::... | reflection.kt:10:38:10:42 | get | reflection.kt:33:9:33:23 | getP0 |
|
||||
| reflection.kt:15:35:15:41 | ...::... | reflection.kt:15:35:15:41 | get | reflection.kt:33:9:33:23 | getP0 |
|
||||
@@ -115,7 +121,20 @@ callsInsideInvocationMethods
|
||||
| reflection.kt:109:17:109:27 | ...::... | reflection.kt:109:17:109:27 | new KMutableProperty0<Integer>(...) { ... } | reflection.kt:109:17:109:27 | set | reflection.kt:109:17:109:27 | setProp1(...) | Base1.setProp1 |
|
||||
| reflection.kt:116:40:116:44 | ...::... | reflection.kt:116:40:116:44 | new Function1<Integer,Unit>(...) { ... } | reflection.kt:116:40:116:44 | invoke | reflection.kt:116:40:116:44 | fn1(...) | LocalFn$.fn1 |
|
||||
| reflection.kt:116:40:116:44 | ...::... | reflection.kt:116:40:116:44 | new Function1<Integer,Unit>(...) { ... } | reflection.kt:116:40:116:44 | invoke | reflection.kt:116:40:116:44 | new (...) | LocalFn$. |
|
||||
| reflection.kt:126:9:126:13 | ...::... | reflection.kt:126:9:126:13 | new Function0<Unit>(...) { ... } | reflection.kt:126:9:126:13 | invoke | reflection.kt:126:9:126:13 | fn1(...) | ReflectionKt.fn1 |
|
||||
| reflection.kt:126:9:126:13 | ...::... | reflection.kt:126:9:126:13 | new Function0<Unit>(...) { ... } | reflection.kt:126:9:126:13 | invoke | reflection.kt:126:9:126:13 | fn1(...) | ReflectionKt$.fn1 |
|
||||
| reflection.kt:126:9:126:13 | ...::... | reflection.kt:126:9:126:13 | new Function0<Unit>(...) { ... } | reflection.kt:126:9:126:13 | invoke | reflection.kt:126:9:126:13 | new (...) | ReflectionKt$. |
|
||||
| reflection.kt:134:21:134:40 | ...::... | reflection.kt:134:21:134:40 | new Function1<Integer,Integer>(...) { ... } | reflection.kt:134:21:134:40 | invoke | reflection.kt:134:21:134:40 | new (...) | ReflectionKt$. |
|
||||
| reflection.kt:134:21:134:40 | ...::... | reflection.kt:134:21:134:40 | new Function1<Integer,Integer>(...) { ... } | reflection.kt:134:21:134:40 | invoke | reflection.kt:134:21:134:40 | takesOptionalParam(...) | ReflectionKt$.takesOptionalParam |
|
||||
| reflection.kt:144:21:144:41 | ...::... | reflection.kt:144:21:144:41 | new Function1<Integer,Integer>(...) { ... } | reflection.kt:144:21:144:41 | invoke | reflection.kt:144:21:144:41 | new (...) | ReflectionKt$. |
|
||||
| reflection.kt:144:21:144:41 | ...::... | reflection.kt:144:21:144:41 | new Function1<Integer,Integer>(...) { ... } | reflection.kt:144:21:144:41 | invoke | reflection.kt:144:21:144:41 | takesOptionalParam(...) | ReflectionKt$.takesOptionalParam |
|
||||
| reflection.kt:145:32:145:70 | ...::... | reflection.kt:145:32:145:70 | new Function2<MemberOptionalsTest,Integer,Integer>(...) { ... } | reflection.kt:145:32:145:70 | invoke | reflection.kt:145:32:145:70 | new (...) | ReflectionKt$. |
|
||||
| reflection.kt:145:32:145:70 | ...::... | reflection.kt:145:32:145:70 | new Function2<MemberOptionalsTest,Integer,Integer>(...) { ... } | reflection.kt:145:32:145:70 | invoke | reflection.kt:145:32:145:70 | takesOptionalParam(...) | ReflectionKt$.takesOptionalParam |
|
||||
| reflection.kt:153:21:153:44 | ...::... | reflection.kt:153:21:153:44 | new Function1<Integer,Integer>(...) { ... } | reflection.kt:153:21:153:44 | invoke | reflection.kt:153:21:153:44 | extTakesOptionalParam(...) | ReflectionKt$.extTakesOptionalParam |
|
||||
| reflection.kt:153:21:153:44 | ...::... | reflection.kt:153:21:153:44 | new Function1<Integer,Integer>(...) { ... } | reflection.kt:153:21:153:44 | invoke | reflection.kt:153:21:153:44 | new (...) | ReflectionKt$. |
|
||||
| reflection.kt:154:33:154:61 | ...::... | reflection.kt:154:33:154:61 | new Function2<String,Integer,Integer>(...) { ... } | reflection.kt:154:33:154:61 | invoke | reflection.kt:154:33:154:61 | extTakesOptionalParam(...) | ReflectionKt$.extTakesOptionalParam |
|
||||
| reflection.kt:154:33:154:61 | ...::... | reflection.kt:154:33:154:61 | new Function2<String,Integer,Integer>(...) { ... } | reflection.kt:154:33:154:61 | invoke | reflection.kt:154:33:154:61 | new (...) | ReflectionKt$. |
|
||||
| reflection.kt:162:25:162:45 | ...::... | reflection.kt:162:25:162:45 | new Function1<Integer,ConstructorOptional>(...) { ... } | reflection.kt:162:25:162:45 | invoke | reflection.kt:162:25:162:45 | <init>(...) | ReflectionKt$.<init> |
|
||||
| reflection.kt:162:25:162:45 | ...::... | reflection.kt:162:25:162:45 | new Function1<Integer,ConstructorOptional>(...) { ... } | reflection.kt:162:25:162:45 | invoke | reflection.kt:162:25:162:45 | new (...) | ReflectionKt$. |
|
||||
fieldAccessInsideInvocationMethods
|
||||
| reflection.kt:14:38:14:44 | ...::... | reflection.kt:14:38:14:44 | new Function1<C,Integer>(...) { ... } | reflection.kt:14:38:14:44 | invoke | reflection.kt:14:38:14:44 | this.<dispatchReceiver> |
|
||||
| reflection.kt:15:35:15:41 | ...::... | reflection.kt:15:35:15:41 | new KProperty0<Integer>(...) { ... } | reflection.kt:15:35:15:41 | get | reflection.kt:15:35:15:41 | this.<dispatchReceiver> |
|
||||
@@ -138,6 +157,8 @@ fieldAccessInsideInvocationMethods
|
||||
| reflection.kt:99:14:99:29 | ...::... | reflection.kt:99:14:99:29 | new Function1<String,Inner<String>>(...) { ... } | reflection.kt:99:14:99:29 | invoke | reflection.kt:99:14:99:29 | this.<dispatchReceiver> |
|
||||
| reflection.kt:109:17:109:27 | ...::... | reflection.kt:109:17:109:27 | new KMutableProperty0<Integer>(...) { ... } | reflection.kt:109:17:109:27 | get | reflection.kt:109:17:109:27 | this.<dispatchReceiver> |
|
||||
| reflection.kt:109:17:109:27 | ...::... | reflection.kt:109:17:109:27 | new KMutableProperty0<Integer>(...) { ... } | reflection.kt:109:17:109:27 | set | reflection.kt:109:17:109:27 | this.<dispatchReceiver> |
|
||||
| reflection.kt:144:21:144:41 | ...::... | reflection.kt:144:21:144:41 | new Function1<Integer,Integer>(...) { ... } | reflection.kt:144:21:144:41 | invoke | reflection.kt:144:21:144:41 | this.<extensionReceiver> |
|
||||
| reflection.kt:153:21:153:44 | ...::... | reflection.kt:153:21:153:44 | new Function1<Integer,Integer>(...) { ... } | reflection.kt:153:21:153:44 | invoke | reflection.kt:153:21:153:44 | this.<extensionReceiver> |
|
||||
modifiers
|
||||
| reflection.kt:7:49:7:54 | ...::... | reflection.kt:7:49:7:54 | invoke | override |
|
||||
| reflection.kt:7:49:7:54 | ...::... | reflection.kt:7:49:7:54 | invoke | public |
|
||||
@@ -229,6 +250,18 @@ modifiers
|
||||
| reflection.kt:116:40:116:44 | ...::... | reflection.kt:116:40:116:44 | invoke | public |
|
||||
| reflection.kt:126:9:126:13 | ...::... | reflection.kt:126:9:126:13 | invoke | override |
|
||||
| reflection.kt:126:9:126:13 | ...::... | reflection.kt:126:9:126:13 | invoke | public |
|
||||
| reflection.kt:134:21:134:40 | ...::... | reflection.kt:134:21:134:40 | invoke | override |
|
||||
| reflection.kt:134:21:134:40 | ...::... | reflection.kt:134:21:134:40 | invoke | public |
|
||||
| reflection.kt:144:21:144:41 | ...::... | reflection.kt:144:21:144:41 | invoke | override |
|
||||
| reflection.kt:144:21:144:41 | ...::... | reflection.kt:144:21:144:41 | invoke | public |
|
||||
| reflection.kt:145:32:145:70 | ...::... | reflection.kt:145:32:145:70 | invoke | override |
|
||||
| reflection.kt:145:32:145:70 | ...::... | reflection.kt:145:32:145:70 | invoke | public |
|
||||
| reflection.kt:153:21:153:44 | ...::... | reflection.kt:153:21:153:44 | invoke | override |
|
||||
| reflection.kt:153:21:153:44 | ...::... | reflection.kt:153:21:153:44 | invoke | public |
|
||||
| reflection.kt:154:33:154:61 | ...::... | reflection.kt:154:33:154:61 | invoke | override |
|
||||
| reflection.kt:154:33:154:61 | ...::... | reflection.kt:154:33:154:61 | invoke | public |
|
||||
| reflection.kt:162:25:162:45 | ...::... | reflection.kt:162:25:162:45 | invoke | override |
|
||||
| reflection.kt:162:25:162:45 | ...::... | reflection.kt:162:25:162:45 | invoke | public |
|
||||
compGenerated
|
||||
| file://<external>/Class2.class:0:0:0:0 | getValue | 3 |
|
||||
| file://<external>/Class2.class:0:0:0:0 | getValue | 3 |
|
||||
@@ -243,6 +276,16 @@ compGenerated
|
||||
| reflection.kt:105:18:105:31 | getProp1 | 3 |
|
||||
| reflection.kt:105:18:105:31 | setProp1 | 3 |
|
||||
| reflection.kt:126:9:126:13 | | 1 |
|
||||
| reflection.kt:131:1:131:50 | takesOptionalParam$default | 10 |
|
||||
| reflection.kt:134:21:134:40 | | 1 |
|
||||
| reflection.kt:140:5:140:54 | takesOptionalParam$default | 10 |
|
||||
| reflection.kt:144:21:144:41 | | 1 |
|
||||
| reflection.kt:145:32:145:70 | | 1 |
|
||||
| reflection.kt:150:1:150:60 | extTakesOptionalParam$default | 10 |
|
||||
| reflection.kt:153:21:153:44 | | 1 |
|
||||
| reflection.kt:154:33:154:61 | | 1 |
|
||||
| reflection.kt:157:1:157:49 | ConstructorOptional | 10 |
|
||||
| reflection.kt:162:25:162:45 | | 1 |
|
||||
propertyReferenceOverrides
|
||||
| reflection.kt:10:38:10:42 | ...::... | reflection.kt:10:38:10:42 | get | kotlin.reflect.KProperty1<C,Integer>.get(Reflection.C) |
|
||||
| reflection.kt:10:38:10:42 | ...::... | reflection.kt:10:38:10:42 | invoke | kotlin.jvm.functions.Function1<C,Integer>.invoke(Reflection.C) |
|
||||
|
||||
@@ -124,4 +124,40 @@ fun fn2(f: () -> Unit) = f()
|
||||
|
||||
fun adapted() {
|
||||
fn2(::fn1)
|
||||
}
|
||||
}
|
||||
|
||||
fun expectsOneParam(f: (Int) -> Int) = f(0)
|
||||
|
||||
fun takesOptionalParam(x: Int, y: Int = 0) = x + y
|
||||
|
||||
fun adaptedParams() {
|
||||
expectsOneParam(::takesOptionalParam)
|
||||
}
|
||||
|
||||
fun expectsOneParamAndReceiver(f: (MemberOptionalsTest, Int) -> Int) { }
|
||||
|
||||
class MemberOptionalsTest {
|
||||
fun takesOptionalParam(x: Int, y: Int = 0) = x + y
|
||||
}
|
||||
|
||||
fun memberAdaptedParams(m: MemberOptionalsTest) {
|
||||
expectsOneParam(m::takesOptionalParam)
|
||||
expectsOneParamAndReceiver(MemberOptionalsTest::takesOptionalParam)
|
||||
}
|
||||
|
||||
fun expectsOneParamAndExtension(f: (String, Int) -> Int) { }
|
||||
|
||||
fun String.extTakesOptionalParam(x: Int, y: Int = 0) = x + y
|
||||
|
||||
fun extensionAdaptedParams(s: String) {
|
||||
expectsOneParam(s::extTakesOptionalParam)
|
||||
expectsOneParamAndExtension(String::extTakesOptionalParam)
|
||||
}
|
||||
|
||||
class ConstructorOptional(x: Int, y: Int = 0) { }
|
||||
|
||||
fun expectsOneParamCons(f: (Int) -> ConstructorOptional) = f(0)
|
||||
|
||||
fun constructorAdaptedParams() {
|
||||
expectsOneParamCons(::ConstructorOptional)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user