Jinseong Jeon | 3682ef4 | 2019-05-28 00:54:31 -0700 | [diff] [blame^] | 1 | // Copyright (c) 2019, the R8 project authors. Please see the AUTHORS file |
| 2 | // for details. All rights reserved. Use of this source code is governed by a |
| 3 | // BSD-style license that can be found in the LICENSE file. |
| 4 | package unused_arg_in_lambdas_kstyle |
| 5 | |
| 6 | import kotlin.jvm.internal.TypeIntrinsics |
| 7 | |
| 8 | private var COUNT = 11 |
| 9 | |
| 10 | private fun next() = "${COUNT++}" |
| 11 | |
| 12 | fun consumeTwo(l: ((x: Any?, unused: Any?) -> Any)) : Any { |
| 13 | // This can be implicitly added by kotlinc |
| 14 | TypeIntrinsics.beforeCheckcastToFunctionOfArity(l, 2) |
| 15 | return l(next(), next()) |
| 16 | } |
| 17 | |
| 18 | private fun lambdaFactory() { |
| 19 | println(consumeTwo { x, _ -> x.toString() + "-" }) |
| 20 | println(consumeTwo { x, _ -> x.toString() + "*" }) |
| 21 | println(consumeTwo { x, _ -> x.toString() + "+" }) |
| 22 | } |
| 23 | |
| 24 | fun main(args: Array<String>) { |
| 25 | lambdaFactory() |
| 26 | } |