[groovy] do not highlight default parameters in abstract methods as forbidden (IDEA-128293)

This commit is contained in:
Daniil Ovchinnikov
2016-03-10 19:59:22 +03:00
parent 72a7eec0a4
commit 9ba817aa50
3 changed files with 41 additions and 3 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2016 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.
@@ -736,6 +736,7 @@ public class GroovyAnnotator extends GroovyElementVisitor {
private static void checkOptionalParametersInAbstractMethod(AnnotationHolder holder, GrMethod method) {
if (!method.hasModifierProperty(PsiModifier.ABSTRACT)) return;
if (!(method.getContainingClass() instanceof GrInterfaceDefinition)) return;
for (GrParameter parameter : method.getParameters()) {
GrExpression initializerGroovy = parameter.getInitializerGroovy();
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2016 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.
@@ -82,5 +82,14 @@ def foo() {
''')
}
void 'test default parameter in trait methods'() {
testHighlighting '''\
trait T {
abstract foo(x = 3);
def bar(y = 6) {}
}
'''
}
final InspectionProfileEntry[] customInspections = [new GroovyAssignabilityCheckInspection(), new GrUnresolvedAccessInspection()]
}
@@ -3,7 +3,35 @@ interface I {
}
abstract class A {
abstract foo(int x<error descr="Default initializers are not allowed in abstract methods"> = 5</error>)
abstract foo(int x = 5)
def abr(int x = 5){}
}
enum E {
ONE {
def foo(x) {}
};
abstract foo(x = 3)
def bar(y = 12) {}
}
@interface An {
int foo()
String bar(x = 2)
}
def a = new Runnable() {
void run() {}
<error descr="Anonymous class cannot have abstract method">abstract</error> foo(x = 5);
}
enum EE {
T {
def foo() {}
<error descr="Anonymous class cannot have abstract method">abstract</error> bar(x = 4);
};
def foo() {}
}