Program: 130375
Project: 130375
Buggy source:
@RequiredReadAction private int getWeightByContext(ResolveResult resolveResult){
  final PsiElement element=resolveResult.getElement();
  if (element == null) {
    return -100;
  }
  if (element instanceof CSharpTypeDefStatement) {
    return Integer.MAX_VALUE;
  }
  if (myParent != null) {
    CSharpContextUtil.ContextType parentContext=CSharpContextUtil.ContextType.ANY;
    if (element instanceof CSharpTypeDeclaration) {
      parentContext=CSharpContextUtil.ContextType.STATIC;
    }
 else     if (element instanceof DotNetVariable) {
      parentContext=CSharpContextUtil.ContextType.INSTANCE;
    }
    DotNetTypeDeclaration forceTarget=resolveTargetElement(element,myParent);
    if (forceTarget == null) {
      return parentContext == CSharpContextUtil.ContextType.INSTANCE ? 10 : 5;
    }
    ResolveResult[] resolveResults=myParent.tryResolveFromQualifier(forceTarget);
    if (resolveResults.length == 0) {
      return parentContext == CSharpContextUtil.ContextType.INSTANCE ? 10 : 5;
    }
    for (    ResolveResult result : resolveResults) {
      PsiElement element1=result.getElement();
      if (element1 == null) {
        continue;
      }
      CSharpContextUtil.ContextType contextForResolved=CSharpContextUtil.getContextForResolved(element1);
      if (parentContext != CSharpContextUtil.ContextType.ANY) {
switch (parentContext) {
case INSTANCE:
          if (contextForResolved.isAllowInstance()) {
            return 5000;
          }
        break;
case STATIC:
      if (contextForResolved == CSharpContextUtil.ContextType.STATIC) {
        return 5000;
      }
    break;
}
}
}
}
 else {
if (element instanceof CSharpTypeDeclaration || element instanceof DotNetNamespaceAsElement) {
return -1;
}
}
return 0;
}

Fixed version (ground truth):
@RequiredReadAction private int getWeightByContext(ResolveResult resolveResult){
  final PsiElement element=resolveResult.getElement();
  if (element == null) {
    return -100;
  }
  if (element instanceof CSharpTypeDefStatement) {
    return Integer.MAX_VALUE;
  }
  if (myParent != null) {
    CSharpContextUtil.ContextType parentContext=CSharpContextUtil.ContextType.ANY;
    if (element instanceof CSharpTypeDeclaration) {
      parentContext=CSharpContextUtil.ContextType.STATIC;
    }
 else     if (element instanceof DotNetVariable) {
      parentContext=CSharpContextUtil.ContextType.INSTANCE;
    }
    DotNetTypeDeclaration forceTarget=resolveTargetElement(element,myParent);
    if (forceTarget == null) {
      return parentContext == CSharpContextUtil.ContextType.INSTANCE ? 10 : 5;
    }
    String vmQName=forceTarget.getVmQName();
    ResolveResult[] resolveResults=myParent.tryResolveFromQualifier(forceTarget);
    if (resolveResults.length == 0) {
      return parentContext == CSharpContextUtil.ContextType.INSTANCE ? 10 : 5;
    }
    for (    ResolveResult result : resolveResults) {
      PsiElement element1=result.getElement();
      if (element1 == null) {
        continue;
      }
      CSharpContextUtil.ContextType contextForResolved=CSharpContextUtil.getContextForResolved(element1);
      if (parentContext != CSharpContextUtil.ContextType.ANY) {
switch (parentContext) {
case INSTANCE:
          if (contextForResolved.isAllowInstance()) {
            return 5000;
          }
        break;
case STATIC:
      if (contextForResolved == CSharpContextUtil.ContextType.STATIC) {
        return 5000;
      }
    break;
}
}
}
}
 else {
if (element instanceof CSharpTypeDeclaration || element instanceof DotNetNamespaceAsElement) {
return -1;
}
}
return 0;
}