@Nullable("null if ref is not 'super' reference")
  public static Collection<GroovyResolveResult> resolveSuperExpression(@NotNull GrReferenceExpression ref) {
    GrExpression qualifier = ref.getQualifier();

    if (qualifier == null) {
      PsiClass aClass = PsiUtil.getContextClass(ref);
      if (aClass != null) {
        return getSuperClass(aClass);
      }
    }
    else if (qualifier instanceof GrReferenceExpression) {
      GroovyResolveResult result = ((GrReferenceExpression)qualifier).advancedResolve();
      PsiElement resolved = result.getElement();
      if (resolved instanceof PsiClass superClass) {

        GrTypeDefinition scopeClass = PsiTreeUtil.getParentOfType(ref, GrTypeDefinition.class, true);
        if (scopeClass != null && GrTraitUtil.isTrait(superClass) && scopeClass.isInheritor(superClass, false)) {
          PsiSubstitutor superClassSubstitutor = TypeConversionUtil.getSuperClassSubstitutor(superClass, scopeClass, PsiSubstitutor.EMPTY);
          return Collections.singletonList(new GroovyResolveResultImpl(superClass, null, null, superClassSubstitutor, true, true));
        }

        if (PsiUtil.hasEnclosingInstanceInScope(superClass, ref, false)) {
          return getSuperClass(superClass);
        }
      }
    }

    return null;
  }
@Nullable("null if ref is not 'super' reference")
  public static Collection<GroovyResolveResult> resolveSuperExpression(@NotNull GrReferenceExpression ref)