mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[groovy] do not highlight default parameters in abstract methods as forbidden (IDEA-128293)
This commit is contained in:
+2
-1
@@ -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();
|
||||
|
||||
+10
-1
@@ -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()]
|
||||
}
|
||||
|
||||
Vendored
+29
-1
@@ -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() {}
|
||||
}
|
||||
Reference in New Issue
Block a user