예제 #1
0
  void check(JavaSource source, ErrorChecker ec, int id) {
    boolean resolutionError = false;
    VarargsMethod selectedMethod = null;

    boolean m1_applicable = m1.isApplicable(actuals);
    boolean m2_applicable = m2.isApplicable(actuals);

    if (!m1_applicable && !m2_applicable) {
      resolutionError = true;
    } else if (m1_applicable && m2_applicable) {
      // most specific
      boolean m1_moreSpecific = m1.isMoreSpecificThan(m2);
      boolean m2_moreSpecific = m2.isMoreSpecificThan(m1);

      resolutionError = m1_moreSpecific == m2_moreSpecific;
      selectedMethod = m1_moreSpecific ? m1 : m2;
    } else {
      selectedMethod = m1_applicable ? m1 : m2;
    }

    if (ec.errorFound != resolutionError) {
      throw new Error(
          "invalid diagnostics for source:\n"
              + source.getCharContent(true)
              + "\nExpected resolution error: "
              + resolutionError
              + "\nFound error: "
              + ec.errorFound
              + "\nCompiler diagnostics:\n"
              + ec.printDiags());
    } else if (!resolutionError) {
      verifyBytecode(selectedMethod, source, id);
    }
  }
예제 #2
0
 public JavaSource(
     VarargsMethod m1, VarargsMethod m2, TypeKind actual, ArgumentsArity argsArity) {
   super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
   source =
       source_template
           .replaceAll("#V1", m1.toString())
           .replaceAll("#V2", m2.toString())
           .replaceAll("#E", argsArity.asExpressionList(actual));
 }