test/tools/javac/lambda/typeInference/InferenceTest2b.java

Print this page




  47         test.m2((a, b) -> {return a;});
  48         test.m3((a, b) -> a);
  49     }
  50 
  51     interface SAM6<T> {
  52         T m6(T a, T b);
  53     }
  54 
  55     void m1(SAM6<? super List<?>> s) {
  56         System.out.println("m1()");
  57         Stack<String> a = new Stack<String>();
  58         ArrayList<String> b = new ArrayList<String>();
  59         assertTrue(s.m6(a, b) == a);
  60 
  61         Vector<?> c = null;
  62         assertTrue(s.m6(c, b) == c);
  63     }
  64 
  65     void m2(SAM6<? super Integer> s) {
  66         System.out.println("m2()");
  67         assertTrue(s.m6(1, 2) == 1);
  68     }
  69 
  70     void m3(SAM6<? super Calendar> s) {
  71         System.out.println("m3()");
  72         Calendar gc = Calendar.getInstance();
  73         GregorianCalendar gc2 = new GregorianCalendar();
  74         assertTrue(s.m6(gc, gc2) == gc);
  75     }
  76 }


  47         test.m2((a, b) -> {return a;});
  48         test.m3((a, b) -> a);
  49     }
  50 
  51     interface SAM6<T> {
  52         T m6(T a, T b);
  53     }
  54 
  55     void m1(SAM6<? super List<?>> s) {
  56         System.out.println("m1()");
  57         Stack<String> a = new Stack<String>();
  58         ArrayList<String> b = new ArrayList<String>();
  59         assertTrue(s.m6(a, b) == a);
  60 
  61         Vector<?> c = null;
  62         assertTrue(s.m6(c, b) == c);
  63     }
  64 
  65     void m2(SAM6<? super Integer> s) {
  66         System.out.println("m2()");
  67         assertTrue(s.m6(1, 2).equals(Integer.valueOf(1)));
  68     }
  69 
  70     void m3(SAM6<? super Calendar> s) {
  71         System.out.println("m3()");
  72         Calendar gc = Calendar.getInstance();
  73         GregorianCalendar gc2 = new GregorianCalendar();
  74         assertTrue(s.m6(gc, gc2) == gc);
  75     }
  76 }