Program: 130514
Project: 130514
Buggy source:
private static boolean walkChildrenImpl(@NotNull final PsiScopeProcessor processor,@NotNull final PsiElement entrance,boolean walkParent,@Nullable PsiElement maxScope,@NotNull ResolveState state,@NotNull Set<String> typeVisited){
  ProgressIndicatorProvider.checkCanceled();
  GlobalSearchScope resolveScope=entrance.getResolveScope();
  if (entrance instanceof CSharpTypeDeclaration) {
    DotNetGenericExtractor extractor=state.get(CSharpResolveUtil.EXTRACTOR);
    val typeDeclaration=(CSharpTypeDeclaration)entrance;
    val superTypes=new SmartList<DotNetTypeRef>();
    if (!processTypeDeclaration(processor,typeDeclaration,state,resolveScope,superTypes,extractor,typeVisited)) {
      return false;
    }
    for (    DotNetTypeRef dotNetTypeRef : superTypes) {
      DotNetTypeResolveResult typeResolveResult=dotNetTypeRef.resolve(entrance);
      PsiElement resolve=typeResolveResult.getElement();
      if (resolve != null && !resolve.isEquivalentTo(entrance)) {
        DotNetGenericExtractor genericExtractor=typeResolveResult.getGenericExtractor();
        ResolveState newState=ResolveState.initial().put(EXTRACTOR,genericExtractor);
        if (!walkChildrenImpl(processor,resolve,false,maxScope,newState,typeVisited)) {
          return false;
        }
      }
    }
    if (walkParent) {
      if (!walkChildrenImpl(processor,entrance.getParent(),walkParent,maxScope,state,typeVisited)) {
        return false;
      }
    }
  }
 else   if (entrance instanceof DotNetGenericParameter) {
    DotNetGenericParameterList parameterList=(DotNetGenericParameterList)entrance.getParent();
    PsiElement parent=parameterList.getParent();
    if (!(parent instanceof CSharpGenericConstraintOwner)) {
      return true;
    }
    val constraint=CSharpGenericConstraintOwnerUtil.forParameter((CSharpGenericConstraintOwner)parent,(DotNetGenericParameter)entrance);
    if (constraint == null) {
      return true;
    }
    val superTypes=new SmartList<DotNetTypeRef>();
    for (    CSharpGenericConstraintValue value : constraint.getGenericConstraintValues()) {
      if (value instanceof CSharpGenericConstraintTypeValue) {
        DotNetTypeRef typeRef=((CSharpGenericConstraintTypeValue)value).toTypeRef();
        superTypes.add(typeRef);
      }
 else       if (value instanceof CSharpGenericConstraintKeywordValue) {
        if (((CSharpGenericConstraintKeywordValue)value).getKeywordElementType() == CSharpTokens.STRUCT_KEYWORD) {
          superTypes.add(new DotNetTypeRefByQName(DotNetTypes.System.ValueType,CSharpTransform.INSTANCE));
        }
 else         if (((CSharpGenericConstraintKeywordValue)value).getKeywordElementType() == CSharpTokens.CLASS_KEYWORD) {
          superTypes.add(new DotNetTypeRefByQName(DotNetTypes.System.Object,CSharpTransform.INSTANCE));
        }
      }
    }
    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(EXTRACTOR,genericExtractor);
        if (!walkChildrenImpl(processor,resolve,false,maxScope,newState,typeVisited)) {
          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 && !walkChildrenImpl(processor,parentNamespace,walkParent,maxScope,state,typeVisited)) {
        return false;
      }
    }
  }
  return true;
}

Fixed version (ground truth):
private static boolean walkChildrenImpl(@NotNull final PsiScopeProcessor processor,@NotNull final PsiElement entrance,boolean walkParent,@Nullable PsiElement maxScope,@NotNull ResolveState state,@NotNull Set<String> typeVisited){
  ProgressIndicatorProvider.checkCanceled();
  GlobalSearchScope resolveScope=entrance.getResolveScope();
  if (entrance instanceof CSharpTypeDeclaration) {
    DotNetGenericExtractor extractor=state.get(CSharpResolveUtil.EXTRACTOR);
    val typeDeclaration=(CSharpTypeDeclaration)entrance;
    val superTypes=new SmartList<DotNetTypeRef>();
    if (!processTypeDeclaration(processor,typeDeclaration,state,resolveScope,superTypes,extractor,typeVisited)) {
      return false;
    }
    for (    DotNetTypeRef dotNetTypeRef : superTypes) {
      DotNetTypeResolveResult typeResolveResult=dotNetTypeRef.resolve(entrance);
      PsiElement resolve=typeResolveResult.getElement();
      if (resolve != null && !resolve.isEquivalentTo(entrance)) {
        DotNetGenericExtractor genericExtractor=typeResolveResult.getGenericExtractor();
        ResolveState newState=ResolveState.initial().put(EXTRACTOR,genericExtractor);
        if (!walkChildrenImpl(processor,resolve,false,maxScope,newState,typeVisited)) {
          return false;
        }
      }
    }
    if (walkParent) {
      if (!walkChildrenImpl(processor,entrance.getParent(),walkParent,maxScope,state,typeVisited)) {
        return false;
      }
    }
  }
 else   if (entrance instanceof DotNetGenericParameter) {
    DotNetGenericParameterList parameterList=(DotNetGenericParameterList)entrance.getParent();
    PsiElement parent=parameterList.getParent();
    if (!(parent instanceof CSharpGenericConstraintOwner)) {
      return true;
    }
    val constraint=CSharpGenericConstraintOwnerUtil.forParameter((CSharpGenericConstraintOwner)parent,(DotNetGenericParameter)entrance);
    if (constraint == null) {
      return true;
    }
    val superTypes=new SmartList<DotNetTypeRef>();
    for (    CSharpGenericConstraintValue value : constraint.getGenericConstraintValues()) {
      if (value instanceof CSharpGenericConstraintTypeValue) {
        DotNetTypeRef typeRef=((CSharpGenericConstraintTypeValue)value).toTypeRef();
        superTypes.add(typeRef);
      }
 else       if (value instanceof CSharpGenericConstraintKeywordValue) {
        if (((CSharpGenericConstraintKeywordValue)value).getKeywordElementType() == CSharpTokens.STRUCT_KEYWORD) {
          superTypes.add(new DotNetTypeRefByQName(DotNetTypes.System.ValueType,CSharpTransform.INSTANCE));
        }
 else         if (((CSharpGenericConstraintKeywordValue)value).getKeywordElementType() == CSharpTokens.CLASS_KEYWORD) {
          superTypes.add(new DotNetTypeRefByQName(DotNetTypes.System.Object,CSharpTransform.INSTANCE));
        }
      }
    }
    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(EXTRACTOR,genericExtractor);
        if (!walkChildrenImpl(processor,resolve,false,maxScope,newState,typeVisited)) {
          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 && !walkChildrenImpl(processor,parentNamespace,walkParent,maxScope,state,typeVisited)) {
        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 && !walkChildrenImpl(processor,namespace,walkParent,maxScope,state,typeVisited)) {
      return false;
    }
  }
  return true;
}