diff --git a/com.oracle.truffle.r.nodes.test/src/com/oracle/truffle/r/nodes/casts/CastUtils.java b/com.oracle.truffle.r.nodes.test/src/com/oracle/truffle/r/nodes/casts/CastUtils.java index 0b68e310c4c02f17aa36a82d62c5418da65a652f..5480da712a35eec8b8dee79aba852242d7f1ed58 100644 --- a/com.oracle.truffle.r.nodes.test/src/com/oracle/truffle/r/nodes/casts/CastUtils.java +++ b/com.oracle.truffle.r.nodes.test/src/com/oracle/truffle/r/nodes/casts/CastUtils.java @@ -324,9 +324,14 @@ public class CastUtils { } else { Casts positiveCasts = new Casts(cs.stream().filter(c -> existsConvertibleActualType(actualInputTypes, c.inputType(), true)).collect(Collectors.toList())); TypeExpr positive = positiveCasts.casts().stream().map(c -> TypeExpr.atom(c.resultType())).reduce((res, te) -> res.or(te)).orElse(TypeExpr.NOTHING); - - Casts negativeCasts = new Casts(cs.stream().filter(c -> !positiveCasts.resultTypes().contains(c.resultType()) && - !existsConvertibleActualType(actualInputTypes, c.inputType(), true)).collect(Collectors.toList())); + Casts negativeCasts = new Casts( + cs.stream().filter(c -> !existsConvertibleActualType(actualInputTypes, c.inputType(), true) && + // Make sure that the negativeCasts set contains no + // cast whose return type is + // convertible to the return type of any cast from + // the positiveCasts set + positiveCasts.resultTypes().stream().allMatch(posResTp -> isConvertible(c.resultType(), posResTp, false) == Cast.Coverage.none)).collect( + Collectors.toList())); TypeExpr negative = negativeCasts.casts().stream().map(c -> TypeExpr.atom(c.resultType()).not()).reduce((res, te) -> res.and(te)).orElse(TypeExpr.ANYTHING); return positive.and(negative); diff --git a/com.oracle.truffle.r.nodes.test/src/com/oracle/truffle/r/nodes/castsTests/ResultTypesAnalyserTest.java b/com.oracle.truffle.r.nodes.test/src/com/oracle/truffle/r/nodes/castsTests/ResultTypesAnalyserTest.java index 3cfa577f864115872c0ad8d9f93ce70677ce63d8..19dea4141a5e586b2ec7d72acdda23230574ff71 100644 --- a/com.oracle.truffle.r.nodes.test/src/com/oracle/truffle/r/nodes/castsTests/ResultTypesAnalyserTest.java +++ b/com.oracle.truffle.r.nodes.test/src/com/oracle/truffle/r/nodes/castsTests/ResultTypesAnalyserTest.java @@ -127,8 +127,7 @@ public class ResultTypesAnalyserTest { @Test public void testAsLogicalVector() { arg.asLogicalVector(); - assertTypes(RNull.class, RMissing.class, byte.class, RLogicalVector.class, - RArgsValuesAndNames.class); + assertTypes(RNull.class, RMissing.class, byte.class, RLogicalVector.class); } @Test