forked from javaparser/javaparser
-
Notifications
You must be signed in to change notification settings - Fork 9
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 javaparser#4128 from jlerbsc/master
Fix: issue 3976 Issue resolving implicit generic types
- Loading branch information
Showing
2 changed files
with
109 additions
and
0 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
35 changes: 35 additions & 0 deletions
35
...symbol-solver-testing/src/test/java/com/github/javaparser/symbolsolver/Issue3976Test.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,35 @@ | ||
package com.github.javaparser.symbolsolver; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.condition.EnabledForJreRange; | ||
import org.junit.jupiter.api.condition.JRE; | ||
|
||
import com.github.javaparser.JavaParserAdapter; | ||
import com.github.javaparser.ast.CompilationUnit; | ||
import com.github.javaparser.ast.expr.MethodCallExpr; | ||
import com.github.javaparser.resolution.types.ResolvedType; | ||
import com.github.javaparser.symbolsolver.resolution.AbstractResolutionTest; | ||
|
||
public class Issue3976Test extends AbstractResolutionTest { | ||
|
||
@Test | ||
@EnabledForJreRange(min = JRE.JAVA_9) | ||
void test() { | ||
String testCase = | ||
"import java.util.Map;\n" | ||
+ "public class Foo {\n" | ||
+ " public Object m() {\n" | ||
+ " return Map.of(\"k0\", 0, \"k1\", 1D);\n" | ||
+ " }\n" | ||
+ "}"; | ||
|
||
CompilationUnit cu = JavaParserAdapter.of(createParserWithResolver(defaultTypeSolver())).parse(testCase); | ||
|
||
MethodCallExpr methodCallExpr = cu.findFirst(MethodCallExpr.class).get(); | ||
|
||
ResolvedType rt = methodCallExpr.calculateResolvedType(); | ||
assertEquals("java.util.Map<java.lang.String, java.lang.Number>", rt.describe()); | ||
} | ||
} |