Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

private_to_this not considered in ABI analysis #84

Closed
ZacSweers opened this issue Mar 26, 2020 · 4 comments
Closed

private_to_this not considered in ABI analysis #84

ZacSweers opened this issue Mar 26, 2020 · 4 comments

Comments

@ZacSweers
Copy link
Sponsor Contributor

ZacSweers commented Mar 26, 2020

Plugin version
0.26.1

Gradle version
6.3

Android Gradle Plugin (AGP) version
Irrelevant

Describe the bug
Kotlin visibility has a notion of "private to this", which is present in metadata. I don't think this is currently accounted for.

To Reproduce
Steps to reproduce the behavior:

private class Foo

class Bar {
  private val foo = Foo()
}

Expected behavior
A clear and concise description of what you expected to happen.

Additional context
Add any other context about the problem here.

Example of reading the flag from metadata: https://github.com/square/kotlinpoet/blob/master/kotlinpoet-metadata/src/main/kotlin/com/squareup/kotlinpoet/metadata/Flags.kt#L46

@autonomousapps
Copy link
Owner

Are you sure? I just created a project with the only source file like this:

class Library {
    fun someLibraryMethod(): Boolean {
        val p = PrivateToThis()
        return true
    }
}

private class PrivateToThis

(most of this was auto-generated by gradle init)

I then ran ./gradlew abiAnalysisMain, which produced a file build/reports/dependency-analysis/main/abi-dump.txt, whose contents is

public final class abi/example/Library {
        public fun <init> ()V
        public final fun someLibraryMethod ()Z
}

(as expected)

The companion build/reports/dependency-analysis/main/abi.json file is empty.

nb, I'm not even allowed to compile something like this:

class Library {
    fun someLibraryMethod(): PrivateToThis {
        return PrivateToThis()
    }
}

private class PrivateToThis

@ZacSweers
Copy link
Sponsor Contributor Author

That case might not hit it exactly then. Maybe a private top level function?

@autonomousapps
Copy link
Owner

@ZacSweers are you seeing such PrivateToThis members showing up in an ABI report?

@ZacSweers
Copy link
Sponsor Contributor Author

Haven't seen any yet. Can close this out for now I think and just deal with it if it comes up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants