Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArC - injection point validation #24353

Merged
merged 1 commit into from
Mar 18, 2022

Conversation

mkouba
Copy link
Contributor

@mkouba mkouba commented Mar 16, 2022

  • type variable is not a legal injection point type
  • also validate type params of types related to programmatic lookup,
    i.e. Instance<> and List<> with All qualifier

@mkouba mkouba requested review from Ladicek and manovotn March 16, 2022 15:08
@mkouba mkouba added this to the 2.8 - main milestone Mar 16, 2022
@quarkus-bot quarkus-bot bot added area/arc Issue related to ARC (dependency injection) area/documentation labels Mar 16, 2022
Copy link
Contributor

@Ladicek Ladicek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, though I have reservations about the error messages. Wildcards and type variables are legal type arguments. IMHO, the errors should read more like "Injection point may not contain a wildcard type argument" or so.

Note I'm specifically using the term "type argument" instead of "type parameter". I'd encourage to follow this convention. In a function declaration, we define parameters. In a function call, we pass arguments. The same applies to generics. In a generic class/method declaration, we define type parameters (e.g. in class List<T> { ... }, T is a type parameter). In a generic instantiation of a class/method, we pass type arguments (e.g. in List<String>, String is a type argument).

@mkouba
Copy link
Contributor Author

mkouba commented Mar 16, 2022

LGTM, though I have reservations about the error messages. Wildcards and type variables are legal type arguments. IMHO, the errors should read more like "Injection point may not contain a wildcard type argument" or so.

Actually, the error message for @Inject T is "Type variable is not a legal injection point type" which is IMO correct. "Injection point may not contain a wildcard type argument" is not exact because @Inject List<T> is OK.

Note I'm specifically using the term "type argument" instead of "type parameter".

Ok, I'll update the error message for Instance to use the "type argument".

@Ladicek
Copy link
Contributor

Ladicek commented Mar 16, 2022

Some tests assert an error message of "Type variable is not a legal injection point type", which is totally fine. Other tests assert an error message of "Type variable is not a legal type parameter", and that's what I'm objecting about.

@quarkus-bot

This comment has been minimized.

@mkouba mkouba force-pushed the arc-validate-type-params branch from 02a9557 to cd4c003 Compare March 17, 2022 07:24
@mkouba mkouba added the triage/waiting-for-ci Ready to merge when CI successfully finishes label Mar 17, 2022
Copy link
Contributor

@manovotn manovotn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and consistent with what we do in Weld.

@quarkus-bot

This comment has been minimized.

@mkouba
Copy link
Contributor Author

mkouba commented Mar 17, 2022

I need to fix the io.quarkus.qute.deployment.inject.InjectionFailedTest...

- type variable is not a legal injection point type
- also validate type params of types related to programmatic lookup,
i.e. Instance<> and List<> with All qualifier
@mkouba mkouba force-pushed the arc-validate-type-params branch from cd4c003 to 58eada9 Compare March 17, 2022 12:41
@quarkus-bot quarkus-bot bot added the area/qute The template engine label Mar 17, 2022
@mkouba mkouba merged commit 1b07b91 into quarkusio:main Mar 18, 2022
@quarkus-bot quarkus-bot bot removed the triage/waiting-for-ci Ready to merge when CI successfully finishes label Mar 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/arc Issue related to ARC (dependency injection) area/documentation area/qute The template engine
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants