Skip to content

Commit

Permalink
[J2KT] Fix import resolver to include member types from super classes…
Browse files Browse the repository at this point in the history
…, to match Kotlin semantic.

PiperOrigin-RevId: 601284853
  • Loading branch information
Googler authored and copybara-github committed Jan 25, 2024
1 parent 7ae61d9 commit 6b1e11e
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ internal val TypeDeclaration.memberTypeNameMap: Map<String, String>

/** A map of local member names used in this type. */
internal val TypeDeclaration.localTypeNameMap: Map<String, String>
get() = memberTypeNameMap.plus(nameMapEntry)
get() = superTypesMemberNameMap.plus(memberTypeNameMap).plus(nameMapEntry)

/** A map of local names from super type members. */
internal val TypeDeclaration.superTypesMemberNameMap: Map<String, String>
get() = superTypeDeclaration?.run { superTypesMemberNameMap.plus(memberTypeNameMap) } ?: mapOf()

/** A map of local names used in this type. */
internal val Type.localTypeNameMap: Map<String, String>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,23 @@ void testLocal(String string) {
}

static class Child extends Parent {
@Override
void testJavaLang(java.lang.String string) {
string.trim();
}

@Override
void testLocal(String string) {
string.local();
}
}

static class GrandChild extends Child {
@Override
void testJavaLang(java.lang.String string) {
string.trim();
}

@Override
void testLocal(String string) {
string.local();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,20 @@ open class ImportResolution {
}

open class Child internal constructor(): ImportResolution.Parent() {
override fun testJavaLang_pp_j2kt(string: kotlin.String?) {
string!!.java_trim()
}

override fun testLocal_pp_j2kt(string: ImportResolution.Parent.String?) {
string!!.local_pp_j2kt()
}
}

open class GrandChild internal constructor(): ImportResolution.Child() {
override fun testJavaLang_pp_j2kt(string: kotlin.String?) {
string!!.java_trim()
}

override fun testLocal_pp_j2kt(string: ImportResolution.Parent.String?) {
string!!.local_pp_j2kt()
}
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 6b1e11e

Please sign in to comment.