groostav

    groostav

    3 years ago
    Hey guys, I'm trying to convert a method reference like
    SomeClass::main
    into a classname for a
    java -mainClass
    argument. This is the best I've got
    private val KFunction<*>.instanceTypeName: String get() {
        return ((this as FunctionReference).boundReceiver::class as KClass<*>).jvmName
    }
    usage:
    val mainClass: String = (MyType::main).instanceTypeName
    is there a better solution?
    b

    bdawg.io

    3 years ago
    Why not just do it off of
    MyType::class.jvmName
    ?
    groostav

    groostav

    3 years ago
    just so that the
    main
    function has a user
    udalov

    udalov

    3 years ago
    FunctionReference
    is an internal API, so please don’t use it Instead, you can use
    instanceParameter!!.type.jvmErasure.jvmName