fix: improve type inference for generics in invoke insn (#927)

This commit is contained in:
Skylot
2020-05-10 14:20:27 +01:00
parent b1d5ed0066
commit 404136cd72
4 changed files with 205 additions and 26 deletions
@@ -0,0 +1,44 @@
package jadx.tests.integration.types;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Test;
import jadx.tests.api.IntegrationTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestGenerics5 extends IntegrationTest {
public static class TestCls {
private InheritableThreadLocal<Map<String, String>> inheritableThreadLocal;
public void put(String key, String val) {
if (key == null) {
throw new IllegalArgumentException("key cannot be null");
}
Map<String, String> map = this.inheritableThreadLocal.get();
if (map == null) {
map = new HashMap<>();
this.inheritableThreadLocal.set(map);
}
map.put(key, val);
}
public void remove(String key) {
Map<String, String> map = this.inheritableThreadLocal.get();
if (map != null) {
map.remove(key);
}
}
}
@Test
public void test() {
noDebugInfo();
assertThat(getClassNode(TestCls.class))
.code()
.countString(2, "Map<String, String> map = this.inheritableThreadLocal.get();");
}
}