Skip to content

[Bytecode] Hide nested types inside hidden Kotlin types. #723

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

Merged
merged 1 commit into from
Sep 18, 2020

Conversation

jpobst
Copy link
Contributor

@jpobst jpobst commented Sep 18, 2020

Fixes: #682
Context: dotnet/android#4955

Previously, we added support for reading Kotlin generated metadata. Part of this was recognizing when a type was "Kotlin-internal" and marking it private/package-private so generator would not attempt to bind it.

However we did not modify nested types of these types, which still show as public. When attempting to bind these, the parent type cannot be found which causes a warning:

warning BG8604: top ancestor ParentType not found for nested type ParentType.ChildEnum 

Note this doesn't prevent building, and the type is not bound, so we are doing the "correct" thing. This fix just prevents the warning from appearing, possibly confusing users.

The fix is to mark all nested types the same level of "hidden" as the parent type.

@jpobst jpobst marked this pull request as ready for review September 18, 2020 15:32
@jpobst jpobst marked this pull request as draft September 18, 2020 18:33
@jpobst jpobst marked this pull request as ready for review September 18, 2020 18:33
@jonpryor jonpryor merged commit 5136ef9 into master Sep 18, 2020
@jonpryor jonpryor deleted the hide-internal-kotlin branch September 18, 2020 19:47
jonpryor pushed a commit that referenced this pull request Sep 18, 2020
Fixes: #682

Context: dotnet/android#4955

We added support for reading Kotlin-provided metadata in commit
439bd83.  Part of this was recognizing when a type was
"Kotlin-internal" and marking it as `private` or "package-private" to
prevent `generator` from attempting to bind it. 

However, we didn't consider *nested* types of `private` or
"package-private" types in 439bd83, leaving the nested type
visibility unchanged.  This could result in a warning when binding
such nested types:

	warning BG8604: top ancestor ParentType not found for nested type ParentType.ChildEnum 

Note: this doesn't prevent building -- unless `csc /warnaserror` is
used -- and the type is not bound, so we are doing the "correct" thing.
This warning *does* create a "less-than-desirable" user experience,
possibly confusing users.

Update `generator` to change the visibility of nested types within
non-`public` types so that `generator` doesn't attempt to bind the
nested types.  This avoids the BG8604 warning.
@jpobst jpobst added this to the 11.0 (16.8 / 8.8) milestone Sep 22, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Apr 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Public types nested in internal Kotlin types not marked as internal
2 participants