Program: 130532
Project: 130532
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();
  if (entrance instanceof DotNetTypeDeclaration) {
    DotNetGenericExtractor extractor=state.get(CSharpResolveUtil.EXTRACTOR_KEY);
    val typeDeclaration=(DotNetTypeDeclaration)entrance;
    val superTypes=new SmartList<DotNetTypeRef>();
    if (typeDeclaration.hasModifier(CSharpModifier.PARTIAL)) {
      val types=DotNetPsiFacade.getInstance(entrance.getProject()).findTypes(typeDeclaration.getPresentableQName(),entrance.getResolveScope(),typeDeclaration.getGenericParametersCount());
      for (      val type : types) {
        if (!type.hasModifier(CSharpModifier.PARTIAL)) {
          continue;
        }
        if (!processTypeDeclaration(processor,type,state,superTypes,extractor,typeVisited)) {
          return false;
        }
      }
    }
 else {
      if (!processTypeDeclaration(processor,typeDeclaration,state,superTypes,extractor,typeVisited)) {
        return false;
      }
    }
    for (    DotNetTypeRef dotNetTypeRef : superTypes) {
      PsiElement resolve=dotNetTypeRef.resolve(entrance);
      if (resolve != null && !resolve.isEquivalentTo(entrance)) {
        DotNetGenericExtractor genericExtractor=dotNetTypeRef.getGenericExtractor(resolve,entrance);
        ResolveState newState=ResolveState.initial().put(EXTRACTOR_KEY,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(CSharpNativeTypeRef.OBJECT);
        }
      }
    }
    for (    DotNetTypeRef dotNetTypeRef : superTypes) {
      PsiElement resolve=dotNetTypeRef.resolve(entrance);
      if (resolve != null && resolve != entrance) {
        DotNetGenericExtractor genericExtractor=dotNetTypeRef.getGenericExtractor(resolve,entrance);
        ResolveState newState=ResolveState.initial().put(EXTRACTOR_KEY,genericExtractor);
        if (!walkChildrenImpl(processor,resolve,false,maxScope,newState,typeVisited)) {
          return false;
        }
      }
    }
  }
 else   if (entrance instanceof CSharpNamespaceAsElement) {
    if (!entrance.processDeclarations(processor,state,maxScope,entrance)) {
      return false;
    }
    String pQName=CSharpNamespaceHelper.getNamespaceForIndexing(((CSharpNamespaceAsElement)entrance).getPresentableParentQName());
    if (Comparing.equal(pQName,CSharpNamespaceHelper.ROOT)) {
      return true;
    }
    if (walkParent) {
      CSharpNamespaceAsElement parentNamespace=new CSharpNamespaceAsElement(entrance.getProject(),pQName,entrance.getResolveScope());
      if (!walkChildrenImpl(processor,parentNamespace,walkParent,maxScope,state,typeVisited)) {
        return false;
      }
    }
  }
 else   if (entrance instanceof DotNetNamespaceDeclaration) {
    String presentableQName=((DotNetNamespaceDeclaration)entrance).getPresentableQName();
    if (presentableQName == null) {
      return true;
    }
    if (walkParent) {
      CSharpNamespaceAsElement parentNamespace=new CSharpNamespaceAsElement(entrance.getProject(),presentableQName,entrance.getResolveScope());
      if (!walkChildrenImpl(processor,parentNamespace,walkParent,maxScope,state,typeVisited)) {
        return false;
      }
    }
  }
 else   if (entrance instanceof PsiFile) {
    CSharpNamespaceAsElement parentNamespace=new CSharpNamespaceAsElement(entrance.getProject(),CSharpNamespaceHelper.ROOT,entrance.getResolveScope());
    return walkChildrenImpl(processor,parentNamespace,walkParent,maxScope,state,typeVisited);
  }
  PsiFile psiFile=state.get(CONTAINS_FILE_KEY);
  return psiFile == null || walkChildrenImpl(processor,psiFile,walkParent,maxScope,state,typeVisited);
}

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();
  if (entrance instanceof DotNetTypeDeclaration) {
    DotNetGenericExtractor extractor=state.get(CSharpResolveUtil.EXTRACTOR_KEY);
    val typeDeclaration=(DotNetTypeDeclaration)entrance;
    val superTypes=new SmartList<DotNetTypeRef>();
    if (typeDeclaration.hasModifier(CSharpModifier.PARTIAL)) {
      String vmQName=typeDeclaration.getVmQName();
      val types=CSharpPsiSearcher.getInstance(entrance.getProject()).findTypes(vmQName,entrance.getResolveScope());
      for (      val type : types) {
        if (!type.hasModifier(CSharpModifier.PARTIAL)) {
          continue;
        }
        if (!processTypeDeclaration(processor,type,state,superTypes,extractor,null)) {
          return false;
        }
      }
      typeVisited.add(vmQName);
    }
 else {
      if (!processTypeDeclaration(processor,typeDeclaration,state,superTypes,extractor,typeVisited)) {
        return false;
      }
    }
    for (    DotNetTypeRef dotNetTypeRef : superTypes) {
      PsiElement resolve=dotNetTypeRef.resolve(entrance);
      if (resolve != null && !resolve.isEquivalentTo(entrance)) {
        DotNetGenericExtractor genericExtractor=dotNetTypeRef.getGenericExtractor(resolve,entrance);
        ResolveState newState=ResolveState.initial().put(EXTRACTOR_KEY,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(CSharpNativeTypeRef.OBJECT);
        }
      }
    }
    for (    DotNetTypeRef dotNetTypeRef : superTypes) {
      PsiElement resolve=dotNetTypeRef.resolve(entrance);
      if (resolve != null && resolve != entrance) {
        DotNetGenericExtractor genericExtractor=dotNetTypeRef.getGenericExtractor(resolve,entrance);
        ResolveState newState=ResolveState.initial().put(EXTRACTOR_KEY,genericExtractor);
        if (!walkChildrenImpl(processor,resolve,false,maxScope,newState,typeVisited)) {
          return false;
        }
      }
    }
  }
 else   if (entrance instanceof CSharpNamespaceAsElement) {
    if (!entrance.processDeclarations(processor,state,maxScope,entrance)) {
      return false;
    }
    String pQName=CSharpNamespaceHelper.getNamespaceForIndexing(((CSharpNamespaceAsElement)entrance).getPresentableParentQName());
    if (Comparing.equal(pQName,CSharpNamespaceHelper.ROOT)) {
      return true;
    }
    if (walkParent) {
      CSharpNamespaceAsElement parentNamespace=new CSharpNamespaceAsElement(entrance.getProject(),pQName,entrance.getResolveScope());
      if (!walkChildrenImpl(processor,parentNamespace,walkParent,maxScope,state,typeVisited)) {
        return false;
      }
    }
  }
 else   if (entrance instanceof DotNetNamespaceDeclaration) {
    String presentableQName=((DotNetNamespaceDeclaration)entrance).getPresentableQName();
    if (presentableQName == null) {
      return true;
    }
    if (walkParent) {
      CSharpNamespaceAsElement parentNamespace=new CSharpNamespaceAsElement(entrance.getProject(),presentableQName,entrance.getResolveScope());
      if (!walkChildrenImpl(processor,parentNamespace,walkParent,maxScope,state,typeVisited)) {
        return false;
      }
    }
  }
 else   if (entrance instanceof PsiFile) {
    CSharpNamespaceAsElement parentNamespace=new CSharpNamespaceAsElement(entrance.getProject(),CSharpNamespaceHelper.ROOT,entrance.getResolveScope());
    return walkChildrenImpl(processor,parentNamespace,walkParent,maxScope,state,typeVisited);
  }
  PsiFile psiFile=state.get(CONTAINS_FILE_KEY);
  return psiFile == null || walkChildrenImpl(processor,psiFile,walkParent,maxScope,state,typeVisited);
}