Skip to content

Commit

Permalink
[KT] Correct cast for target params when generating bridge method calls
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 720787551
  • Loading branch information
kevinoconnor7 authored and copybara-github committed Jan 29, 2025
1 parent b39a860 commit 3170ad0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,14 @@ internal class BridgeLowering(val context: JvmBackendContext) : ClassLoweringPas
val argument =
irGet(param).let { argument ->
if (param == bridge.dispatchReceiverParameter) argument
else irCastIfNeeded(argument, targetParam.type.upperBound)
// MODIFIED BY GOOGLE
// Cast to the exact target parameter type to ensure we will generate a
// correct JsDocCast. Casting to the upper bound would be sufficient for JVM
// runtime behavior, but would generate imprecise JsDocCasts.
// Original code:
// else irCastIfNeeded(argument, targetParam.type.upperBound)
else irCastIfNeeded(argument, targetParam.type)
// END OF MODIFICATIONS
}
putArgument(targetParam, argument)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,25 @@ class GenericType extends AbstractCollection {
}
/** @nodts @return {boolean} */
m_contains__autovalue_SimpleAutoValue__boolean(/** SimpleAutoValue */ o) {
return super.contains(o);
return super.contains(/**@type {?}*/ (o));
}
/** @final @override @return {boolean} */
contains(/** * */ element) {
if (!($Equality.$same(element, null) || SimpleAutoValue.$isInstance(element))) {
return false;
}
return this.m_contains__autovalue_SimpleAutoValue__boolean(/**@type {!SimpleAutoValue}*/ (element));
return this.m_contains__autovalue_SimpleAutoValue__boolean(/**@type {SimpleAutoValue}*/ (element));
}
/** @nodts @return {boolean} */
m_remove__autovalue_SimpleAutoValue__boolean(/** SimpleAutoValue */ o) {
return super.remove(o);
return super.remove(/**@type {?}*/ (o));
}
/** @final @override @return {boolean} */
remove(/** * */ element) {
if (!($Equality.$same(element, null) || SimpleAutoValue.$isInstance(element))) {
return false;
}
return this.m_remove__autovalue_SimpleAutoValue__boolean(/**@type {!SimpleAutoValue}*/ (element));
return this.m_remove__autovalue_SimpleAutoValue__boolean(/**@type {SimpleAutoValue}*/ (element));
}
/** @nodts */
static $clinit() {
Expand Down

0 comments on commit 3170ad0

Please sign in to comment.