File tree Expand file tree Collapse file tree
java-frontend/src/test/java/org/sonar/java/model Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2222import org .sonar .java .model .declaration .ClassTreeImpl ;
2323import org .sonar .java .model .declaration .MethodTreeImpl ;
2424import org .sonar .java .model .declaration .VariableTreeImpl ;
25+ import org .sonar .plugins .java .api .semantic .Type ;
2526
2627import static org .assertj .core .api .Assertions .assertThat ;
2728import static org .junit .jupiter .api .Assertions .assertAll ;
@@ -60,6 +61,17 @@ void superClass() {
6061 );
6162 }
6263
64+ @ Test
65+ void testSuperClassWhenSemanticCanNotResolveObjectType () {
66+ var cu = test ("interface I{}" );
67+ var i = (ClassTreeImpl ) cu .types ().get (0 );
68+
69+ JSema sematicThatCanNotResolveObjectType = spy (cu .sema );
70+ when (sematicThatCanNotResolveObjectType .resolveType ("java.lang.Object" )).thenReturn (null );
71+ var typeSymbol = new JTypeSymbol (sematicThatCanNotResolveObjectType , i .typeBinding );
72+ assertThat (typeSymbol .superClass ()).isSameAs (Type .UNKNOWN );
73+ }
74+
6375 @ Test
6476 void interfaces () {
6577 JavaTree .CompilationUnitTreeImpl cu = test ("interface I { } class C implements I { }" );
You can’t perform that action at this time.
0 commit comments