-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2151 from jjbr/endless-recursion-parent-of-simila…
…r-name Fix for endless recursion bug #2150
- Loading branch information
Showing
3 changed files
with
43 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...src/test/java/com/github/javaparser/symbolsolver/resolution/NotQuiteCyclicParentTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.github.javaparser.symbolsolver.resolution; | ||
|
||
import com.github.javaparser.ast.CompilationUnit; | ||
import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; | ||
import com.github.javaparser.ast.body.MethodDeclaration; | ||
import com.github.javaparser.ast.expr.VariableDeclarationExpr; | ||
import com.github.javaparser.ast.stmt.ExpressionStmt; | ||
import com.github.javaparser.resolution.UnsolvedSymbolException; | ||
import com.github.javaparser.resolution.types.ResolvedType; | ||
import com.github.javaparser.symbolsolver.javaparser.Navigator; | ||
import com.github.javaparser.symbolsolver.javaparsermodel.JavaParserFacade; | ||
import com.github.javaparser.symbolsolver.resolution.typesolvers.ReflectionTypeSolver; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.fail; | ||
|
||
public class NotQuiteCyclicParentTest extends AbstractResolutionTest { | ||
|
||
@Test | ||
void testSimilarNameInterface() { | ||
CompilationUnit cu = parseSample("NotQuiteCyclicParent"); | ||
ClassOrInterfaceDeclaration clazz = Navigator.demandInterface(cu, "NotQuiteCyclicParent"); | ||
MethodDeclaration method = Navigator.demandMethod(clazz, "main"); | ||
VariableDeclarationExpr varDec = | ||
(VariableDeclarationExpr) ((ExpressionStmt) method.getBody().get().getStatement(0)).getExpression(); | ||
|
||
try { | ||
ResolvedType ref = JavaParserFacade.get(new ReflectionTypeSolver()).getType(varDec); | ||
} catch (UnsolvedSymbolException e) { | ||
return; | ||
} | ||
|
||
fail("We shouldn't be able to resolve the type (it is not defined)."); | ||
} | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
javaparser-symbol-solver-testing/src/test/resources/NotQuiteCyclicParent.java.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package foo; | ||
|
||
public interface NotQuiteCyclicParent extends bar.NotQuiteCyclicParent { | ||
default void main() { | ||
MyType x = new MyType(); | ||
} | ||
} |