提交 6cfa552a 编写于 作者: L lana

Merge

/*
* Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -224,7 +224,8 @@ public class DeferredAttr extends JCTree.Visitor {
DeferredStuckPolicy deferredStuckPolicy;
if (resultInfo.pt.hasTag(NONE) || resultInfo.pt.isErroneous()) {
deferredStuckPolicy = dummyStuckPolicy;
} else if (resultInfo.checkContext.deferredAttrContext().mode == AttrMode.SPECULATIVE) {
} else if (resultInfo.checkContext.deferredAttrContext().mode == AttrMode.SPECULATIVE ||
resultInfo.checkContext.deferredAttrContext().insideOverloadPhase()) {
deferredStuckPolicy = new OverloadStuckPolicy(resultInfo, this);
} else {
deferredStuckPolicy = new CheckStuckPolicy(resultInfo, this);
......
/*
* @test /nodynamiccopyright/
* @bug 8016081 8016178
* @bug 8016081 8016178 8069545
* @summary structural most specific and stuckness
* @compile/fail/ref=T8016177g.out -XDrawDiagnostics T8016177g.java
*/
......
T8016177g.java:35:20: compiler.err.prob.found.req: (compiler.misc.possible.loss.of.precision: double, int)
1 error
T8016177g.java:34:14: compiler.err.cant.apply.symbol: kindname.method, print, java.lang.String, Test.Person, kindname.class, Test, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inferred.do.not.conform.to.upper.bounds: Test.Person, java.lang.String,java.lang.Object))
T8016177g.java:35:20: compiler.err.cant.apply.symbol: kindname.method, abs, int, java.lang.Double, kindname.class, Test, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.infer.no.conforming.instance.exists: , R, int))
2 errors
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8068399
* @summary structural most specific and stuckness
*/
import java.util.function.Function;
import java.util.stream.IntStream;
import java.util.stream.Stream;
public class T8068399 {
public static class Spectrum {
public double[] getEnergy() {
return new double[0];
}
}
protected Spectrum spectrum;
public static class Ref<T> {
T value;
public Ref() {
}
public Ref(T value) {
this.value = value;
}
public boolean isNull() {
return value == null;
}
public T get() {
return value;
}
public void set(T value) {
this.value = value;
}
}
public static <T>T maxKey(Stream<T> stream, Function<T, Double> function) {
Ref<Double> max = new Ref<>();
Ref<T> index = new Ref<>();
stream.forEach(v -> {
Double value = function.apply(v);
if (max.isNull() || value > max.get()) {
max.set(value);
index.set(v);
}
});
return index.get();
}
public static int interpolate(int x, int x0, int x1, int y0, int y1) {
return y0 + (x - x0) * (y1 - y0) / (x1 - x0);
}
public static double interpolate(double x, double x0, double x1, double y0, double y1) {
return y0 + (x - x0) * (y1 - y0) / (x1 - x0);
}
protected int getXByFrequency(double frequency) {
return (int) Math.round(interpolate(frequency,
getMinSpectrumCoord(),
getMaxSpectrumCoord(),
0, getWidth()));
}
private int getWidth() {
return 0;
}
private double getMaxSpectrumCoord() {
return 0;
}
private double getMinSpectrumCoord() {
return 0;
}
void foo() {
int maxBpmIndex = 0;
int xcur = getXByFrequency(maxKey(IntStream.range(0, maxBpmIndex).boxed(),
i -> Math.abs(spectrum.getEnergy()[i])));
}
public static void main(String [] args) {
}
}
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8068430
* @summary structural most specific and stuckness
*/
import java.util.HashMap;
import java.util.Map;
public class T8068430 {
public static void main(String[] args) {
Map<Integer, String> mp = new HashMap<>();
mp.put(1, "a");
mp.put(2, "b");
mp.put(3, "c");
mp.put(4, "d");
System.out.println(mp.entrySet().stream().reduce(0,
(i, e) -> i + e.getKey(),
(i1, i2) -> i1 + i2));
}
}
\ No newline at end of file
/*
* @test /nodynamiccopyright/
* @bug 8071432
* @summary structural most specific and stuckness
* @compile/fail/ref=T8071432.out -XDrawDiagnostics T8071432.java
*/
import java.util.Arrays;
import java.util.Collection;
class T8071432 {
static class Point {
private double x, y;
public Point(double x, double y) {
this.x = x;
this.y = y;
}
public double getX() {
return x;
}
public double getY() {
return y;
}
public double distance(Point p) {
return Math.sqrt((this.x - p.x) * (this.x - p.x) +
(this.y - p.y) * (this.y - p.y));
}
public double distance() {
return Math.sqrt(this.x * this.x + this.y * this.y);
}
public String toString() {
return "(" + x + ":" + y + ")";
}
}
public static void main(String[] args) {
Collection<Point> c = Arrays.asList(new Point(1.0, 0.1));
System.out.println("------- 1 ---------------");
System.out.println(c.stream().reduce(0.0,
(s, p) -> s += p.distance(), (d1, d2) -> 0));
}
}
T8071432.java:47:45: compiler.err.prob.found.req: (compiler.misc.infer.no.conforming.assignment.exists: U, (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: int, java.lang.Double)))
T8071432.java:47:27: compiler.err.cant.apply.symbol: kindname.method, println, java.lang.Object, <any>, kindname.class, java.io.PrintStream, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.infer.no.conforming.assignment.exists: U, (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: int, java.lang.Double))))
2 errors
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册