test/tools/javac/lambda/8071432/T8071432.java

Thu, 12 Feb 2015 10:16:19 +0530

author
vromero
date
Thu, 12 Feb 2015 10:16:19 +0530
changeset 2730
a513711d6171
permissions
-rw-r--r--

8069545: javac shouldn't check nested stuck lambdas during overload resolution
Summary: Nested lambdas should not be considered while overload resolution is in progress
Reviewed-by: mcimadamore
Contributed-by: vicente.romero@oracle.com, srikanth.adayapalam@oracle.com

     1 /*
     2  * @test /nodynamiccopyright/
     3  * @bug 8071432
     4  * @summary structural most specific and stuckness
     5  * @compile/fail/ref=T8071432.out -XDrawDiagnostics T8071432.java
     6  */
     8 import java.util.Arrays;
     9 import java.util.Collection;
    11 class T8071432 {
    13     static class Point {
    15         private double x, y;
    17         public Point(double x, double y) {
    18             this.x = x;
    19             this.y = y;
    20         }
    22         public double getX() {
    23             return x;
    24         }
    26         public double getY() {
    27             return y;
    28         }
    30         public double distance(Point p) {
    31             return Math.sqrt((this.x - p.x) * (this.x - p.x) +
    32                              (this.y - p.y) * (this.y - p.y));
    33         }
    35         public double distance() {
    36             return Math.sqrt(this.x * this.x + this.y * this.y);
    37         }
    39         public String toString() {
    40             return "(" + x + ":" + y + ")";
    41         }
    42     }
    44     public static void main(String[] args) {
    45         Collection<Point> c = Arrays.asList(new Point(1.0, 0.1));
    46         System.out.println("------- 1 ---------------");
    47         System.out.println(c.stream().reduce(0.0,
    48                                             (s, p) -> s += p.distance(), (d1, d2) -> 0));
    49     }
    50 }

mercurial