[groovy] methods with default parameters are not abstract in traits even if code method is abstract

This commit is contained in:
Daniil Ovchinnikov
2016-06-20 18:48:50 +03:00
parent d2b1009812
commit 84546a6db5
2 changed files with 23 additions and 1 deletions
@@ -95,7 +95,7 @@ public class GrReflectedMethodImpl extends LightMethodBuilder implements GrRefle
final GrLightModifierList myModifierList = ((GrLightModifierList)getModifierList());
for (String modifier : GrModifier.GROOVY_MODIFIERS) {
if (baseMethod.hasModifierProperty(modifier)) {
if (baseMethod.getModifierList().hasExplicitModifier(modifier)) {
myModifierList.addModifier(modifier);
}
}
@@ -15,6 +15,7 @@
*/
package org.jetbrains.plugins.groovy.lang.highlighting
import com.intellij.codeInsight.generation.OverrideImplementExploreUtil
import com.intellij.codeInspection.InspectionProfileEntry
import com.intellij.testFramework.LightProjectDescriptor
import org.jetbrains.annotations.NotNull
@@ -136,5 +137,26 @@ trait T {
}
}
void 'test trait with method with default parameters'() {
testHighlighting '''\
trait A {
def foo(a, b = null, c = null) {}
}
class B implements A {}
'''
}
void 'test trait with abstract method with default parameters'() {
testHighlighting '''
trait A {
abstract foo(a, b = null, c = null)
}
<error descr="Method 'foo' is not implemented">class B implements A</error> {}
'''
def definition = fixture.findClass('B') as GrTypeDefinition
def map = OverrideImplementExploreUtil.getMapToOverrideImplement(definition, true)
assert map.size() == 1 // need to implement only foo(a, b, c)
}
final InspectionProfileEntry[] customInspections = [new GroovyAssignabilityCheckInspection(), new GrUnresolvedAccessInspection()]
}