Resolve bridge methods for multi-level generic Kotlin suspend overrides - #37368
Closed
Asthenia0412 wants to merge 1 commit into
Closed
Asthenia0412 wants to merge 1 commit into
Asthenia0412 wants to merge 1 commit into
Conversation
BridgeMethodResolver.checkResolvedTypeMatch compares the resolved generic return type against the candidate method's JVM return type. For Kotlin suspending functions, the JVM return type is always Object regardless of the declared return type, so the return type check rejects valid candidates in multi-level generic hierarchies where multiple non-bridge candidates exist. Skip the return type check when the candidate method is a Kotlin suspending function (detected via KotlinDetector.isSuspendingFunction), allowing the parameter type match to select the correct bridged method. Closes spring-projectsgh-37125
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
BridgeMethodResolver.checkResolvedTypeMatchcompares the resolved generic return type against the candidate method's JVM return type. For Kotlin suspending functions, the JVM return type is alwaysObjectregardless of the declared return type, so the return type check rejects valid candidates in multi-level generic hierarchies where multiple non-bridge candidates exist.This is the multi-implementation counterpart of #33045: the single-candidate shortcut returns the candidate directly, but the candidate-search path performs the return type check and fails for Kotlin suspend functions.
Changes
In
checkResolvedTypeMatch, skip the return type check when the candidate method is a Kotlin suspending function (detected viaKotlinDetector.isSuspendingFunction). The parameter type match still selects the correct bridged method.Related Issue
BridgeMethodResolverdoes not resolve bridge methods for multi-level generic Kotlin suspend overrides #37125