void (@NotNull GrTypeArgumentList typeArgumentList) { PsiElement parent = typeArgumentList.getParent(); if (!(parent instanceof GrReferenceElement)) return; if (parent instanceof GrCodeReferenceElement && !mayContainTypeArguments((GrCodeReferenceElement)parent)) { myHolder.newAnnotation(HighlightSeverity.ERROR, GroovyBundle.message("type.argument.list.is.not.allowed.here")).create(); return; } final GroovyResolveResult resolveResult = ((GrReferenceElement<?>)parent).advancedResolve(); final PsiElement resolved = resolveResult.getElement(); final PsiSubstitutor substitutor = resolveResult.getSubstitutor(); if (resolved == null) return; if (!(resolved instanceof PsiTypeParameterListOwner)) { myHolder.newAnnotation(HighlightSeverity.WARNING, GroovyBundle.message("type.argument.list.is.not.allowed.here")).create(); return; } if (typeArgumentList.isDiamond()) return; final PsiTypeParameter[] parameters = ((PsiTypeParameterListOwner)resolved).getTypeParameters(); final GrTypeElement[] arguments = typeArgumentList.getTypeArgumentElements(); if (arguments.length != parameters.length) { myHolder.newAnnotation(HighlightSeverity.WARNING, GroovyBundle.message("wrong.number.of.type.arguments", arguments.length, parameters.length)).create(); return; } for (int i = 0; i < parameters.length; i++) { PsiTypeParameter parameter = parameters[i]; final PsiClassType[] superTypes = parameter.getExtendsListTypes(); final PsiType argType = arguments[i].getType(); for (PsiClassType superType : superTypes) { final PsiType substitutedSuper = substitutor.substitute(superType); if (substitutedSuper != null && !substitutedSuper.isAssignableFrom(argType)) { myHolder.newAnnotation(HighlightSeverity.WARNING, GroovyBundle .message("type.argument.0.is.not.in.its.bound.should.extend.1", argType.getCanonicalText(), superType.getCanonicalText())).range(arguments[i]).create(); break; } } } }