The solution is really simple and non-invasive: in the context scan flow, when scan(basePackages) is invoked, we deal with resources instead of classes. Before any further evaluations, these resources need to be sorted based on how many "$" are present in the filename. When a valid candidate is excluded because of a non-matching condition, the corresponding filename is added to a list. Before registering a candidate, this list is consulted. The candidate is registered if the list doesn't contain the candidate's parent filename.

Closes #29372

Comment From: cagliostro92

@bclozel do you think that can be merged?

Comment From: cagliostro92

@snicoll is it possible to get feedback about this contribution?

Comment From: snicoll

@EdoardoP92 paging individual team members isn't going to help this PR to be reviewed faster. We're doing our best with our current priorities and we'll get to it as soon as possible. Thank you for your patience.

Comment From: jhoeller

Closing this PR along with #29372 and #30750 since classpath scanning is meant to find such nested classes independently when they carry their own stereotype annotation.