mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
map literals with 'super' key may be assigned to the classes with a non-default constructor
This commit is contained in:
@@ -66,6 +66,11 @@ public class GppTypeConverter extends GrTypeConverter {
|
||||
(!TypesUtil.isAssignable(lKeyType, parameters[0], context) || !TypesUtil.isAssignable(lValueType, parameters[1], context))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (((GrMapType)rType).getValueType("super") != null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (hasDefaultConstructor(lType)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.intellij.psi.PsiType;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -149,6 +150,11 @@ public class GrMapType extends GrLiteralClassType {
|
||||
return super.equals(obj);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public PsiType getValueType(@NotNull String key) {
|
||||
return myStringEntries.get(key);
|
||||
}
|
||||
|
||||
public boolean isAssignableFrom(@NotNull PsiType type) {
|
||||
return type instanceof GrMapType || myFacade.getElementFactory().createTypeFromText(getJavaClassName(), null).isAssignableFrom(type);
|
||||
}
|
||||
|
||||
+1
-1
@@ -103,7 +103,7 @@ public class GrArgumentLabelImpl extends GroovyPsiElementImpl implements GrArgum
|
||||
}
|
||||
|
||||
final IElementType elemType = element.getNode().getElementType();
|
||||
if (GroovyTokenTypes.mIDENT == elemType) {
|
||||
if (GroovyTokenTypes.mIDENT == elemType || GroovyTokenTypes.KEYWORDS.contains(elemType)) {
|
||||
return element.getText();
|
||||
}
|
||||
|
||||
|
||||
@@ -375,6 +375,16 @@ s.do<caret>Smth()
|
||||
assertEquals "doSmth", ((PsiMethod) findReference().resolve()).name
|
||||
}
|
||||
|
||||
public void testBaseConstructorCallInMapLiteras() throws Exception {
|
||||
configureScript """
|
||||
@Typed File foo() { ['super':['a']] }
|
||||
@Typed File goo() { <warning descr="Cannot assign 'Map' to 'File'">[:]</warning> }
|
||||
File bar() { <warning descr="Cannot assign 'Map' to 'File'">[:]</warning> }
|
||||
"""
|
||||
myFixture.enableInspections new GroovyAssignabilityCheckInspection()
|
||||
myFixture.checkHighlighting(true, false, false)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class GppProjectDescriptor extends DefaultLightProjectDescriptor {
|
||||
|
||||
Reference in New Issue
Block a user