diff --git a/transpiler/java/com/google/j2cl/transpiler/frontend/kotlin/lower/BridgeLowering.kt b/transpiler/java/com/google/j2cl/transpiler/frontend/kotlin/lower/BridgeLowering.kt index d6fb7e3672..92564117c4 100644 --- a/transpiler/java/com/google/j2cl/transpiler/frontend/kotlin/lower/BridgeLowering.kt +++ b/transpiler/java/com/google/j2cl/transpiler/frontend/kotlin/lower/BridgeLowering.kt @@ -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) } diff --git a/transpiler/javatests/com/google/j2cl/readable/java/autovalue/output_j2kt_web/SimpleAutoValue$GenericType.impl.java.js.txt b/transpiler/javatests/com/google/j2cl/readable/java/autovalue/output_j2kt_web/SimpleAutoValue$GenericType.impl.java.js.txt index a30292f84e..4baf4bc77d 100644 --- a/transpiler/javatests/com/google/j2cl/readable/java/autovalue/output_j2kt_web/SimpleAutoValue$GenericType.impl.java.js.txt +++ b/transpiler/javatests/com/google/j2cl/readable/java/autovalue/output_j2kt_web/SimpleAutoValue$GenericType.impl.java.js.txt @@ -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() {