From 8ca8029d00df9b21b2918221c80a4ffb021446e6 Mon Sep 17 00:00:00 2001
From: Adam Welc <adam.welc@oracle.com>
Date: Fri, 11 Mar 2016 15:58:04 -0800
Subject: [PATCH] Fixed (temporarily) a problem with invoking "any" function on
 data frames.

---
 .../builtin/base/R/dataframe_overrides.R      | 30 +++++++++++++++++++
 .../r/test/builtins/TestBuiltin_any.java      |  2 ++
 2 files changed, 32 insertions(+)
 create mode 100644 com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/R/dataframe_overrides.R

diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/R/dataframe_overrides.R b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/R/dataframe_overrides.R
new file mode 100644
index 0000000000..2d61513b53
--- /dev/null
+++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/R/dataframe_overrides.R
@@ -0,0 +1,30 @@
+#  File src/library/base/R/dataframe.R
+#  Part of the R package, http://www.R-project.org
+#
+#  This program is free software; you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  A copy of the GNU General Public License is available at
+#  http://www.r-project.org/Licenses/
+
+# Statlib code by John Chambers, Bell Labs, 1994
+# Changes Copyright (C) 1998-2014 The R Core Team
+
+Summary.data.frame <- function(..., na.rm=FALSE)
+{
+    args <- list(...)
+    args <- lapply(args, function(x) {
+        x <- as.matrix(x)
+        if(!is.numeric(x) && !is.complex(x))
+            stop("only defined on a data frame with all numeric variables")
+        x
+    })
+    do.call(.Generic, c(args, na.rm=na.rm))
+}
diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_any.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_any.java
index f2d23109a8..dfc6232901 100644
--- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_any.java
+++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_any.java
@@ -122,5 +122,7 @@ public class TestBuiltin_any extends TestBase {
         assertEval(Ignored.Unknown, Output.ContainsWarning, "{ any(1) }");
         // FIXME coercion warning missing
         assertEval(Ignored.Unknown, Output.ContainsWarning, "{ any(0) }");
+
+        assertEval("{ d<-data.frame(c(1L,2L), c(10L, 20L)); any(d) }");
     }
 }
-- 
GitLab