Program: 15980
Project: 15980
Buggy source:
protected Object getShadowVariable0(AbstractComponent baseChild,String name,boolean recurse){
  Object val=getAttribute(name);
  if (val != null || hasAttribute(name))   return val;
  if (!(this instanceof ShadowElement)) {
    ComponentCtrl ctrl=this;
    List<HtmlShadowElement> shadowRoots=ctrl.getShadowRoots();
    if (!shadowRoots.isEmpty()) {
      Map<Component,Integer> indexCacheMap=getIndexCacheMap();
      try {
        if (indexCacheMap != null) {
          destroyIndexCacheMap();
        }
        initIndexCacheMap();
        for (        HtmlShadowElement shadow : shadowRoots) {
          if (shadow.getShadowHost() != baseChild) {
switch (HtmlShadowElement.inRange(shadow,baseChild)) {
case IN_RANGE:
case FIRST:
case LAST:
              val=shadow.resolveVariable(baseChild,name,recurse);
            if (val != null)             return val;
          break;
      }
    }
 else {
      val=shadow.resolveVariable(baseChild,name,recurse);
      if (val != null)       return val;
    }
  }
}
  finally {
  ShadowElementsCtrl.setDistributedIndexInfo(indexCacheMap);
}
}
}
if (recurse) {
if (_parent != null) return _parent.getShadowVariable0(this,name,recurse);
if (this instanceof ShadowElement) {
AbstractComponent shadowHost=(AbstractComponent)((ShadowElement)this).getShadowHost();
if (shadowHost != null) {
  if (shadowHost._variableSeeking) {
    if (shadowHost.getParent() != null) {
      return ((AbstractComponent)shadowHost.getParent()).getShadowVariable(name,recurse);
    }
    return null;
  }
  return shadowHost.getShadowVariable(name,recurse);
}
}
}
return null;
}

Fixed version (ground truth):
protected Object getShadowVariable0(Component baseChild,String name,boolean recurse){
  Object val=getAttribute(name);
  if (val != null || hasAttribute(name))   return val;
  if (!(this instanceof ShadowElement)) {
    ComponentCtrl ctrl=this;
    List<HtmlShadowElement> shadowRoots=ctrl.getShadowRoots();
    if (!shadowRoots.isEmpty()) {
      Map<Component,Integer> indexCacheMap=getIndexCacheMap();
      try {
        if (indexCacheMap != null) {
          destroyIndexCacheMap();
        }
        initIndexCacheMap();
        for (        HtmlShadowElement shadow : shadowRoots) {
          if (shadow.getShadowHost() != baseChild) {
switch (HtmlShadowElement.inRange(shadow,baseChild)) {
case IN_RANGE:
case FIRST:
case LAST:
              return shadow.resolveVariable(baseChild,name,recurse);
          }
        }
 else {
          val=shadow.resolveVariable(baseChild,name,recurse);
          if (val != null)           return val;
        }
      }
    }
  finally {
      ShadowElementsCtrl.setDistributedIndexInfo(indexCacheMap);
    }
  }
}
if (recurse) {
  if (_parent != null)   return _parent.getShadowVariable0(this,name,recurse);
  if (this instanceof ShadowElement) {
    AbstractComponent shadowHost=(AbstractComponent)((ShadowElement)this).getShadowHost();
    if (shadowHost != null) {
      if (shadowHost._variableSeeking) {
        if (shadowHost.getParent() != null) {
          return ((AbstractComponent)shadowHost.getParent()).getShadowVariable(name,recurse);
        }
        return null;
      }
      if (this == baseChild) {
        if (shadowHost.getParent() != null)         return shadowHost.getParent().getShadowVariable(name,recurse);
      }
 else       return shadowHost.getShadowVariable(name,recurse);
    }
  }
}
return null;
}