mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-123484 anonymous from traits are not allowed
This commit is contained in:
@@ -376,3 +376,4 @@ declared.type.0.have.to.extend.script=Declared type ''{0}'' does not extend 'gro
|
||||
base.script.annotation.is.allowed.only.inside.scripts=Annotation @BaseScript can only be used within a script
|
||||
0.expressions.on.trait.fields.properties.are.not.supported.in.traits={0} expressions on trait fields/properties are not supported in traits
|
||||
only.traits.expected.here=Only traits are expected here
|
||||
anonymous.classes.cannot.be.created.from.traits=Anonymous classes cannot be created from traits
|
||||
|
||||
@@ -2001,9 +2001,13 @@ public class GroovyAnnotator extends GroovyElementVisitor {
|
||||
final GroovyConfigUtils configUtils = GroovyConfigUtils.getInstance();
|
||||
if (typeDefinition.isAnonymous()) {
|
||||
if (!configUtils.isVersionAtLeast(typeDefinition, GroovyConfigUtils.GROOVY1_7)) {
|
||||
holder.createErrorAnnotation(typeDefinition.getNameIdentifierGroovy(), GroovyBundle.message("anonymous.classes.are.not.supported",
|
||||
configUtils
|
||||
.getSDKVersion(typeDefinition)));
|
||||
holder.createErrorAnnotation(typeDefinition.getNameIdentifierGroovy(),
|
||||
GroovyBundle.message("anonymous.classes.are.not.supported", configUtils.getSDKVersion(typeDefinition)));
|
||||
}
|
||||
|
||||
PsiElement superClass = ((PsiAnonymousClass)typeDefinition).getBaseClassReference().resolve();
|
||||
if (superClass instanceof GrTypeDefinition && ((GrTypeDefinition)superClass).isTrait()) {
|
||||
holder.createErrorAnnotation(typeDefinition.getNameIdentifierGroovy(), GroovyBundle.message("anonymous.classes.cannot.be.created.from.traits"));
|
||||
}
|
||||
}
|
||||
else if (typeDefinition.getContainingClass() != null && !(typeDefinition instanceof GrEnumTypeDefinition)) {
|
||||
|
||||
+8
@@ -1868,6 +1868,14 @@ trait C {
|
||||
<error descr="++ expressions on trait fields/properties are not supported in traits">x++</error>
|
||||
}
|
||||
}
|
||||
''')
|
||||
}
|
||||
|
||||
void testTraitAsAnonymous() {
|
||||
testHighlighting('''
|
||||
trait T {}
|
||||
|
||||
new <error descr="Anonymous classes cannot be created from traits">T</error>(){}
|
||||
''')
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user