예제 #1
0
  @Test
  public void analyzingLambdaCreatedFromPrimitiveLambdaThatNeedsNarrowConversionFromLongToInt()
      throws Exception {
    class C {
      void m() {
        LambdaPrimitives.λ(l, idx, 0);
      }
    }

    LambdaAnalyzer lambda = lambdaIn(C.class);

    assertEquals(getType(Fn2LLtoL.class), lambda.lambdaType);

    assertEquals(list(LONG_TYPE, LONG_TYPE), list(lambda.sam.getArgumentTypes()));
    assertEquals(list(LONG_TYPE, INT_TYPE), lambda.getParameterTypes());

    assertFalse(lambda.parameterNeedsUnboxing("l"));
    assertFalse(lambda.parameterNeedsBoxing("l"));
    assertFalse(lambda.parameterNeedsNarrowConversionFromActualArgument("l"));
    assertEquals(-1, lambda.parameterNarrowConversionOpcode("l"));

    assertFalse(lambda.parameterNeedsUnboxing("idx"));
    assertFalse(lambda.parameterNeedsBoxing("idx"));
    assertTrue(lambda.parameterNeedsNarrowConversionFromActualArgument("idx"));
    assertEquals(L2I, lambda.parameterNarrowConversionOpcode("idx"));

    assertEquals(LONG_TYPE, lambda.expressionType);
    assertEquals(LONG_TYPE, lambda.sam.getReturnType());
  }
예제 #2
0
  @Test
  public void analyzingLambdaCreatedFromPrimitiveLambdaThatNeedsNarrowConversionFromDoubleToFloat()
      throws Exception {
    class C {
      void m() {
        LambdaPrimitives.λ(d, fl, 0);
      }
    }

    LambdaAnalyzer lambda = lambdaIn(C.class);

    assertEquals(getType(Fn2DDtoD.class), lambda.lambdaType);
    assertEquals(list(DOUBLE_TYPE, DOUBLE_TYPE), list(lambda.sam.getArgumentTypes()));
    assertEquals(list(DOUBLE_TYPE, FLOAT_TYPE), lambda.getParameterTypes());

    assertFalse(lambda.parameterNeedsUnboxing("fl"));
    assertFalse(lambda.parameterNeedsBoxing("fl"));
    assertTrue(lambda.parameterNeedsNarrowConversionFromActualArgument("fl"));
    assertEquals(D2F, lambda.parameterNarrowConversionOpcode("fl"));
  }