-
Notifications
You must be signed in to change notification settings - Fork 93
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-2316 Resolve field members of a ClassType #2163
Conversation
c91153d
to
18232f2
Compare
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!
I left clarification questions and a few comments. Well done!
@@ -70,6 +70,13 @@ public SymbolImpl(String name, @Nullable String fullyQualifiedName) { | |||
this.kind = Kind.OTHER; | |||
} | |||
|
|||
public SymbolImpl(String name, @Nullable String fullyQualifiedName, @Nullable String annotatedTypeName) { |
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.
minor you can slightly modify the constructor above to call the new one you ve created.
public SymbolImpl(String name, @Nullable String fullyQualifiedName) {
this(name, fullyQualifiedName, null);
}
@@ -70,6 +70,13 @@ public SymbolImpl(String name, @Nullable String fullyQualifiedName) { | |||
this.kind = Kind.OTHER; | |||
} | |||
|
|||
public SymbolImpl(String name, @Nullable String fullyQualifiedName, @Nullable String annotatedTypeName) { |
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.
question It seems there are only a few unit tests for this class. May be you can add a unit test in SymbolImplTest
to test the constructor you have created?
scan(assignmentStatement.assignedValue()); | ||
scan(assignmentStatement.annotation()); | ||
scan(assignmentStatement.variable()); |
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.
any reason you don't call super
? Tests in TypeInferenceV2Test
are still green if I use the call to super
scan(assignmentStatement.assignedValue()); | |
scan(assignmentStatement.annotation()); | |
scan(assignmentStatement.variable()); | |
super.visitAnnotatedAssignment(assignmentStatement); |
.filter(NameImpl.class::isInstance) | ||
.map(NameImpl.class::cast) | ||
.ifPresent(lhsName -> { | ||
if (currentType() instanceof ClassType) { |
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.
question this line is to check that you are in a class definition right?
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.
discussed
class A: | ||
test = "hi" | ||
test = True |
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.
I suggest that you update the test with type hint to ensure that the type of test
Symbol is bool
in the end.
class A: | |
test = "hi" | |
test = True | |
class A: | |
test : str = "hi" | |
test : bool = True |
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.
test added
@@ -562,10 +631,13 @@ class B: | |||
test = "hi" | |||
class C(A, B): | |||
pass | |||
C.test |
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.
why do you have to remove the access to the field test
everywhere?
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.
discussed
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!
5d5a23c
to
aa163b8
Compare
Quality Gate passedIssues Measures |
SONARPY-2316