diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastBaseNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastBaseNode.java index e978790e993e88ae7858bcdb73eee4f7fc9dffc4..46d1c12b92bce59399c1a4f98da2bc332002b5df 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastBaseNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastBaseNode.java @@ -184,11 +184,7 @@ public abstract class CastBaseNode extends CastNode { } protected boolean isReusable(RAbstractVector v) { - // Reusing only of complete vectors otherwise we will produce different warning output - if (reuseNonShared && v.isComplete() && v instanceof RSharingAttributeStorage) { - return !((RSharingAttributeStorage) v).isShared(); - } - return false; + return reuseNonShared; } protected RAbstractVector castWithReuse(RType targetType, RAbstractVector v, ConditionProfile naProfile) { diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/closures/RToComplexVectorClosure.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/closures/RToComplexVectorClosure.java index 14fd6c978272552ff618e0d6de7bbf44392c94a7..3932e3c982f38996b40e23e04baf91063b7f6c74 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/closures/RToComplexVectorClosure.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/closures/RToComplexVectorClosure.java @@ -71,7 +71,7 @@ abstract class RToComplexVectorClosure extends RToVectorClosure implements RAbst @Override public final RAbstractComplexVector copyWithNewDimensions(int[] newDimensions) { - if (!keepAttributes) { + if (keepAttributes) { return materialize().copyWithNewDimensions(newDimensions); } return this; diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/closures/RToIntVectorClosure.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/closures/RToIntVectorClosure.java index ee9fafbb913ca62a0bc6aa93240ce4dbe1196d2e..6c925729975a0d1b883decff1924b03548041c2a 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/closures/RToIntVectorClosure.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/closures/RToIntVectorClosure.java @@ -69,7 +69,7 @@ abstract class RToIntVectorClosure extends RToVectorClosure implements RAbstract @Override public final RAbstractIntVector copyWithNewDimensions(int[] newDimensions) { - if (!keepAttributes) { + if (keepAttributes) { return materialize().copyWithNewDimensions(newDimensions); } return this; @@ -103,6 +103,7 @@ final class RLogicalToIntVectorClosure extends RToIntVectorClosure implements RA final class RDoubleToIntVectorClosure extends RToIntVectorClosure implements RAbstractIntVector { private final RDoubleVector vector; + private boolean naReported; RDoubleToIntVectorClosure(RDoubleVector vector, boolean keepAttributes) { super(keepAttributes); @@ -122,7 +123,10 @@ final class RDoubleToIntVectorClosure extends RToIntVectorClosure implements RAb } int result = (int) value; if (result == Integer.MIN_VALUE || value > Integer.MAX_VALUE) { - RError.warning(RError.SHOW_CALLER2, RError.Message.NA_INTRODUCED_COERCION); + if (!naReported) { + RError.warning(RError.SHOW_CALLER2, RError.Message.NA_INTRODUCED_COERCION); + naReported = true; + } return RRuntime.INT_NA; } return result; @@ -132,6 +136,7 @@ final class RDoubleToIntVectorClosure extends RToIntVectorClosure implements RAb final class RDoubleSequenceToIntVectorClosure extends RToIntVectorClosure implements RAbstractIntVector { private final RDoubleSequence vector; + private boolean naReported; RDoubleSequenceToIntVectorClosure(RDoubleSequence vector, boolean keepAttributes) { super(keepAttributes); @@ -151,7 +156,10 @@ final class RDoubleSequenceToIntVectorClosure extends RToIntVectorClosure implem } int result = (int) value; if (result == Integer.MIN_VALUE || value > Integer.MAX_VALUE) { - RError.warning(RError.SHOW_CALLER2, RError.Message.NA_INTRODUCED_COERCION); + if (!naReported) { + RError.warning(RError.SHOW_CALLER2, RError.Message.NA_INTRODUCED_COERCION); + naReported = true; + } return RRuntime.INT_NA; } return result;