[groovy] fix AIOOBE (EA-67879)

This commit is contained in:
Daniil Ovchinnikov
2017-02-07 01:31:07 +03:00
parent 9f9ab95d9b
commit edec513df0
2 changed files with 19 additions and 3 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,7 +20,10 @@ import com.intellij.openapi.util.Couple;
import com.intellij.openapi.util.VolatileNotNullLazyValue;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.*;
import com.intellij.psi.JavaPsiFacade;
import com.intellij.psi.PsiClassType;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiType;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
@@ -107,7 +110,12 @@ public abstract class GrMapType extends GrLiteralClassType {
if (otherEntries.isEmpty()) return "[:]";
String name = getJavaClassName();
final PsiType[] params = getParameters();
return name + "<" + getInternalText(params[0]) + ", " + getInternalText(params[1]) + ">";
if (params.length == 2) {
return name + "<" + getInternalText(params[0]) + ", " + getInternalText(params[1]) + ">";
}
else {
return name;
}
}
List<String> components = new ArrayList<>();
@@ -56,6 +56,14 @@ interface X {
method([X.C, X.D])
method2([a: X.C, b: X.D])
'''
}
void 'test map without string keys and values'() {
testHighlighting '''\
def foo(int a) {}
def m = [(aa): (<error descr="Expression expected">)</error>]
foo<warning descr="'foo' in '_' cannot be applied to '(java.util.LinkedHashMap)'">(m)</warning>
'''
}
}