nus-yam/ex-repair huggingface dataset:
Program: 28202
Project: 28202
Buggy source:
/** 
 * Returns true if this is a literal value. We define a literal value as any node that evaluates to the same thing regardless of when or where it is evaluated. So /xyz/ and [3, 5] are literals, but function() { return a; } is not.
 */
static boolean isLiteralValue(Node n){
switch (n.getType()) {
case Token.ARRAYLIT:
case Token.OBJECTLIT:
case Token.REGEXP:
    for (Node child=n.getFirstChild(); child != null; child=child.getNext()) {
      if (!isLiteralValue(child)) {
        return false;
      }
    }
  return true;
default :
return isImmutableValue(n);
}
}

Fixed version (ground truth):
/** 
 * Returns true if this is a literal value. We define a literal value as any node that evaluates to the same thing regardless of when or where it is evaluated. So /xyz/ and [3, 5] are literals, but the name a is not. Function literals do not meet this definition, because they lexically capture variables. For example, if you have <code> function() { return a; } </code> If it is evaluated in a different scope, then it captures a different variable. Even if the function did not read any captured vairables directly, it would still fail this definition, because it affects the lifecycle of variables in the enclosing scope. However, a function literal with respect to a particular scope is a literal.
 * @param includeFunctions If true, all function expressions will betreated as literals.
 */
static boolean isLiteralValue(Node n,boolean includeFunctions){
switch (n.getType()) {
case Token.ARRAYLIT:
case Token.OBJECTLIT:
case Token.REGEXP:
    for (Node child=n.getFirstChild(); child != null; child=child.getNext()) {
      if (!isLiteralValue(child,includeFunctions)) {
        return false;
      }
    }
  return true;
case Token.FUNCTION:
return includeFunctions && !NodeUtil.isFunctionDeclaration(n);
default :
return isImmutableValue(n);
}
}
Program: 28204
Project: 28204
Buggy source:
private void buildParameterList(List<Parameter> parameters,Node cur){
  while ((cur=cur.getNext()) != null) {
    parameters.add(new Parameter(cur,NodeUtil.isLiteralValue(cur)));
  }
}

Fixed version (ground truth):
private void buildParameterList(List<Parameter> parameters,Node cur){
  while ((cur=cur.getNext()) != null) {
    parameters.add(new Parameter(cur,NodeUtil.isLiteralValue(cur,false)));
  }
}
Program: 28205
Project: 28205
Buggy source:
private Node tryFoldAdd(Node node,Node left,Node right){
  Preconditions.checkArgument(node.getType() == Token.ADD);
  if (NodeUtil.isLiteralValue(left) && NodeUtil.isLiteralValue(right)) {
    return tryFoldAddConstant(node,left,right);
  }
 else {
    return tryFoldLeftChildAdd(node,left,right);
  }
}

Fixed version (ground truth):
private Node tryFoldAdd(Node node,Node left,Node right){
  Preconditions.checkArgument(node.getType() == Token.ADD);
  if (NodeUtil.isLiteralValue(left,false) && NodeUtil.isLiteralValue(right,false)) {
    return tryFoldAddConstant(node,left,right);
  }
 else {
    return tryFoldLeftChildAdd(node,left,right);
  }
}
Program: 28206
Project: 28206
Buggy source:
/** 
 * Expressions such as [foo() + 'a' + 'b'] generate parse trees where no node has two const children ((foo() + 'a') + 'b'), so tryFoldAdd() won't fold it -- tryFoldLeftChildAdd() will (for Strings). Specifically it folds Add exprssions where: - The left child is also and add expression - The right child is a constant value - The left child's right child is a STRING constant. WARNING: If javascript ever adds operator overloading, this will probably stop being correct.
 */
private Node tryFoldLeftChildAdd(Node n,Node left,Node right){
  if (NodeUtil.isLiteralValue(right) && left.getType() == Token.ADD && left.getChildCount() == 2) {
    Node ll=left.getFirstChild();
    Node lr=ll.getNext();
    if (lr.getType() != Token.STRING) {
      return n;
    }
    String leftString=NodeUtil.getStringValue(lr);
    String rightString=NodeUtil.getStringValue(right);
    if (leftString != null && rightString != null) {
      left.removeChild(ll);
      String result=leftString + rightString;
      n.replaceChild(left,ll);
      n.replaceChild(right,Node.newString(result));
      reportCodeChange();
    }
  }
  return n;
}

Fixed version (ground truth):
/** 
 * Expressions such as [foo() + 'a' + 'b'] generate parse trees where no node has two const children ((foo() + 'a') + 'b'), so tryFoldAdd() won't fold it -- tryFoldLeftChildAdd() will (for Strings). Specifically it folds Add exprssions where: - The left child is also and add expression - The right child is a constant value - The left child's right child is a STRING constant. WARNING: If javascript ever adds operator overloading, this will probably stop being correct.
 */
private Node tryFoldLeftChildAdd(Node n,Node left,Node right){
  if (NodeUtil.isLiteralValue(right,false) && left.getType() == Token.ADD && left.getChildCount() == 2) {
    Node ll=left.getFirstChild();
    Node lr=ll.getNext();
    if (lr.getType() != Token.STRING) {
      return n;
    }
    String leftString=NodeUtil.getStringValue(lr);
    String rightString=NodeUtil.getStringValue(right);
    if (leftString != null && rightString != null) {
      left.removeChild(ll);
      String result=leftString + rightString;
      n.replaceChild(left,ll);
      n.replaceChild(right,Node.newString(result));
      reportCodeChange();
    }
  }
  return n;
}
Program: 28207
Project: 28207
Buggy source:
/** 
 * Folds 'typeof(foo)' if foo is a literal, e.g. typeof("bar") --> "string" typeof(6) --> "number"
 */
private Node tryFoldTypeof(Node originalTypeofNode){
  Preconditions.checkArgument(originalTypeofNode.getType() == Token.TYPEOF);
  Node argumentNode=originalTypeofNode.getFirstChild();
  if (argumentNode == null || !NodeUtil.isLiteralValue(argumentNode)) {
    return originalTypeofNode;
  }
  String typeNameString=null;
switch (argumentNode.getType()) {
case Token.STRING:
    typeNameString="String_Node_Str";
  break;
case Token.NUMBER:
typeNameString="String_Node_Str";
break;
case Token.TRUE:
case Token.FALSE:
typeNameString="String_Node_Str";
break;
case Token.NULL:
case Token.OBJECTLIT:
case Token.ARRAYLIT:
typeNameString="String_Node_Str";
break;
case Token.VOID:
typeNameString="String_Node_Str";
break;
case Token.NAME:
if ("String_Node_Str".equals(argumentNode.getString())) {
typeNameString="String_Node_Str";
}
break;
}
if (typeNameString != null) {
Node newNode=Node.newString(typeNameString);
originalTypeofNode.getParent().replaceChild(originalTypeofNode,newNode);
reportCodeChange();
return newNode;
}
return originalTypeofNode;
}

Fixed version (ground truth):
/** 
 * Folds 'typeof(foo)' if foo is a literal, e.g. typeof("bar") --> "string" typeof(6) --> "number"
 */
private Node tryFoldTypeof(Node originalTypeofNode){
  Preconditions.checkArgument(originalTypeofNode.getType() == Token.TYPEOF);
  Node argumentNode=originalTypeofNode.getFirstChild();
  if (argumentNode == null || !NodeUtil.isLiteralValue(argumentNode,true)) {
    return originalTypeofNode;
  }
  String typeNameString=null;
switch (argumentNode.getType()) {
case Token.FUNCTION:
    typeNameString="String_Node_Str";
  break;
case Token.STRING:
typeNameString="String_Node_Str";
break;
case Token.NUMBER:
typeNameString="String_Node_Str";
break;
case Token.TRUE:
case Token.FALSE:
typeNameString="String_Node_Str";
break;
case Token.NULL:
case Token.OBJECTLIT:
case Token.ARRAYLIT:
typeNameString="String_Node_Str";
break;
case Token.VOID:
typeNameString="String_Node_Str";
break;
case Token.NAME:
if ("String_Node_Str".equals(argumentNode.getString())) {
typeNameString="String_Node_Str";
}
break;
}
if (typeNameString != null) {
Node newNode=Node.newString(typeNameString);
originalTypeofNode.getParent().replaceChild(originalTypeofNode,newNode);
reportCodeChange();
return newNode;
}
return originalTypeofNode;
}
Program: 28208
Project: 28208
Buggy source:
/** 
 * Try to fold   {@code left instanceof right} into {@code true}or   {@code false}.
 */
private Node tryFoldInstanceof(Node n,Node left,Node right){
  Preconditions.checkArgument(n.getType() == Token.INSTANCEOF);
  if (NodeUtil.isLiteralValue(left) && !NodeUtil.mayHaveSideEffects(right)) {
    Node replacementNode=null;
    if (NodeUtil.isImmutableValue(left)) {
      replacementNode=new Node(Token.FALSE);
    }
 else     if (right.getType() == Token.NAME && "String_Node_Str".equals(right.getString())) {
      replacementNode=new Node(Token.TRUE);
    }
    if (replacementNode != null) {
      n.getParent().replaceChild(n,replacementNode);
      reportCodeChange();
      return replacementNode;
    }
  }
  return n;
}

Fixed version (ground truth):
/** 
 * Try to fold   {@code left instanceof right} into {@code true}or   {@code false}.
 */
private Node tryFoldInstanceof(Node n,Node left,Node right){
  Preconditions.checkArgument(n.getType() == Token.INSTANCEOF);
  if (NodeUtil.isLiteralValue(left,true) && !NodeUtil.mayHaveSideEffects(right)) {
    Node replacementNode=null;
    if (NodeUtil.isImmutableValue(left)) {
      replacementNode=new Node(Token.FALSE);
    }
 else     if (right.getType() == Token.NAME && "String_Node_Str".equals(right.getString())) {
      replacementNode=new Node(Token.TRUE);
    }
    if (replacementNode != null) {
      n.getParent().replaceChild(n,replacementNode);
      reportCodeChange();
      return replacementNode;
    }
  }
  return n;
}
Program: 28210
Project: 28210
Buggy source:
/** 
 * Folds "typeof expression" based on the JSType of "expression" if the expression  has no side effects. <p>E.g., <pre> var x = 6; if (typeof(x) == "number") { } </pre> folds to <pre> var x = 6; if ("number" == "number") { } </pre> <p>This method doesn't fold literal values -- we leave that to PeepholeFoldConstants.
 */
private Node tryFoldTypeof(Node typeofNode){
  Preconditions.checkArgument(typeofNode.getType() == Token.TYPEOF);
  Preconditions.checkArgument(typeofNode.getFirstChild() != null);
  Node argumentNode=typeofNode.getFirstChild();
  if (!NodeUtil.isLiteralValue(argumentNode) && !NodeUtil.mayHaveSideEffects(argumentNode)) {
    JSType argumentType=argumentNode.getJSType();
    String typeName=null;
    if (argumentType != null) {
      if (argumentType.isObject() || argumentType.isNullType()) {
        typeName="String_Node_Str";
      }
 else       if (argumentType.isStringValueType()) {
        typeName="String_Node_Str";
      }
 else       if (argumentType.isNumberValueType()) {
        typeName="String_Node_Str";
      }
 else       if (argumentType.isBooleanValueType()) {
        typeName="String_Node_Str";
      }
 else       if (argumentType.isVoidType()) {
        typeName="String_Node_Str";
      }
 else       if (argumentType.isUnionType()) {
        typeName=null;
      }
      if (typeName != null) {
        Node newNode=Node.newString(typeName);
        typeofNode.getParent().replaceChild(typeofNode,newNode);
        reportCodeChange();
        return newNode;
      }
    }
  }
  return typeofNode;
}

Fixed version (ground truth):
/** 
 * Folds "typeof expression" based on the JSType of "expression" if the expression  has no side effects. <p>E.g., <pre> var x = 6; if (typeof(x) == "number") { } </pre> folds to <pre> var x = 6; if ("number" == "number") { } </pre> <p>This method doesn't fold literal values -- we leave that to PeepholeFoldConstants.
 */
private Node tryFoldTypeof(Node typeofNode){
  Preconditions.checkArgument(typeofNode.getType() == Token.TYPEOF);
  Preconditions.checkArgument(typeofNode.getFirstChild() != null);
  Node argumentNode=typeofNode.getFirstChild();
  if (!NodeUtil.isLiteralValue(argumentNode,true) && !NodeUtil.mayHaveSideEffects(argumentNode)) {
    JSType argumentType=argumentNode.getJSType();
    String typeName=null;
    if (argumentType != null) {
      if (argumentType.isObject() || argumentType.isNullType()) {
        typeName="String_Node_Str";
      }
 else       if (argumentType.isStringValueType()) {
        typeName="String_Node_Str";
      }
 else       if (argumentType.isNumberValueType()) {
        typeName="String_Node_Str";
      }
 else       if (argumentType.isBooleanValueType()) {
        typeName="String_Node_Str";
      }
 else       if (argumentType.isVoidType()) {
        typeName="String_Node_Str";
      }
 else       if (argumentType.isUnionType()) {
        typeName=null;
      }
      if (typeName != null) {
        Node newNode=Node.newString(typeName);
        typeofNode.getParent().replaceChild(typeofNode,newNode);
        reportCodeChange();
        return newNode;
      }
    }
  }
  return typeofNode;
}
Program: 28213
Project: 28213
Buggy source:
/** 
 * Look at all the property assigns to all variables in the given scope. These may or may not count as references. For example, <code> var x = {}; x.foo = 3; // not a reference. var y = foo(); y.foo = 3; // is a reference. </code>
 */
private void interpretAssigns(Scope scope){
  for (Iterator<Var> it=scope.getVars(); it.hasNext(); ) {
    Var var=it.next();
    if (!referenced.contains(var)) {
      boolean assignedToUnknownValue=false;
      boolean hasPropertyAssign=false;
      if (var.getParentNode().getType() == Token.VAR) {
        Node value=var.getInitialValue();
        assignedToUnknownValue=value != null && !NodeUtil.isLiteralValue(value);
      }
 else {
        assignedToUnknownValue=true;
      }
      for (      Assign assign : assigns.get(var)) {
        if (assign.isPropertyAssign) {
          hasPropertyAssign=true;
        }
 else         if (!NodeUtil.isLiteralValue(assign.assignNode.getLastChild())) {
          assignedToUnknownValue=true;
        }
      }
      if (assignedToUnknownValue && hasPropertyAssign) {
        markReferencedVar(var);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Look at all the property assigns to all variables in the given scope. These may or may not count as references. For example, <code> var x = {}; x.foo = 3; // not a reference. var y = foo(); y.foo = 3; // is a reference. </code>
 */
private void interpretAssigns(Scope scope){
  for (Iterator<Var> it=scope.getVars(); it.hasNext(); ) {
    Var var=it.next();
    if (!referenced.contains(var)) {
      boolean assignedToUnknownValue=false;
      boolean hasPropertyAssign=false;
      if (var.getParentNode().getType() == Token.VAR) {
        Node value=var.getInitialValue();
        assignedToUnknownValue=value != null && !NodeUtil.isLiteralValue(value,true);
      }
 else {
        assignedToUnknownValue=true;
      }
      for (      Assign assign : assigns.get(var)) {
        if (assign.isPropertyAssign) {
          hasPropertyAssign=true;
        }
 else         if (!NodeUtil.isLiteralValue(assign.assignNode.getLastChild(),true)) {
          assignedToUnknownValue=true;
        }
      }
      if (assignedToUnknownValue && hasPropertyAssign) {
        markReferencedVar(var);
      }
    }
  }
}
Program: 28214
Project: 28214
Buggy source:
public void assertNotLiteral(Node n){
  assertFalse(NodeUtil.isLiteralValue(n));
  assertFalse(NodeUtil.isImmutableValue(n));
}

Fixed version (ground truth):
public void assertNotLiteral(Node n){
  assertFalse(NodeUtil.isLiteralValue(n,true));
  assertFalse(NodeUtil.isLiteralValue(n,false));
  assertFalse(NodeUtil.isImmutableValue(n));
}
Program: 28215
Project: 28215
Buggy source:
public void assertLiteralButNotImmutable(Node n){
  assertTrue(NodeUtil.isLiteralValue(n));
  assertFalse(NodeUtil.isImmutableValue(n));
}

Fixed version (ground truth):
public void assertLiteralButNotImmutable(Node n){
  assertTrue(NodeUtil.isLiteralValue(n,true));
  assertTrue(NodeUtil.isLiteralValue(n,false));
  assertFalse(NodeUtil.isImmutableValue(n));
}
Program: 28217
Project: 28217
Buggy source:
public void assertLiteralAndImmutable(Node n){
  assertTrue(NodeUtil.isLiteralValue(n));
  assertTrue(NodeUtil.isImmutableValue(n));
}

Fixed version (ground truth):
public void assertLiteralAndImmutable(Node n){
  assertTrue(NodeUtil.isLiteralValue(n,true));
  assertTrue(NodeUtil.isLiteralValue(n,false));
  assertTrue(NodeUtil.isImmutableValue(n));
}
Program: 28218
Project: 28218
Buggy source:
public void testFoldTypeof(){
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  foldSame("String_Node_Str");
  foldSame("String_Node_Str");
}

Fixed version (ground truth):
public void testFoldTypeof(){
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  foldSame("String_Node_Str");
  foldSame("String_Node_Str");
}
Program: 28219
Project: 28219
Buggy source:
public void testFoldInstanceOf(){
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  foldSame("String_Node_Str");
  foldSame("String_Node_Str");
  foldSame("String_Node_Str");
}

Fixed version (ground truth):
public void testFoldInstanceOf(){
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  foldSame("String_Node_Str");
  foldSame("String_Node_Str");
  foldSame("String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
}
Program: 28220
Project: 28220
Buggy source:
/** 
 * Returns a version of   {@code type} that is restricted by some knowledgeabout the result of the  {@code typeof} operation..<p> The behavior of the  {@code typeof} operator can be summarized by thefollowing table: <table> <tr><th>type</th><th>result</th></tr> <tr><td> {@code undefined}</td><td>"undefined"</td></tr> <tr><td>  {@code null}</td><td>"object"</td></tr> <tr><td>  {@code boolean}</td><td>"boolean"</td></tr> <tr><td>  {@code number}</td><td>"number"</td></tr> <tr><td>  {@code string}</td><td>"string"</td></tr> <tr><td>  {@code Object} (which doesn't implement [[Call]])</td><td>"object"</td></tr> <tr><td> {@code Object} (which implements [[Call]])</td><td>"function"</td></tr> </table>
 * @param type the type to restrict
 * @param value A value known to be equal or not equal to the result of the{@code typeof} operation
 * @param resultEqualsValue {@code true} if the {@code typeOf} result is knownto equal  {@code value};   {@code false} if it is known <em>not</em> toequal  {@code value}
 * @return the restricted type or null if no version of the type matches therestriction
 */
JSType getRestrictedByTypeOfResult(JSType type,String value,boolean resultEqualsValue){
  return type == null ? null : type.visit(new RestrictByOneTypeOfResultVisitor(value,resultEqualsValue));
}

Fixed version (ground truth):
/** 
 * Returns a version of   {@code type} that is restricted by some knowledgeabout the result of the  {@code typeof} operation.<p> The behavior of the  {@code typeof} operator can be summarized by thefollowing table: <table> <tr><th>type</th><th>result</th></tr> <tr><td> {@code undefined}</td><td>"undefined"</td></tr> <tr><td>  {@code null}</td><td>"object"</td></tr> <tr><td>  {@code boolean}</td><td>"boolean"</td></tr> <tr><td>  {@code number}</td><td>"number"</td></tr> <tr><td>  {@code string}</td><td>"string"</td></tr> <tr><td>  {@code Object} (which doesn't implement [[Call]])</td><td>"object"</td></tr> <tr><td> {@code Object} (which implements [[Call]])</td><td>"function"</td></tr> </table>
 * @param type the type to restrict
 * @param value A value known to be equal or not equal to the result of the{@code typeof} operation
 * @param resultEqualsValue {@code true} if the {@code typeOf} result is knownto equal  {@code value};   {@code false} if it is known <em>not</em> toequal  {@code value}
 * @return the restricted type or null if no version of the type matches therestriction
 */
JSType getRestrictedByTypeOfResult(JSType type,String value,boolean resultEqualsValue){
  if (type == null) {
    if (resultEqualsValue) {
      JSType result=getNativeTypeForTypeOf(value);
      return result == null ? getNativeType(UNKNOWN_TYPE) : result;
    }
 else {
      return null;
    }
  }
  return type.visit(new RestrictByOneTypeOfResultVisitor(value,resultEqualsValue));
}
Program: 28221
Project: 28221
Buggy source:
/** 
 * Declares a refined type in   {@code scope} for the name represented by{@code node}. It must be possible to refine the type of the given node in the given scope, as determined by   {@link #getTypeIfRefinable}.
 */
protected void declareNameInScope(FlowScope scope,Node node,JSType type){
switch (node.getType()) {
case Token.NAME:
    scope.inferSlotType(node.getString(),type);
  break;
case Token.GETPROP:
String qualifiedName=node.getQualifiedName();
Preconditions.checkNotNull(qualifiedName);
JSType origType=node.getJSType();
origType=origType == null ? getNativeType(UNKNOWN_TYPE) : origType;
scope.inferQualifiedSlot(qualifiedName,origType,type);
break;
default :
throw new IllegalArgumentException("String_Node_Str");
}
}

Fixed version (ground truth):
/** 
 * Declares a refined type in   {@code scope} for the name represented by{@code node}. It must be possible to refine the type of the given node in the given scope, as determined by   {@link #getTypeIfRefinable}.
 */
protected void declareNameInScope(FlowScope scope,Node node,JSType type){
switch (node.getType()) {
case Token.NAME:
    scope.inferSlotType(node.getString(),type);
  break;
case Token.GETPROP:
String qualifiedName=node.getQualifiedName();
Preconditions.checkNotNull(qualifiedName);
JSType origType=node.getJSType();
origType=origType == null ? getNativeType(UNKNOWN_TYPE) : origType;
scope.inferQualifiedSlot(qualifiedName,origType,type);
break;
default :
throw new IllegalArgumentException("String_Node_Str" + node.toStringTree());
}
}
Program: 28222
Project: 28222
Buggy source:
@Override protected JSType caseTopType(JSType topType){
  if (resultEqualsValue) {
    if (value.equals("String_Node_Str")) {
      return getNativeType(NUMBER_TYPE);
    }
 else     if (value.equals("String_Node_Str")) {
      return getNativeType(BOOLEAN_TYPE);
    }
 else     if (value.equals("String_Node_Str")) {
      return getNativeType(STRING_TYPE);
    }
 else     if (value.equals("String_Node_Str")) {
      return getNativeType(VOID_TYPE);
    }
 else     if (value.equals("String_Node_Str")) {
      return getNativeType(U2U_CONSTRUCTOR_TYPE);
    }
  }
  return topType;
}

Fixed version (ground truth):
@Override protected JSType caseTopType(JSType topType){
  JSType result=topType;
  if (resultEqualsValue) {
    JSType typeByName=getNativeTypeForTypeOf(value);
    if (typeByName != null) {
      result=typeByName;
    }
  }
  return result;
}
Program: 28223
Project: 28223
Buggy source:
public JSType apply(TypeRestriction p){
  Visitor<JSType> visitor=p.outcome ? restrictToObjectVisitor : restrictToNotObjectVisitor;
  return p.type == null ? null : p.type.visit(visitor);
}

Fixed version (ground truth):
public JSType apply(TypeRestriction p){
  if (p.type == null) {
    return p.outcome ? getNativeType(OBJECT_TYPE) : null;
  }
  Visitor<JSType> visitor=p.outcome ? restrictToObjectVisitor : restrictToNotObjectVisitor;
  return p.type.visit(visitor);
}
Program: 28224
Project: 28224
Buggy source:
public FlowScope getPreciserScopeKnowingConditionOutcome(Node condition,FlowScope blindScope,boolean outcome){
  if (condition.getType() == CALL && condition.getChildCount() == 2) {
    Node callee=condition.getFirstChild();
    Node param=condition.getLastChild();
    if (callee.getType() == GETPROP) {
      JSType paramType=getTypeIfRefinable(param,blindScope);
      if (paramType != null) {
        Node left=callee.getFirstChild();
        Node right=callee.getLastChild();
        if (left.getType() == NAME && "String_Node_Str".equals(left.getString()) && right.getType() == STRING) {
          Function<TypeRestriction,JSType> restricter=restricters.get(right.getString());
          if (restricter != null) {
            return restrictParameter(param,paramType,blindScope,restricter,outcome);
          }
        }
      }
    }
  }
  return nextPreciserScopeKnowingConditionOutcome(condition,blindScope,outcome);
}

Fixed version (ground truth):
@Override public FlowScope getPreciserScopeKnowingConditionOutcome(Node condition,FlowScope blindScope,boolean outcome){
  if (condition.getType() == CALL && condition.getChildCount() == 2) {
    Node callee=condition.getFirstChild();
    Node param=condition.getLastChild();
    if (callee.getType() == GETPROP && param.isQualifiedName()) {
      JSType paramType=getTypeIfRefinable(param,blindScope);
      Node left=callee.getFirstChild();
      Node right=callee.getLastChild();
      if (left.getType() == NAME && "String_Node_Str".equals(left.getString()) && right.getType() == STRING) {
        Function<TypeRestriction,JSType> restricter=restricters.get(right.getString());
        if (restricter != null) {
          return restrictParameter(param,paramType,blindScope,restricter,outcome);
        }
      }
    }
  }
  return nextPreciserScopeKnowingConditionOutcome(condition,blindScope,outcome);
}
Program: 28226
Project: 28226
Buggy source:
private FlowScope traverseName(Node n,FlowScope scope){
  String varName=n.getString();
  Node value=n.getFirstChild();
  JSType type=n.getJSType();
  if (value != null) {
    scope=traverse(value,scope);
    updateScopeForTypeChange(scope,n,n.getJSType(),getJSType(value));
    return scope;
  }
 else {
    StaticSlot<JSType> var=scope.getSlot(varName);
    if (var != null && !(var.isTypeInferred() && unflowableVarNames.contains(varName))) {
      type=var.getType();
      if (type == null) {
        type=getNativeType(UNKNOWN_TYPE);
      }
    }
  }
  n.setJSType(type);
  return scope;
}

Fixed version (ground truth):
private FlowScope traverseName(Node n,FlowScope scope){
  String varName=n.getString();
  Node value=n.getFirstChild();
  JSType type=n.getJSType();
  if (value != null) {
    scope=traverse(value,scope);
    updateScopeForTypeChange(scope,n,n.getJSType(),getJSType(value));
    return scope;
  }
 else {
    StaticSlot<JSType> var=scope.getSlot(varName);
    if (var != null) {
      boolean isInferred=var.isTypeInferred();
      boolean unflowable=isInferred && unflowableVarNames.contains(varName);
      boolean nonLocalInferredSlot=isInferred && syntacticScope.getParent() != null && var == syntacticScope.getParent().getSlot(varName);
      if (!unflowable && !nonLocalInferredSlot) {
        type=var.getType();
        if (type == null) {
          type=getNativeType(UNKNOWN_TYPE);
        }
      }
    }
  }
  n.setJSType(type);
  return scope;
}
Program: 28227
Project: 28227
Buggy source:
/** 
 * Uses the Y scale factor to calculate the min possible height.
 */
@Override public int getMinHeightPlusMargin(){
  return (int)((getOriginalHeight() / getYScaleFactor()) + getMarginBottom());
}

Fixed version (ground truth):
/** 
 * Uses the Y scale factor to calculate the min possible height.
 */
@Override public int getMinHeightPlusMargin(){
  return (int)(getOriginalHeight() * (1 - 1 / getYScaleFactor()) + getMarginBottom());
}
Program: 28228
Project: 28228
Buggy source:
/** 
 * Override method used to apply different scale and alpha effects while the view is being dragged.
 * @param left position.
 * @param top position.
 * @param dx change in X position from the last call.
 * @param dy change in Y position from the last call.
 */
@Override public void onViewPositionChanged(View changedView,int left,int top,int dx,int dy){
  if (draggableView.isDragViewAtBottom()) {
    draggableView.changeDragViewViewAlpha();
  }
 else {
    draggableView.restoreAlpha();
    draggableView.changeDragViewScale();
    draggableView.changeDragViewPosition();
    draggableView.changeSecondViewAlpha();
    draggableView.changeSecondViewPosition();
    draggableView.changeBackgroundAlpha();
  }
}

Fixed version (ground truth):
/** 
 * Override method used to apply different scale and alpha effects while the view is being dragged.
 * @param left position.
 * @param top position.
 * @param dx change in X position from the last call.
 * @param dy change in Y position from the last call.
 */
@Override public void onViewPositionChanged(View changedView,int left,int top,int dx,int dy){
  if (0 == top) {
    draggableView.requestLayout();
  }
  if (draggableView.isDragViewAtBottom()) {
    draggableView.changeDragViewViewAlpha();
  }
 else {
    draggableView.restoreAlpha();
    draggableView.changeDragViewScale();
    draggableView.changeDragViewPosition();
    draggableView.changeSecondViewAlpha();
    draggableView.changeSecondViewPosition();
    draggableView.changeBackgroundAlpha();
  }
}
Program: 28229
Project: 28229
Buggy source:
/** 
 * Close the view to the right, to the left or minimize it using the draggableView position and the x axis velocity.
 */
private void triggerOnReleaseActionsWhileHorizontalDrag(float xVel){
  if (xVel < 0 && xVel <= X_MIN_VELOCITY) {
    draggableView.closeToLeft();
  }
 else   if (xVel > 0 && xVel >= X_MIN_VELOCITY) {
    draggableView.closeToRight();
  }
 else {
    if (draggableView.isNextToLeftBound()) {
      draggableView.closeToLeft();
    }
 else     if (draggableView.isNextToRightBound()) {
      draggableView.closeToRight();
    }
 else {
      draggableView.minimize();
    }
  }
}

Fixed version (ground truth):
/** 
 * Close the view to the right, to the left or minimize it using the draggableView position and the x axis velocity.
 */
private void triggerOnReleaseActionsWhileHorizontalDrag(float xVel){
  if (xVel < 0 && xVel <= -X_MIN_VELOCITY) {
    draggableView.closeToLeft();
  }
 else   if (xVel > 0 && xVel >= X_MIN_VELOCITY) {
    draggableView.closeToRight();
  }
 else {
    if (draggableView.isNextToLeftBound()) {
      draggableView.closeToLeft();
    }
 else     if (draggableView.isNextToRightBound()) {
      draggableView.closeToRight();
    }
 else {
      draggableView.minimize();
    }
  }
}
Program: 28230
Project: 28230
Buggy source:
/** 
 * @return true if the left position of the view is to the left of the twenty five percent ofthe parent width.
 */
@Override public boolean isNextToLeftBound(){
  return (getView().getLeft() - getMarginRight()) < getParentView().getWidth() * 0.25;
}

Fixed version (ground truth):
/** 
 * @return true if the right position of the view is to the left of sixty percent of the parentwidth.
 */
@Override public boolean isNextToLeftBound(){
  return (getView().getRight() - getMarginRight()) < getParentView().getWidth() * 0.6;
}
Program: 28231
Project: 28231
Buggy source:
/** 
 * @return true if the left position of the view is to the right of the twenty five percent ofthe parent width.
 */
@Override public boolean isNextToRightBound(){
  return (getView().getLeft() - getMarginRight()) > getParentView().getWidth() * 0.25;
}

Fixed version (ground truth):
/** 
 * @return true if the right position of the view is to the right of the one hundred twenty fivefive percent of the parent view width.
 */
@Override public boolean isNextToRightBound(){
  return (getView().getRight() - getMarginRight()) > getParentView().getWidth() * 1.25;
}
Program: 28232
Project: 28232
Buggy source:
/** 
 * Close the view to the right, to the left or minimize it using the draggableView position and the x axis velocity.
 * @param xVel
 */
private void triggerOnReleaseActionsWhileHorizontalDrag(float xVel){
  if (xVel < 0 && xVel <= X_MIN_VELOCITY) {
    draggableView.closeToLeft();
  }
 else   if (xVel > 0 && xVel >= X_MIN_VELOCITY) {
    draggableView.closeToRight();
  }
 else {
    if (draggableView.isNextToLeftBound()) {
      draggableView.closeToLeft();
    }
 else     if (draggableView.isNextToRightBound()) {
      draggableView.closeToRight();
    }
 else {
      draggableView.minimize();
    }
  }
}

Fixed version (ground truth):
/** 
 * Close the view to the right, to the left or minimize it using the draggableView position and the x axis velocity.
 * @param xVel
 */
private void triggerOnReleaseActionsWhileHorizontalDrag(float xVel){
  if (xVel < 0 && xVel <= -X_MIN_VELOCITY) {
    draggableView.closeToLeft();
  }
 else   if (xVel > 0 && xVel >= X_MIN_VELOCITY) {
    draggableView.closeToRight();
  }
 else {
    if (draggableView.isNextToLeftBound()) {
      draggableView.closeToLeft();
    }
 else     if (draggableView.isNextToRightBound()) {
      draggableView.closeToRight();
    }
 else {
      draggableView.minimize();
    }
  }
}
Program: 28233
Project: 28233
Buggy source:
/** 
 * Override method to configure the dragged view and secondView layout properly.
 */
@Override protected void onLayout(boolean changed,int left,int top,int right,int bottom){
  int newTop=(int)transformer.getViewHeight();
  int lastTopPosition=transformer.getLastTopPosition();
  int lastLeftPosition=transformer.getLastLeftPosition();
  int newRight=transformer.getLastRightPosition();
  int newBottom=lastTopPosition + newTop;
  dragView.layout(lastLeftPosition,lastTopPosition,newRight,newBottom);
  secondView.layout(0,(int)transformer.getOriginalHeight(),right,getHeight());
}

Fixed version (ground truth):
/** 
 * Override method to configure the dragged view and secondView layout properly.
 */
@Override protected void onLayout(boolean changed,int left,int top,int right,int bottom){
  if (isInEditMode())   super.onLayout(changed,left,top,right,bottom);
 else   if (isDragViewAtTop()) {
    dragView.layout(left,top,right,(int)transformer.getOriginalHeight());
    secondView.layout(left,(int)transformer.getOriginalHeight(),right,bottom);
    ViewHelper.setY(dragView,top);
    ViewHelper.setY(secondView,transformer.getOriginalHeight());
  }
}
Program: 28234
Project: 28234
Buggy source:
/** 
 * Override method used to configure the horizontal drag. Restrict the motion of the dragged child view along the horizontal axis.
 * @param child child view being dragged.
 * @param left attempted motion along the X axis.
 * @param dx proposed change in position for left.
 * @return the new clamped position for left.
 */
@Override public int clampViewPositionHorizontal(View child,int left,int dx){
  int newLeft=draggedView.getLeft();
  if ((draggableView.isMinimized() && Math.abs(dx) > MINIMUN_DX_FOR_HORIZONTAL_DRAG) || (draggableView.isDragViewAtBottom() && !draggableView.isDragViewAtRight())) {
    newLeft=left;
  }
  return newLeft;
}

Fixed version (ground truth):
/** 
 * Override method used to configure the horizontal drag. Restrict the motion of the dragged child view along the horizontal axis.
 * @param child child view being dragged.
 * @param left attempted motion along the X axis.
 * @param dx proposed change in position for left.
 * @return the new clamped position for left.
 */
@Override public int clampViewPositionHorizontal(View child,int left,int dx){
  int newLeft=draggedView.getLeft();
  if ((draggableView.isMinimized() && Math.abs(dx) > MINIMUM_DX_FOR_HORIZONTAL_DRAG) || (draggableView.isDragViewAtBottom() && !draggableView.isDragViewAtRight())) {
    newLeft=left;
  }
  return newLeft;
}
Program: 28235
Project: 28235
Buggy source:
/** 
 * Close the view to the right, to the left or minimize it using the draggableView position and the x axis velocity.
 */
private void triggerOnReleaseActionsWhileHorizontalDrag(float xVel){
  if (xVel < 0 && xVel <= X_MIN_VELOCITY) {
    draggableView.closeToLeft();
  }
 else   if (xVel > 0 && xVel >= X_MIN_VELOCITY) {
    draggableView.closeToRight();
  }
 else {
    if (draggableView.isNextToLeftBound()) {
      draggableView.closeToLeft();
    }
 else     if (draggableView.isNextToRightBound()) {
      draggableView.closeToRight();
    }
 else {
      draggableView.minimize();
    }
  }
}

Fixed version (ground truth):
/** 
 * Close the view to the right, to the left or minimize it using the draggableView position and the x axis velocity.
 */
private void triggerOnReleaseActionsWhileHorizontalDrag(float xVel){
  if (xVel < 0 && xVel <= -X_MIN_VELOCITY) {
    draggableView.closeToLeft();
  }
 else   if (xVel > 0 && xVel >= X_MIN_VELOCITY) {
    draggableView.closeToRight();
  }
 else {
    if (draggableView.isNextToLeftBound()) {
      draggableView.closeToLeft();
    }
 else     if (draggableView.isNextToRightBound()) {
      draggableView.closeToRight();
    }
 else {
      draggableView.minimize();
    }
  }
}
Program: 28236
Project: 28236
Buggy source:
/** 
 * Realize an smooth slide to an slide offset passed as argument. This method is the base of maximize, minimize and close methods.
 * @param slideOffset to apply
 * @return true if the view is slided.
 */
private boolean smoothSlideTo(float slideOffset){
  final int topBound=getPaddingTop();
  int y=(int)(topBound + slideOffset * getVerticalDragRange());
  int x=(int)(slideOffset * (getWidth() - transformer.getMinWidth()));
  if (viewDragHelper.smoothSlideViewTo(dragView,x,y)) {
    ViewCompat.postInvalidateOnAnimation(this);
    return true;
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Realize an smooth slide to an slide offset passed as argument. This method is the base of maximize, minimize and close methods.
 * @param slideOffset to apply
 * @return true if the view is slided.
 */
private boolean smoothSlideTo(float slideOffset){
  final int topBound=getPaddingTop();
  int x=(int)(slideOffset * (getWidth() - transformer.getMinWidth()));
  int y=(int)(topBound + slideOffset * getVerticalDragRange());
  if (viewDragHelper.smoothSlideViewTo(dragView,x,y)) {
    ViewCompat.postInvalidateOnAnimation(this);
    return true;
  }
  return false;
}
Program: 28237
Project: 28237
Buggy source:
/** 
 * Modify secondView position to be always below dragged view.
 */
void changeSecondViewPosition(){
  ViewHelper.setY(secondView,dragView.getBottom());
  ViewHelper.setX(secondView,dragView.getLeft());
}

Fixed version (ground truth):
/** 
 * Modify secondView position to be always below dragged view.
 */
void changeSecondViewPosition(){
  ViewHelper.setY(secondView,dragView.getBottom());
}
Program: 28238
Project: 28238
Buggy source:
@Override public void updateWidth(float verticalDragOffset){
  RelativeLayout.LayoutParams params=(RelativeLayout.LayoutParams)getView().getLayoutParams();
  int newWidth=(int)(getOriginalWidth() * (1 - verticalDragOffset / getxScaleFactor()));
  params.width=newWidth;
  getView().setLayoutParams(params);
}

Fixed version (ground truth):
@Override public void updateWidth(float verticalDragOffset){
  RelativeLayout.LayoutParams params=(RelativeLayout.LayoutParams)getView().getLayoutParams();
  int newWidth=(int)(getOriginalWidth() * (1 - verticalDragOffset / getxScaleFactor()));
  params.width=newWidth;
  setLastLeftPosition((int)(getOriginalWidth() - newWidth));
  getView().setLayoutParams(params);
}
Program: 28239
Project: 28239
Buggy source:
/** 
 * Override method to configure the dragged view and secondView layout properly.
 * @param changed
 * @param left
 * @param top
 * @param right
 * @param bottom
 */
@Override protected void onLayout(boolean changed,int left,int top,int right,int bottom){
  int newTop=(int)transformer.getViewHeight();
  int lastTopPosition=transformer.getLastTopPosition();
  int lastLeftPosition=transformer.getLastLeftPosition();
  int newRight=transformer.getLastRightPosition();
  dragView.layout(lastLeftPosition,lastTopPosition,newRight,lastTopPosition + newTop);
  secondView.layout(0,lastTopPosition + newTop,right,lastTopPosition + bottom);
}

Fixed version (ground truth):
/** 
 * Override method to configure the dragged view and secondView layout properly.
 * @param changed
 * @param left
 * @param top
 * @param right
 * @param bottom
 */
@Override protected void onLayout(boolean changed,int left,int top,int right,int bottom){
  int newTop=(int)transformer.getViewHeight();
  int lastTopPosition=transformer.getLastTopPosition();
  int lastLeftPosition=transformer.getLastLeftPosition();
  int newRight=transformer.getLastRightPosition();
  int newBottom=lastTopPosition + newTop;
  dragView.layout(lastLeftPosition,lastTopPosition,newRight,newBottom);
  secondView.layout(0,newBottom,right,lastTopPosition + bottom);
}
Program: 28240
Project: 28240
Buggy source:
/** 
 * Override method used to apply different scale and alpha effects while the view is being dragged.
 * @param changedView
 * @param left        position.
 * @param top         position.
 * @param dx          change in X position from the last call.
 * @param dy          change in Y position from the last call.
 */
@Override public void onViewPositionChanged(View changedView,int left,int top,int dx,int dy){
  draggableView.updateLastDragViewPosition(top,left);
  if (draggableView.isDragViewAtBottom()) {
    draggableView.changeDragViewViewAlpha();
  }
 else {
    draggableView.changeDragViewScale();
    draggableView.changeDragViewPosition();
    draggableView.changeSecondViewAlpha();
    draggableView.changeSecondViewPosition();
    draggableView.changeBackgroundAlpha();
  }
  draggableView.invalidate();
}

Fixed version (ground truth):
/** 
 * Override method used to apply different scale and alpha effects while the view is being dragged.
 * @param changedView
 * @param left        position.
 * @param top         position.
 * @param dx          change in X position from the last call.
 * @param dy          change in Y position from the last call.
 */
@Override public void onViewPositionChanged(View changedView,int left,int top,int dx,int dy){
  draggableView.updateLastDragViewPosition(top,left);
  if (draggableView.isDragViewAtBottom()) {
    draggableView.changeDragViewViewAlpha();
  }
 else {
    draggableView.restoreAlpha();
    draggableView.changeDragViewScale();
    draggableView.changeDragViewPosition();
    draggableView.changeSecondViewAlpha();
    draggableView.changeSecondViewPosition();
    draggableView.changeBackgroundAlpha();
  }
}
Program: 28241
Project: 28241
Buggy source:
boolean isNextToRightBound(){
  return (dragView.getLeft() - getDragViewMarginRight()) > getWidth() * 0.25;
}

Fixed version (ground truth):
boolean isNextToRightBound(){
  return (dragView.getLeft() - getDragViewMarginRight()) > getWidth() * QUARTER;
}
Program: 28242
Project: 28242
Buggy source:
boolean isHeaderAboveTheMiddle(){
  int viewHeight=getHeight();
  float viewHeaderY=ViewHelper.getY(dragView) + (dragView.getHeight() / 2);
  return viewHeaderY < (viewHeight * 0.5f);
}

Fixed version (ground truth):
boolean isHeaderAboveTheMiddle(){
  int viewHeight=getHeight();
  float viewHeaderY=ViewHelper.getY(dragView) + (dragView.getHeight() * HALF);
  return viewHeaderY < (viewHeight * HALF);
}
Program: 28243
Project: 28243
Buggy source:
void changeBackgroundAlpha(){
  Drawable background=getBackground();
  if (background != null) {
    int newAlpha=(int)(100 * (1 - getVerticalDragOffset()));
    background.setAlpha(newAlpha);
  }
}

Fixed version (ground truth):
void changeBackgroundAlpha(){
  Drawable background=getBackground();
  if (background != null) {
    int newAlpha=(int)(ONE_HUNDRED * (1 - getVerticalDragOffset()));
    background.setAlpha(newAlpha);
  }
}
Program: 28244
Project: 28244
Buggy source:
boolean isDragViewAtTop(){
  return dragView.getTop() == 0;
}

Fixed version (ground truth):
boolean isDragViewAtTop(){
  return dragView.getTop() == ZERO;
}
Program: 28245
Project: 28245
Buggy source:
boolean isNextToLeftBound(){
  return (dragView.getRight() - getDragViewMarginRight()) < getWidth() / 2;
}

Fixed version (ground truth):
boolean isNextToLeftBound(){
  return (dragView.getRight() - getDragViewMarginRight()) < getWidth() * HALF;
}
Program: 28246
Project: 28246
Buggy source:
@Override protected void onLayout(boolean changed,int left,int top,int right,int bottom){
  int topViewHeight=this.topViewHeight == DEFAULT_TOP_VIEW_HEIGHT ? dragView.getMeasuredHeight() : (int)this.topViewHeight;
  dragView.layout(lastLeftPosition,lastTopPosition,lastLeftPosition + dragView.getMeasuredWidth(),lastTopPosition + topViewHeight);
  secondView.layout(0,lastTopPosition + topViewHeight,right,lastTopPosition + bottom);
}

Fixed version (ground truth):
@Override protected void onLayout(boolean changed,int left,int top,int right,int bottom){
  int newTop=this.topViewHeight == DEFAULT_TOP_VIEW_HEIGHT ? dragView.getMeasuredHeight() : (int)this.topViewHeight;
  dragView.layout(lastLeftPosition,lastTopPosition,lastLeftPosition + dragView.getMeasuredWidth(),lastTopPosition + newTop);
  secondView.layout(0,lastTopPosition + newTop,right,lastTopPosition + bottom);
}
Program: 28247
Project: 28247
Buggy source:
@Override public boolean tryCaptureView(View view,int pointerId){
  return view == capturedView;
}

Fixed version (ground truth):
@Override public boolean tryCaptureView(View view,int pointerId){
  return view.equals(capturedView);
}
Program: 28248
Project: 28248
Buggy source:
@Override public int clampViewPositionVertical(View child,int top,int dy){
  int newTop=draggableView.getHeight() - capturedView.getHeight();
  if (draggableView.isMinimized() && (dy >= MINIMUM_DY_FOR_VERTICAL_DRAG || dy >= -MINIMUM_DY_FOR_VERTICAL_DRAG) || (!draggableView.isMinimized() && !draggableView.isDragViewAtBottom())) {
    final int topBound=draggableView.getPaddingTop();
    final int bottomBound=draggableView.getHeight() - child.getHeight() - child.getPaddingBottom();
    newTop=Math.min(Math.max(top,topBound),bottomBound);
  }
  return newTop;
}

Fixed version (ground truth):
@Override public int clampViewPositionVertical(View child,int top,int dy){
  int newTop=draggableView.getHeight() - capturedView.getHeight();
  if (draggableView.isMinimized() && Math.abs(dy) >= MINIMUM_DY_FOR_VERTICAL_DRAG || (!draggableView.isMinimized() && !draggableView.isDragViewAtBottom())) {
    final int topBound=draggableView.getPaddingTop();
    final int bottomBound=draggableView.getHeight() - child.getHeight() - child.getPaddingBottom();
    newTop=Math.min(Math.max(top,topBound),bottomBound);
  }
  return newTop;
}
Program: 28249
Project: 28249
Buggy source:
@Override public void onViewReleased(View releasedChild,float xVel,float yVel){
  super.onViewReleased(releasedChild,xVel,yVel);
  if (draggableView.isDragViewAtBottom() && !draggableView.isDragViewAtRight()) {
    if (xVel < 0 && xVel <= X_MIN_VELOCITY) {
      draggableView.closeToLeft();
    }
 else     if (xVel > 0 && xVel >= X_MIN_VELOCITY) {
      draggableView.closeToRight();
    }
 else {
      if (draggableView.isNextToLeftBound()) {
        draggableView.closeToLeft();
      }
 else       if (draggableView.isNextToRightBound()) {
        draggableView.closeToRight();
      }
 else {
        draggableView.minimize();
      }
    }
  }
 else {
    if (yVel < 0 && yVel <= -Y_MIN_VELOCITY) {
      draggableView.maximize();
    }
 else     if (yVel > 0 && yVel >= Y_MIN_VELOCITY) {
      draggableView.minimize();
    }
 else {
      if (draggableView.isHeaderAboveTheMiddle()) {
        draggableView.maximize();
      }
 else {
        draggableView.minimize();
      }
    }
  }
}

Fixed version (ground truth):
@Override public void onViewReleased(View releasedChild,float xVel,float yVel){
  super.onViewReleased(releasedChild,xVel,yVel);
  if (draggableView.isDragViewAtBottom() && !draggableView.isDragViewAtRight()) {
    triggerOnReleaseActionsWhileHorizontalDrag(xVel);
  }
 else {
    triggerOnReleaseActionsWhileVerticalDrag(yVel);
  }
}