Skip to content

Support type parameter substitution at call-sites during inlining. - #6039

Merged
copybara-service[bot] merged 1 commit into
masterfrom
test_964303865
Aug 17, 2026
Merged

Support type parameter substitution at call-sites during inlining.#6039
copybara-service[bot] merged 1 commit into
masterfrom
test_964303865

Conversation

@copybara-service

Copy link
Copy Markdown
Contributor

Support type parameter substitution at call-sites during inlining.

When inlining generic methods whose @InlineMe replacement contains type variables
(e.g., Client.<T>after(), new ArrayList<V>(), (T) obj, this.<T>after()),
Inliner now maps method type parameter names to the explicit type arguments
passed at the call-site and substitutes them into the replacement expression.

When explicit type arguments are omitted at the call-site:

  • In method invocations (e.g. Client.<V>after()), unsubstituted type arguments
    are stripped to allow standard compiler type inference (Client.after()).
  • In constructor invocations (e.g. new ArrayList<V>()), unsubstituted type
    arguments are converted to diamond syntax (new ArrayList<>()).
  • In casts (e.g. (T) obj), unresolvable type variable casts are stripped
    (obj), allowing compiler type inference when the cast is unnecessary.

When inlining generic methods whose `@InlineMe` replacement contains type variables
(e.g., `Client.<T>after()`, `new ArrayList<V>()`, `(T) obj`, `this.<T>after()`),
Inliner now maps method type parameter names to the explicit type arguments
passed at the call-site and substitutes them into the replacement expression.

When explicit type arguments are omitted at the call-site:
- In method invocations (e.g. `Client.<V>after()`), unsubstituted type arguments
  are stripped to allow standard compiler type inference (`Client.after()`).
- In constructor invocations (e.g. `new ArrayList<V>()`), unsubstituted type
  arguments are converted to diamond syntax (`new ArrayList<>()`).
- In casts (e.g. `(T) obj`), unresolvable type variable casts are stripped
  (`obj`), allowing compiler type inference when the cast is unnecessary.

PiperOrigin-RevId: 966158769
@copybara-service
copybara-service Bot merged commit b41e2ba into master Aug 17, 2026
@copybara-service
copybara-service Bot deleted the test_964303865 branch August 17, 2026 20:45
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.

1 participant