File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
python-frontend/src/test/java/org/sonar/python/semantic/v2 Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -774,6 +774,40 @@ class A:
774774 });
775775 }
776776
777+ @ Test
778+ void conflictBetweenFunctionAndStaticField () {
779+ var code = """
780+ class A:
781+ something: int = 42
782+ def something(self): ...
783+ A
784+ """ ;
785+ Expression expr = lastExpression (code );
786+ assertThat (expr .typeV2 ())
787+ .isInstanceOfSatisfying (ClassType .class , classType -> {
788+ assertThat (classType .members ())
789+ .containsExactlyInAnyOrder (
790+ new Member ("something" , ObjectType .fromType (INT_TYPE )),
791+ new Member ("something" , PythonType .UNKNOWN ));
792+ // There should be a FunctionType, see SONARPY-3553 and SONARPY-3554
793+ });
794+ }
795+
796+ @ Test
797+ void conflictBetweenFunctionDefinitions () {
798+ var code = """
799+ class A:
800+ def a(self): ...
801+ def a(self): ...
802+ A
803+ """ ;
804+ Expression expr = lastExpression (code );
805+ assertThat (expr .typeV2 ()).isInstanceOfSatisfying (ClassType .class , classType -> {
806+ assertThat (classType .members ()).containsExactly (new Member ("a" , PythonType .UNKNOWN ));
807+ // should resolve to the FunctionType, see SONARPY-3554 and SONARPY-3553
808+ });
809+ }
810+
777811 @ Test
778812 void staticFieldsInInheritedClasses () {
779813 Expression exprWithInheritance = lastExpression ("""
You can’t perform that action at this time.
0 commit comments