From 586f95367cb50086b69f56d3f76bc0fdf800b3a3 Mon Sep 17 00:00:00 2001 From: Maxim Medvedev Date: Fri, 30 Jul 2010 16:38:58 +0400 Subject: [PATCH] IDEA-56950 IDEA doesn't consider types int and Integer as identical --- .../lang/psi/impl/statements/expressions/TypesUtil.java | 3 ++- .../statements/expressions/path/GrIndexPropertyImpl.java | 5 +++-- .../org/jetbrains/plugins/groovy/GroovyCompletionTest.java | 5 ++++- .../jetbrains/plugins/groovy/GroovyCompletionTestBase.java | 2 +- .../groovy/completion/IntCompletionInGenericParameter.groovy | 2 ++ .../completion/IntCompletionInGenericParameter_after.groovy | 2 ++ .../groovy/completion/IntCompletionInPlusMethod.groovy | 5 +++++ .../groovy/completion/IntCompletionInPlusMethod_after.groovy | 5 +++++ 8 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 plugins/groovy/testdata/groovy/completion/IntCompletionInGenericParameter.groovy create mode 100644 plugins/groovy/testdata/groovy/completion/IntCompletionInGenericParameter_after.groovy create mode 100644 plugins/groovy/testdata/groovy/completion/IntCompletionInPlusMethod.groovy create mode 100644 plugins/groovy/testdata/groovy/completion/IntCompletionInPlusMethod_after.groovy diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/TypesUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/TypesUtil.java index 26a0d6868e64..9b1707f9aa02 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/TypesUtil.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/TypesUtil.java @@ -103,7 +103,8 @@ public class TypesUtil { if (candidates.length == 1) { final PsiElement element = candidates[0].getElement(); if (element instanceof PsiMethod) { - return candidates[0].getSubstitutor().substitute(PsiUtil.getSmartReturnType((PsiMethod)element)); + return boxPrimitiveType(candidates[0].getSubstitutor().substitute(PsiUtil.getSmartReturnType((PsiMethod)element)), + place.getManager(), place.getResolveScope()); } } return null; diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/path/GrIndexPropertyImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/path/GrIndexPropertyImpl.java index 4bf6c6faf70f..4e9f16abf393 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/path/GrIndexPropertyImpl.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/path/GrIndexPropertyImpl.java @@ -102,12 +102,13 @@ public class GrIndexPropertyImpl extends GrExpressionImpl implements GrIndexProp componentType = TypesUtil.boxPrimitiveType(((PsiArrayType)thisType).getComponentType(), getManager(), getResolveScope()); } else if (InheritanceUtil.isInheritor(thisType, CommonClassNames.JAVA_UTIL_MAP) && argTypes.length == 1) { - componentType = substituteTypeParameter(thisType, CommonClassNames.JAVA_UTIL_MAP, 1, true); + componentType = TypesUtil + .boxPrimitiveType(substituteTypeParameter(thisType, CommonClassNames.JAVA_UTIL_MAP, 1, true), getManager(), getResolveScope()); } if (overloadedOperatorType != null && (componentType == null || !TypesUtil.isAssignable(overloadedOperatorType, componentType, getManager(), getResolveScope()))) { - return overloadedOperatorType; + return TypesUtil.boxPrimitiveType(overloadedOperatorType, getManager(), getResolveScope()); } return componentType; } diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/GroovyCompletionTest.java b/plugins/groovy/test/org/jetbrains/plugins/groovy/GroovyCompletionTest.java index bde311d89c66..6f925ecd5edb 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/GroovyCompletionTest.java +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/GroovyCompletionTest.java @@ -230,4 +230,7 @@ public class GroovyCompletionTest extends GroovyCompletionTestBase { "}"); doSmartTest(); } -} + + public void testIntCompletionInPlusMethod() {doBasicTest();} + public void testIntCompletionInGenericParameter() {doBasicTest();} +} \ No newline at end of file diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/GroovyCompletionTestBase.java b/plugins/groovy/test/org/jetbrains/plugins/groovy/GroovyCompletionTestBase.java index 467fdaf3cde7..524a00ba742c 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/GroovyCompletionTestBase.java +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/GroovyCompletionTestBase.java @@ -31,7 +31,7 @@ abstract public class GroovyCompletionTestBase extends LightCodeInsightFixtureTe myFixture.checkResultByFile(getTestName(false) + "_after.groovy", true); } - protected void doBasicTest() throws Exception { + protected void doBasicTest() { myFixture.testCompletion(getTestName(false) + ".groovy", getTestName(false) + "_after.groovy"); } diff --git a/plugins/groovy/testdata/groovy/completion/IntCompletionInGenericParameter.groovy b/plugins/groovy/testdata/groovy/completion/IntCompletionInGenericParameter.groovy new file mode 100644 index 000000000000..bcc8971c1f4c --- /dev/null +++ b/plugins/groovy/testdata/groovy/completion/IntCompletionInGenericParameter.groovy @@ -0,0 +1,2 @@ +List list +list.get(0).intV \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/completion/IntCompletionInGenericParameter_after.groovy b/plugins/groovy/testdata/groovy/completion/IntCompletionInGenericParameter_after.groovy new file mode 100644 index 000000000000..eb07dd8424d9 --- /dev/null +++ b/plugins/groovy/testdata/groovy/completion/IntCompletionInGenericParameter_after.groovy @@ -0,0 +1,2 @@ +List list +list.get(0).intValue() \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/completion/IntCompletionInPlusMethod.groovy b/plugins/groovy/testdata/groovy/completion/IntCompletionInPlusMethod.groovy new file mode 100644 index 000000000000..e057df79f2e6 --- /dev/null +++ b/plugins/groovy/testdata/groovy/completion/IntCompletionInPlusMethod.groovy @@ -0,0 +1,5 @@ +class X { + int plus(X x) {} +} + +(new X()+new X()).intV \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/completion/IntCompletionInPlusMethod_after.groovy b/plugins/groovy/testdata/groovy/completion/IntCompletionInPlusMethod_after.groovy new file mode 100644 index 000000000000..d068bce94894 --- /dev/null +++ b/plugins/groovy/testdata/groovy/completion/IntCompletionInPlusMethod_after.groovy @@ -0,0 +1,5 @@ +class X { + int plus(X x) {} +} + +(new X()+new X()).intValue() \ No newline at end of file