mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
String is assignable to char
This commit is contained in:
+2
@@ -29,6 +29,8 @@ public interface GrClosureSignature {
|
||||
@NotNull
|
||||
GrClosureParameter[] getParameters();
|
||||
|
||||
int getParameterCount();
|
||||
|
||||
boolean isVarargs();
|
||||
|
||||
@Nullable
|
||||
|
||||
+9
-7
@@ -36,7 +36,6 @@ import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrBinaryExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.types.GrClosureParameter;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.types.GrClosureSignature;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.GrClosureType;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.GrTupleType;
|
||||
@@ -50,6 +49,7 @@ import java.util.Map;
|
||||
|
||||
import static com.intellij.psi.CommonClassNames.*;
|
||||
import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.*;
|
||||
import static org.jetbrains.plugins.groovy.lang.psi.util.GroovyCommonClassNames.GROOVY_LANG_GSTRING;
|
||||
import static org.jetbrains.plugins.groovy.lang.psi.util.GroovyCommonClassNames.JAVA_MATH_BIG_DECIMAL;
|
||||
import static org.jetbrains.plugins.groovy.lang.psi.util.GroovyCommonClassNames.JAVA_MATH_BIG_INTEGER;
|
||||
|
||||
@@ -304,6 +304,11 @@ public class TypesUtil {
|
||||
lType = boxPrimitiveType(lType, manager, scope);
|
||||
}
|
||||
|
||||
if (unboxPrimitiveTypeWrapper(lType) == PsiType.CHAR &&
|
||||
(typeEqualsToText(rType, GROOVY_LANG_GSTRING) || typeEqualsToText(rType, JAVA_LANG_STRING))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return TypeConversionUtil.isAssignable(lType, rType);
|
||||
|
||||
}
|
||||
@@ -393,13 +398,10 @@ public class TypesUtil {
|
||||
else if (type1 instanceof GrClosureType && type2 instanceof GrClosureType) {
|
||||
GrClosureType clType1 = (GrClosureType)type1;
|
||||
GrClosureType clType2 = (GrClosureType)type2;
|
||||
GrClosureSignature signature1=clType1.getSignature();
|
||||
GrClosureSignature signature2=clType2.getSignature();
|
||||
GrClosureSignature signature1 = clType1.getSignature();
|
||||
GrClosureSignature signature2 = clType2.getSignature();
|
||||
|
||||
GrClosureParameter[] parameters1 = signature1.getParameters();
|
||||
GrClosureParameter[] parameters2 = signature2.getParameters();
|
||||
|
||||
if (parameters1.length == parameters2.length) {
|
||||
if (signature1.getParameterCount() == signature2.getParameterCount()) {
|
||||
final GrClosureSignature signature = GrClosureSignatureImpl.getLeastUpperBound(signature1, signature2, manager);
|
||||
if (signature != null) {
|
||||
GlobalSearchScope scope = clType1.getResolveScope().intersectWith(clType2.getResolveScope());
|
||||
|
||||
+5
@@ -82,6 +82,11 @@ public class GrClosureSignatureImpl implements GrClosureSignature {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getParameterCount() {
|
||||
return myParameters.length;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public GrClosureSignature curry(int count) {
|
||||
if (count > myParameters.length) {
|
||||
|
||||
@@ -375,4 +375,8 @@ public class GroovyHighlightingTest extends LightCodeInsightFixtureTestCase {
|
||||
doTest(new UnusedDefInspection());
|
||||
}
|
||||
|
||||
public void testStringAssignableToChar() {
|
||||
doTest(new GroovyAssignabilityCheckInspection());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
def a='string text'
|
||||
char ch = a //here should not be inspection warning
|
||||
int x = <warning descr="Cannot assign 'String' to 'int'">a</warning> //check that assignability inspection is on.
|
||||
Reference in New Issue
Block a user