-
Notifications
You must be signed in to change notification settings - Fork 85
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
SONARPY-1826 Enable flow sensitive type inference for function types #1796
Conversation
dd172c5
to
56fbaa2
Compare
public abstract class Propagation { | ||
|
||
final Set<SymbolV2> variableDependencies = new HashSet<>(); | ||
final Set<Propagation> dependents = new HashSet<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
initialize in the constructor?
lhsSymbol.usages().stream() | ||
.filter(u -> !SymbolV2Utils.isFunctionOrClassDeclaration(u)) | ||
.map(UsageV2::tree) | ||
.filter(NameImpl.class::isInstance) | ||
.map(NameImpl.class::cast) | ||
.forEach(n -> n.typeV2(rhsType)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this part is the same as usages stream below, so maybe it makes sense to extend this common part?
return lhsName.symbolV2().usages() | ||
.stream() | ||
.filter(u -> !SymbolV2Utils.isFunctionOrClassDeclaration(u)) | ||
.map(UsageV2::tree) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we can simply move this part to SymbolV2Utils:
public static Stream<Tree> getSymbolNonDeclarationUsageTrees(SymbolV2 symbol) {
return symbol.usages()
.stream()
.filter(u -> !SymbolV2Utils.isFunctionOrClassDeclaration(u))
.map(UsageV2::tree)
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! I extracted this into a dedicated method.
However, I kept it in Propagation
, as I want the filtering out of definitions to be super explicit (I think it only makes sense in this specific case). I added a comment to clarify this in the now mutualized method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, see a couple of small comments
b7005eb
to
aeec2cd
Compare
56fbaa2
to
68ead15
Compare
Quality Gate failedFailed conditions See analysis details on SonarQube Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
7f31bba
to
6b08403
Compare
4920279
into
MMF-3796
No description provided.