Repository navigation
resolve the payload type from the class declaration - #421
Open
rootkiller6788 wants to merge 2 commits into
Open
rootkiller6788 wants to merge 2 commits into
rootkiller6788 wants to merge 2 commits into
Conversation
When the accept method lives in a base class, the subclass only has the erased accept(Object, Context), so the payload type comes out empty. This test fails right now.
The accept method alone is not enough: if the subclass inherits accept from a base class, the only copy it has is the erased accept(Object, Context), so we could not tell what the payload type was. Read the type argument of BackgroundFunction<T> by walking the class hierarchy instead, substituting type variables as we go up. The accept method lookup is still there as a fallback for classes where the declaration does not say. Fixes GoogleCloudPlatform#95.
rootkiller6788
marked this pull request as ready for review
November 26, 2026 11:31
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.
Fixes #95.
A function that extends a base class implementing accept() for all its subclasses would not start, with "Could not determine the payload type for BackgroundFunction of type ...".
Reason is that the payload type was read off the accept method, but a subclass that does not declare accept itself only has the inherited, erased accept(Object, Context), so the lookup came back empty.
The type argument of BackgroundFunction is now read from the class declaration, walking up the hierarchy and substituting type variables on the way. That covers the inherited accept case and generic base classes, and if the declaration does not pin the type down (raw implementations, for example) it still falls back to the old accept lookup, so nothing that worked before changes.
Tests added for the inherited case and for two levels of inheritance; both fail without the change. On my machine the rest of the invoker/core suite fails the same way before and after.