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 constructor shows up in API dump #73

Open
martinbonnin opened this issue Dec 1, 2021 · 3 comments
Open

private constructor shows up in API dump #73

martinbonnin opened this issue Dec 1, 2021 · 3 comments
Assignees

Comments

@martinbonnin
Copy link
Contributor

martinbonnin commented Dec 1, 2021

The following code:

class FooBar private constructor(val id: String) {
  class Builder {
    fun build() = FooBar("")
  }
}

dumps the following API:

public final class com/apollographql/apollo3/api/FooBar {
	public synthetic fun <init> (Ljava/lang/String;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
	public final fun getId ()Ljava/lang/String;
}

public final class com/apollographql/apollo3/api/FooBar$Builder {
	public fun <init> ()V
	public final fun build ()Lcom/apollographql/apollo3/api/FooBar;
}

I'm curious as to why <init> is listed in the dump. If I were to remove the id parameter, would that be considered a breaking change even if it should be an implementation detail?

I'm using 0.8.0-RC

@qwwdfsad
Copy link
Collaborator

Note to self:

class ConstructorMarker constructor(unused: String = "")

and

class ConstructorMarker private constructor(unused: String, i: Int) {
    class Builder {
        fun build() = ConstructorMarker("", 42)
    }
}

both produce public synthetic <init>(Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V, the trick is to properly distinguish them as former is part of the ABI, while latter is not

@qwwdfsad
Copy link
Collaborator

qwwdfsad commented Feb 1, 2022

We decided this is a compiler issue: https://youtrack.jetbrains.com/issue/KT-51073

Alas there is not much we can do on BCV side to address it

@dovchinnikov
Copy link

BCV could at least filter out synthetic constructors with DefaultConstructorMarker but without I

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

4 participants