Program: 130502
Project: 130502
Buggy source:
public static boolean walkChildren(@NotNull final PsiScopeProcessor processor,@NotNull final PsiElement entrance,boolean walkParent,@NotNull ResolveState state){
  ProgressIndicatorProvider.checkCanceled();
  GlobalSearchScope resolveScope=entrance.getResolveScope();
  if (entrance instanceof CSharpTypeDeclaration) {
    val typeDeclaration=(CSharpTypeDeclaration)entrance;
    val superTypes=new SmartList<DotNetTypeRef>();
    if (!processor.execute(typeDeclaration,state)) {
      return false;
    }
    DotNetGenericExtractor thisExtractor=state.get(EXTRACTOR);
    if (typeDeclaration.hasModifier(CSharpModifier.PARTIAL)) {
      DotNetTypeDeclaration[] types=DotNetPsiSearcher.getInstance(typeDeclaration.getProject()).findTypes(typeDeclaration.getVmQName(),typeDeclaration.getResolveScope());
      for (      DotNetTypeDeclaration type : types) {
        DotNetTypeList extendList=type.getExtendList();
        if (extendList != null) {
          DotNetTypeRef[] typeRefs=extendList.getTypeRefs();
          for (          DotNetTypeRef typeRef : typeRefs) {
            superTypes.add(GenericUnwrapTool.exchangeTypeRef(typeRef,thisExtractor,type));
          }
        }
      }
      if (superTypes.isEmpty()) {
        Set<String> set=new THashSet<String>();
        for (        DotNetTypeDeclaration type : types) {
          set.add(CSharpTypeDeclarationImplUtil.getDefaultSuperType(type));
        }
        if (set.contains(DotNetTypes.System.ValueType)) {
          superTypes.add(new DotNetTypeRefByQName(DotNetTypes.System.ValueType,CSharpTransform.INSTANCE));
        }
 else {
          superTypes.add(new DotNetTypeRefByQName(DotNetTypes.System.Object,CSharpTransform.INSTANCE));
        }
      }
    }
 else {
      for (      DotNetTypeRef typeRef : typeDeclaration.getExtendTypeRefs()) {
        superTypes.add(GenericUnwrapTool.exchangeTypeRef(typeRef,thisExtractor,typeDeclaration));
      }
    }
    for (    DotNetTypeRef dotNetTypeRef : superTypes) {
      DotNetTypeResolveResult typeResolveResult=dotNetTypeRef.resolve(entrance);
      PsiElement resolve=typeResolveResult.getElement();
      if (resolve != null && !resolve.isEquivalentTo(entrance)) {
        DotNetGenericExtractor genericExtractor=typeResolveResult.getGenericExtractor();
        CSharpResolveSelector selector=state.get(SELECTOR);
        ResolveState newState=ResolveState.initial().put(SELECTOR,selector).put(EXTRACTOR,genericExtractor);
        if (!walkChildren(processor,resolve,false,newState)) {
          return false;
        }
      }
    }
    if (walkParent) {
      PsiElement parent=entrance.getParent();
      if (parent == null) {
        return true;
      }
      if (!walkChildren(processor,parent,walkParent,state)) {
        return false;
      }
    }
  }
 else   if (entrance instanceof CSharpTypeDefStatement) {
    DotNetTypeRef dotNetTypeRef=((CSharpTypeDefStatement)entrance).toTypeRef();
    DotNetTypeResolveResult typeResolveResult=dotNetTypeRef.resolve(entrance);
    PsiElement element=typeResolveResult.getElement();
    if (element == null) {
      return true;
    }
    CSharpResolveSelector selector=state.get(SELECTOR);
    ResolveState newState=ResolveState.initial().put(SELECTOR,selector).put(EXTRACTOR,typeResolveResult.getGenericExtractor());
    return walkChildren(processor,element,walkParent,newState);
  }
 else   if (entrance instanceof DotNetGenericParameter) {
    if (!processor.execute(entrance,state)) {
      return false;
    }
    val superTypes=CSharpGenericConstraintUtil.getExtendTypes((DotNetGenericParameter)entrance);
    CSharpResolveSelector selector=state.get(SELECTOR);
    for (    DotNetTypeRef dotNetTypeRef : superTypes) {
      DotNetTypeResolveResult typeResolveResult=dotNetTypeRef.resolve(entrance);
      PsiElement resolve=typeResolveResult.getElement();
      if (resolve != null && resolve != entrance) {
        DotNetGenericExtractor genericExtractor=typeResolveResult.getGenericExtractor();
        ResolveState newState=ResolveState.initial().put(SELECTOR,selector).put(EXTRACTOR,genericExtractor);
        if (!walkChildren(processor,resolve,walkParent,newState)) {
          return false;
        }
      }
    }
  }
 else   if (entrance instanceof DotNetNamespaceAsElement) {
    state=state.put(BaseDotNetNamespaceAsElement.RESOLVE_SCOPE,resolveScope);
    state=state.put(BaseDotNetNamespaceAsElement.FILTER,DotNetNamespaceAsElement.ChildrenFilter.NONE);
    if (!processor.execute(entrance,state)) {
      return false;
    }
    String parentQName=((DotNetNamespaceAsElement)entrance).getPresentableParentQName();
    if (StringUtil.isEmpty(parentQName)) {
      return true;
    }
    if (walkParent) {
      DotNetNamespaceAsElement parentNamespace=DotNetPsiSearcher.getInstance(entrance.getProject()).findNamespace(parentQName,resolveScope);
      if (parentNamespace != null && !walkChildren(processor,parentNamespace,walkParent,state)) {
        return false;
      }
    }
  }
 else   if (entrance instanceof DotNetNamespaceDeclaration) {
    String presentableQName=((DotNetNamespaceDeclaration)entrance).getPresentableQName();
    if (presentableQName == null) {
      return true;
    }
    state=state.put(BaseDotNetNamespaceAsElement.RESOLVE_SCOPE,resolveScope);
    state=state.put(BaseDotNetNamespaceAsElement.FILTER,DotNetNamespaceAsElement.ChildrenFilter.NONE);
    DotNetNamespaceAsElement namespace=DotNetPsiSearcher.getInstance(entrance.getProject()).findNamespace(presentableQName,resolveScope);
    if (namespace != null && !walkChildren(processor,namespace,walkParent,state)) {
      return false;
    }
  }
  return true;
}

Fixed version (ground truth):
public static boolean walkChildren(@NotNull final PsiScopeProcessor processor,@NotNull final PsiElement entrance,boolean walkParent,boolean walkDeep,@NotNull ResolveState state){
  ProgressIndicatorProvider.checkCanceled();
  GlobalSearchScope resolveScope=entrance.getResolveScope();
  if (entrance instanceof CSharpTypeDeclaration) {
    val typeDeclaration=(CSharpTypeDeclaration)entrance;
    val superTypes=new SmartList<DotNetTypeRef>();
    if (!processor.execute(typeDeclaration,state)) {
      return false;
    }
    if (walkDeep) {
      DotNetGenericExtractor thisExtractor=state.get(EXTRACTOR);
      if (typeDeclaration.hasModifier(CSharpModifier.PARTIAL)) {
        DotNetTypeDeclaration[] types=DotNetPsiSearcher.getInstance(typeDeclaration.getProject()).findTypes(typeDeclaration.getVmQName(),typeDeclaration.getResolveScope());
        for (        DotNetTypeDeclaration type : types) {
          DotNetTypeList extendList=type.getExtendList();
          if (extendList != null) {
            DotNetTypeRef[] typeRefs=extendList.getTypeRefs();
            for (            DotNetTypeRef typeRef : typeRefs) {
              superTypes.add(GenericUnwrapTool.exchangeTypeRef(typeRef,thisExtractor,type));
            }
          }
        }
        if (superTypes.isEmpty()) {
          Set<String> set=new THashSet<String>();
          for (          DotNetTypeDeclaration type : types) {
            set.add(CSharpTypeDeclarationImplUtil.getDefaultSuperType(type));
          }
          if (set.contains(DotNetTypes.System.ValueType)) {
            superTypes.add(new DotNetTypeRefByQName(DotNetTypes.System.ValueType,CSharpTransform.INSTANCE));
          }
 else {
            superTypes.add(new DotNetTypeRefByQName(DotNetTypes.System.Object,CSharpTransform.INSTANCE));
          }
        }
      }
 else {
        for (        DotNetTypeRef typeRef : typeDeclaration.getExtendTypeRefs()) {
          superTypes.add(GenericUnwrapTool.exchangeTypeRef(typeRef,thisExtractor,typeDeclaration));
        }
      }
      for (      DotNetTypeRef dotNetTypeRef : superTypes) {
        DotNetTypeResolveResult typeResolveResult=dotNetTypeRef.resolve(entrance);
        PsiElement resolve=typeResolveResult.getElement();
        if (resolve != null && !resolve.isEquivalentTo(entrance)) {
          DotNetGenericExtractor genericExtractor=typeResolveResult.getGenericExtractor();
          CSharpResolveSelector selector=state.get(SELECTOR);
          ResolveState newState=ResolveState.initial().put(SELECTOR,selector).put(EXTRACTOR,genericExtractor);
          if (!walkChildren(processor,resolve,false,true,newState)) {
            return false;
          }
        }
      }
    }
    if (walkParent) {
      PsiElement parent=entrance.getParent();
      if (parent == null) {
        return true;
      }
      if (!walkChildren(processor,parent,walkParent,true,state)) {
        return false;
      }
    }
  }
 else   if (entrance instanceof CSharpTypeDefStatement) {
    DotNetTypeRef dotNetTypeRef=((CSharpTypeDefStatement)entrance).toTypeRef();
    DotNetTypeResolveResult typeResolveResult=dotNetTypeRef.resolve(entrance);
    PsiElement element=typeResolveResult.getElement();
    if (element == null) {
      return true;
    }
    CSharpResolveSelector selector=state.get(SELECTOR);
    ResolveState newState=ResolveState.initial().put(SELECTOR,selector).put(EXTRACTOR,typeResolveResult.getGenericExtractor());
    return walkChildren(processor,element,walkParent,true,newState);
  }
 else   if (entrance instanceof DotNetGenericParameter) {
    if (!processor.execute(entrance,state)) {
      return false;
    }
    val superTypes=CSharpGenericConstraintUtil.getExtendTypes((DotNetGenericParameter)entrance);
    CSharpResolveSelector selector=state.get(SELECTOR);
    for (    DotNetTypeRef dotNetTypeRef : superTypes) {
      DotNetTypeResolveResult typeResolveResult=dotNetTypeRef.resolve(entrance);
      PsiElement resolve=typeResolveResult.getElement();
      if (resolve != null && resolve != entrance) {
        DotNetGenericExtractor genericExtractor=typeResolveResult.getGenericExtractor();
        ResolveState newState=ResolveState.initial().put(SELECTOR,selector).put(EXTRACTOR,genericExtractor);
        if (!walkChildren(processor,resolve,walkParent,true,newState)) {
          return false;
        }
      }
    }
  }
 else   if (entrance instanceof DotNetNamespaceAsElement) {
    state=state.put(BaseDotNetNamespaceAsElement.RESOLVE_SCOPE,resolveScope);
    state=state.put(BaseDotNetNamespaceAsElement.FILTER,DotNetNamespaceAsElement.ChildrenFilter.NONE);
    if (!processor.execute(entrance,state)) {
      return false;
    }
    String parentQName=((DotNetNamespaceAsElement)entrance).getPresentableParentQName();
    if (StringUtil.isEmpty(parentQName)) {
      return true;
    }
    if (walkParent) {
      DotNetNamespaceAsElement parentNamespace=DotNetPsiSearcher.getInstance(entrance.getProject()).findNamespace(parentQName,resolveScope);
      if (parentNamespace != null && !walkChildren(processor,parentNamespace,walkParent,true,state)) {
        return false;
      }
    }
  }
 else   if (entrance instanceof DotNetNamespaceDeclaration) {
    String presentableQName=((DotNetNamespaceDeclaration)entrance).getPresentableQName();
    if (presentableQName == null) {
      return true;
    }
    state=state.put(BaseDotNetNamespaceAsElement.RESOLVE_SCOPE,resolveScope);
    state=state.put(BaseDotNetNamespaceAsElement.FILTER,DotNetNamespaceAsElement.ChildrenFilter.NONE);
    DotNetNamespaceAsElement namespace=DotNetPsiSearcher.getInstance(entrance.getProject()).findNamespace(presentableQName,resolveScope);
    if (namespace != null && !walkChildren(processor,namespace,walkParent,true,state)) {
      return false;
    }
  }
  return true;
}