From 12a16caf69731a2d2f2d5f8d167d858e7b64c09a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bendeg=C3=BAz=20Nagy?= Date: Sat, 8 Jul 2017 20:22:35 +0200 Subject: [PATCH] Java, typeres: add vararg most specific tests --- .../pmd/typeresolution/ClassTypeResolverTest.java | 4 ++++ .../pmd/typeresolution/testdata/MethodThirdPhase.java | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/typeresolution/ClassTypeResolverTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/typeresolution/ClassTypeResolverTest.java index 675791ba24..5a493f9e1f 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/typeresolution/ClassTypeResolverTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/typeresolution/ClassTypeResolverTest.java @@ -1325,6 +1325,10 @@ public class ClassTypeResolverTest { assertEquals(int.class, expressions.get(index).getType()); assertEquals(int.class, getChildType(expressions.get(index), 0)); assertEquals(int.class, getChildType(expressions.get(index++), 1)); + // String d = mostSpecific(10, 10, 10); + assertEquals(String.class, expressions.get(index).getType()); + assertEquals(String.class, getChildType(expressions.get(index), 0)); + assertEquals(String.class, getChildType(expressions.get(index++), 1)); // Make sure we got them all assertEquals("All expressions not tested", index, expressions.size()); diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/typeresolution/testdata/MethodThirdPhase.java b/pmd-java/src/test/java/net/sourceforge/pmd/typeresolution/testdata/MethodThirdPhase.java index 290ed7cb03..e7740157d1 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/typeresolution/testdata/MethodThirdPhase.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/typeresolution/testdata/MethodThirdPhase.java @@ -15,8 +15,16 @@ public class MethodThirdPhase { // component type determined properly int c = vararg(10, "", "", ""); - // TODO: add most specific tests among vararg conversion + // most specific vararg method + String d = mostSpecific(10, 10, 10); + } + Exception mostSpecific(Number... b) { + return null; + } + + String mostSpecific(Integer... b) { + return null; } Exception vararg(int a, Number... b) {