[java] skips reference check for array annotations (IDEA-195612)

This commit is contained in:
Roman Shevchenko
2018-07-16 18:13:14 +02:00
parent d0812f7050
commit 547f2b3967
2 changed files with 4 additions and 17 deletions

View File

@@ -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-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.
package com.intellij.codeInsight.daemon.impl.analysis;
import com.intellij.codeInsight.AnnotationTargetUtil;
@@ -390,7 +376,7 @@ public class AnnotationsHighlightUtil {
String message = JavaErrorMessages.message("annotation.not.allowed.void");
return annotationError(annotation, message);
}
if (!(type instanceof PsiPrimitiveType)) {
if (!(type instanceof PsiPrimitiveType || type instanceof PsiArrayType)) {
PsiJavaCodeReferenceElement ref = getOutermostReferenceElement(typeElement.getInnermostComponentReferenceElement());
HighlightInfo info = checkReferenceTarget(annotation, ref);
if (info != null) return info;

View File

@@ -49,6 +49,7 @@ class Outer {
static class StaticInner {
void test() {
@TA StaticInner v1;
StaticMiddle.@TA StaticInner @TA [] @TA [] va;
<error descr="Static member qualifying type may not be annotated">@TA</error> StaticMiddle.@TA StaticInner v2;
<error descr="Static member qualifying type may not be annotated">@TA</error> Outer.<error descr="Static member qualifying type may not be annotated">@TA</error> StaticMiddle.@TA StaticInner v3;
List<Outer.<error descr="Static member qualifying type may not be annotated">@TA</error> StaticMiddle.@TA StaticInner> l1;
@@ -132,4 +133,4 @@ class Outer {
IntFunction<Super> f = Outer.<error descr="Annotations are not allowed here">@TA</error> This.super::getField;
}
}
}
}