testdata for IDEA-147511
authorAnna Kozlova <anna.kozlova@jetbrains.com>
Fri, 6 Nov 2015 12:43:17 +0000 (13:43 +0100)
committerAnna Kozlova <anna.kozlova@jetbrains.com>
Fri, 6 Nov 2015 15:21:29 +0000 (16:21 +0100)
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IDEA147511.java [new file with mode: 0644]
java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java

diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IDEA147511.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IDEA147511.java
new file mode 100644 (file)
index 0000000..a5f2025
--- /dev/null
@@ -0,0 +1,47 @@
+
+import java.util.Comparator;
+import java.util.Optional;
+import java.util.function.BinaryOperator;
+import java.util.function.Consumer;
+import java.util.stream.Stream;
+
+class Bug {
+
+  public static void main(String[] args) {
+    Stream<String> tokenStream = Stream.of("hello", "world");
+
+    Comparator<String> order = Comparator.naturalOrder();
+    Min<String> min = tokenStream.collect(
+      () -> new Min<>(order),
+      Min::accept,
+      Min::combine);
+
+    System.out.printf("Min = %s%n",
+                      min.asOptional().orElse(null));
+  }
+
+  static class Min<T> implements Consumer<T> {
+
+    private final BinaryOperator<T> minOf;
+    private T min;
+
+    public Min(Comparator<? super T> order) {
+      this.minOf = BinaryOperator.minBy(order);
+    }
+
+    @Override
+    public void accept(T t) {
+      this.min = min != null ? minOf.apply(min, t) : t;
+    }
+
+    public void combine(Min<T> other) {
+      if (other.min != null) {
+        accept(other.min);
+      }
+    }
+
+    public Optional<T> asOptional() {
+      return Optional.ofNullable(min);
+    }
+  }
+}
index b24d597f2c28fe608516e2abf9cf7b5f0847b3cd..26d02b495ac3824b243bc633ae9e050e3541f737 100644 (file)
@@ -446,6 +446,10 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
     doTest();
   }
 
+  public void testIDEA147511() throws Exception {
+    doTest();
+  }
+
   private void doTest() {
     doTest(false);
   }