Skip to content
Snippets Groups Projects
Commit 018573ad authored by Zbynek Slajchrt's avatar Zbynek Slajchrt
Browse files

Forward analysis for shouldBe fixed

parent 4f92b143
No related branches found
No related tags found
No related merge requests found
......@@ -22,6 +22,7 @@
*/
package com.oracle.truffle.r.nodes.builtin;
import static com.oracle.truffle.r.nodes.builtin.CastBuilder.Predef.anyValue;
import static com.oracle.truffle.r.nodes.builtin.CastBuilder.Predef.abstractVectorValue;
import static com.oracle.truffle.r.nodes.builtin.CastBuilder.Predef.asBoolean;
import static com.oracle.truffle.r.nodes.builtin.CastBuilder.Predef.asInteger;
......@@ -861,6 +862,26 @@ public class CastBuilderTest {
Assert.assertEquals("abc", cast("abc"));
}
@Test
public void testWarningInElseBranchOfMapIf() {
arg.mapIf(numericValue(),
chain(asIntegerVector()).with(findFirst().integerElement()).end(),
chain(asIntegerVector()).with(Predef.shouldBe(anyValue().not(), RError.NO_CALLER, RError.Message.NA_INTRODUCED_COERCION)).end());
Assert.assertEquals(1, cast(1));
Assert.assertEquals(1, cast("1"));
Assert.assertEquals(RError.Message.NA_INTRODUCED_COERCION.message, CastNode.getLastWarning());
}
@Test
public void testWarningInTrueBranchOfMapIf() {
arg.allowNull().mapIf(stringValue(), chain(asStringVector()).with(shouldBe(anyValue().not(),
RError.SHOW_CALLER, RError.Message.NA_INTRODUCED_COERCION)).end(),
asIntegerVector());
Assert.assertEquals("1", cast("1"));
Assert.assertEquals(RError.Message.NA_INTRODUCED_COERCION.message, CastNode.getLastWarning());
}
/**
* Casts given object using the configured pipeline in {@link #arg}.
*/
......
......@@ -151,6 +151,15 @@ public final class ForwardingAnalysisResult {
nullForwarded,
missingForwarded,
invalid);
} else if (Object.class == tp) {
return new ForwardingAnalysisResult(FORWARDED,
FORWARDED,
FORWARDED,
FORWARDED,
FORWARDED,
FORWARDED,
FORWARDED,
invalid);
} else {
return this;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment