IDEA-218376 Named param with wrong type is not highlighted properly

GitOrigin-RevId: 902b5732cf9665950677d1321235b0d4687cb45c
This commit is contained in:
alexey.afanasiev
2019-07-16 12:20:00 +03:00
committed by intellij-monorepo-bot
parent 8230f21e50
commit 38b39b952f
2 changed files with 24 additions and 19 deletions
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2017 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.jetbrains.plugins.groovy.lang;
import com.intellij.psi.PsiElement;
@@ -41,13 +27,13 @@ public class GroovySourceCodeNamedArgumentProvider extends GroovyNamedArgumentPr
@NotNull Map<String, NamedArgumentDescriptor> result) {
PsiElement resolve = resolveResult.getElement();
if (resolve instanceof GrMethod) {
result.putAll(((GrMethod)resolve).getNamedParameters());
((GrMethod)resolve).getNamedParameters().forEach((key, value) -> result.putIfAbsent(key, value));
}
else if (resolve instanceof GrField) {
result.putAll(((GrField)resolve).getNamedParameters());
((GrField)resolve).getNamedParameters().forEach((key, value) -> result.putIfAbsent(key, value));
}
else if (resolve instanceof GrVariable) {
result.putAll(GrNamedArgumentSearchVisitor.find((GrVariable)resolve));
GrNamedArgumentSearchVisitor.find((GrVariable)resolve).forEach((key, value) -> result.putIfAbsent(key, value));
}
}
}
@@ -1,4 +1,4 @@
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.jetbrains.plugins.groovy.lang.highlighting
import com.intellij.testFramework.LightProjectDescriptor
@@ -107,4 +107,23 @@ def usage(CopyWith cw) {
def resolved = ref.resolve()
assert resolved instanceof GrField
}
void 'test IDEA-218376'() {
highlightingTest '''
import groovy.transform.CompileStatic
import groovy.transform.NamedParam
@CompileStatic
void namedParams(@NamedParam(value = 'last', type = Integer) Map args, int i) {
print args.last
}
@CompileStatic
def m() {
namedParams(1, last: <error descr="Type of argument 'last' can not be 'String'">"1"</error>)
}
m()
'''
}
}