Skip to content

Report an error when AutoFactory implementing methods cannot match create(). - #2166

Open
copybara-service[bot] wants to merge 1 commit into
mainfrom
test_1000110875
Open

copybara-service[bot] wants to merge 1 commit into
mainfrom
test_1000110875

Conversation

@copybara-service

Copy link
Copy Markdown
Contributor

Report an error when AutoFactory implementing methods cannot match create().

When an @AutoFactory(implementing = …) (or extending) abstract method has no matching factory create overload, AutoFactory used to emit a forwarding stub return create(args). If that abstract method was itself named create, the stub called itself and threw StackOverflowError at runtime. The usual trigger is forgetting @Provided on a constructor parameter, which silently turns that parameter into an extra factory argument.

Report a compile-time error that names the unmatched method and points at @Provided, instead of generating the recursive stub.

Closes #697.
Closes #2152.

RELNOTES=AutoFactory now reports a compile-time error when an abstract method from an implementing or extending type does not match any generated factory method, instead of generating a method that fails to compile or calls itself recursively.

…eate().

When an `@AutoFactory(implementing = …)` (or `extending`) abstract method has no matching factory `create` overload, AutoFactory used to emit a forwarding stub `return create(args)`. If that abstract method was itself named `create`, the stub called itself and threw `StackOverflowError` at runtime. The usual trigger is forgetting `@Provided` on a constructor parameter, which silently turns that parameter into an extra factory argument.

Report a compile-time error that names the unmatched method and points at `@Provided`, instead of generating the recursive stub.

Closes #697.
Closes #2152.

RELNOTES=AutoFactory now reports a compile-time error when an abstract method from an `implementing` or `extending` type does not match any generated factory method, instead of generating a method that fails to compile or calls itself recursively.
PiperOrigin-RevId: 1000110875

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AutoFactory: missing @Provided leads to StackOverflowError

1 participant