HelloCW
HelloCW

Reputation: 2325

How to see source code of a fun in Kotlin in Android Studio 3.1.3?

I hope to see the source code of the fun let, but I get the following content after I ctrl + click data?.let.

How to see the source code of a fun in Kotlin in Android Studio 3.1.3?

@kotlin.internal.InlineOnly public inline fun <T, R> T.let(block: (T) -> R): R { /* compiled code */ }

Added Content

Added Content

Android studio start

And More

The image when I click on choose sources

kotlin jar image

Solved:

Now it's OK when system updates the Kotlin plugin today.

I think that the system update the plugin failed caused the problem.

How can I update the plugin manually? You know the Update Plugin UI doesn't always be displayed by the system!

enter image description here

Upvotes: 12

Views: 2957

Answers (1)

Pankaj Kumar
Pankaj Kumar

Reputation: 83018

I can see the source code of let in kotlin-stdlib-common-1.2.51.jar where path is kotlin -> Standard.kt (or file name showing as StandardKt.kotlin_metadata). I am doing same command.

Below is code of that fun

/**
 * Calls the specified function [block] with `this` value as its argument and returns its result.
 */
@kotlin.internal.InlineOnly
public inline fun <T, R> T.let(block: (T) -> R): R {
    contract {
        callsInPlace(block, InvocationKind.EXACTLY_ONCE)
    }
    return block(this)
}

Versions I am using are

Android Studio 3.1.3
Build #AI-173.4819257, built on June 4, 2018
JRE: 1.8.0_152-release-1024-b01 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Mac OS X 10.12.6

And kotlin version is Version: 1.2.51-release-Studio3.1-1

Upvotes: 1

Related Questions