8010303: Graph inference: missing incorporation step causes spurious inference error
Multiple equality constraints on inference vars are not used to generate new inference constraints Reviewed-by: jjg
This commit is contained in:
parent
710a687c15
commit
2b66afe14d
@ -1178,6 +1178,17 @@ public class Types {
|
||||
protected boolean containsTypes(List<Type> ts1, List<Type> ts2) {
|
||||
return isSameTypes(ts1, ts2, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean visitWildcardType(WildcardType t, Type s) {
|
||||
if (!s.hasTag(WILDCARD)) {
|
||||
return false;
|
||||
} else {
|
||||
WildcardType t2 = (WildcardType)s;
|
||||
return t.kind == t2.kind &&
|
||||
isSameType(t.type, t2.type, true);
|
||||
}
|
||||
}
|
||||
};
|
||||
// </editor-fold>
|
||||
|
||||
|
@ -585,11 +585,7 @@ public class Infer {
|
||||
Infer infer = inferenceContext.infer();
|
||||
for (Type b1 : uv.getBounds(InferenceBound.UPPER)) {
|
||||
for (Type b2 : uv.getBounds(InferenceBound.LOWER)) {
|
||||
if (!inferenceContext.inferenceVars().contains(b1) &&
|
||||
!inferenceContext.inferenceVars().contains(b2) &&
|
||||
infer.types.asSuper(b2, b1.tsym) != null) {
|
||||
infer.types.isSubtypeUnchecked(inferenceContext.asFree(b2), inferenceContext.asFree(b1));
|
||||
}
|
||||
infer.types.isSubtypeUnchecked(inferenceContext.asFree(b2), inferenceContext.asFree(b1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -603,11 +599,7 @@ public class Infer {
|
||||
Infer infer = inferenceContext.infer();
|
||||
for (Type b1 : uv.getBounds(InferenceBound.UPPER)) {
|
||||
for (Type b2 : uv.getBounds(InferenceBound.EQ)) {
|
||||
if (!inferenceContext.inferenceVars().contains(b1) &&
|
||||
!inferenceContext.inferenceVars().contains(b2) &&
|
||||
infer.types.asSuper(b2, b1.tsym) != null) {
|
||||
infer.types.isSubtypeUnchecked(inferenceContext.asFree(b2), inferenceContext.asFree(b1));
|
||||
}
|
||||
infer.types.isSubtypeUnchecked(inferenceContext.asFree(b2), inferenceContext.asFree(b1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -621,10 +613,22 @@ public class Infer {
|
||||
Infer infer = inferenceContext.infer();
|
||||
for (Type b1 : uv.getBounds(InferenceBound.EQ)) {
|
||||
for (Type b2 : uv.getBounds(InferenceBound.LOWER)) {
|
||||
if (!inferenceContext.inferenceVars().contains(b1) &&
|
||||
!inferenceContext.inferenceVars().contains(b2) &&
|
||||
infer.types.asSuper(b2, b1.tsym) != null) {
|
||||
infer.types.isSubtypeUnchecked(inferenceContext.asFree(b2), inferenceContext.asFree(b1));
|
||||
infer.types.isSubtypeUnchecked(inferenceContext.asFree(b2), inferenceContext.asFree(b1));
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Given a bound set containing {@code alpha == S} and {@code alpha == T}
|
||||
* perform {@code S == T} (which could lead to new bounds).
|
||||
*/
|
||||
CROSS_EQ_EQ() {
|
||||
public void apply(UndetVar uv, InferenceContext inferenceContext, Warner warn) {
|
||||
Infer infer = inferenceContext.infer();
|
||||
for (Type b1 : uv.getBounds(InferenceBound.EQ)) {
|
||||
for (Type b2 : uv.getBounds(InferenceBound.EQ)) {
|
||||
if (b1 != b2) {
|
||||
infer.types.isSameType(inferenceContext.asFree(b2), inferenceContext.asFree(b1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,2 +1,2 @@
|
||||
TargetType28.java:20:32: compiler.err.prob.found.req: (compiler.misc.incompatible.eq.upper.bounds: X, java.lang.String,R, java.lang.Object,java.lang.Number)
|
||||
TargetType28.java:20:32: compiler.err.prob.found.req: (compiler.misc.incompatible.eq.upper.bounds: X, R,java.lang.String, java.lang.Object,java.lang.Number)
|
||||
1 error
|
||||
|
50
langtools/test/tools/javac/lambda/TargetType67.java
Normal file
50
langtools/test/tools/javac/lambda/TargetType67.java
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 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.
|
||||
*
|
||||
* 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 8010303
|
||||
* @summary Graph inference: missing incorporation step causes spurious inference error
|
||||
* @compile TargetType67.java
|
||||
*/
|
||||
class TargetType67 {
|
||||
|
||||
interface Func<A, B> {
|
||||
B f(A a);
|
||||
}
|
||||
|
||||
class List<X> {
|
||||
|
||||
<M> List<M> map(Func<X, M> f) {
|
||||
return null;
|
||||
}
|
||||
|
||||
<A> List<A> apply(final List<Func<X, A>> lf) {
|
||||
return null;
|
||||
}
|
||||
|
||||
<B, C> List<C> bind(final List<B> lb, final Func<X, Func<B, C>> f) {
|
||||
return lb.apply(map(f));
|
||||
}
|
||||
}
|
||||
}
|
63
langtools/test/tools/javac/lambda/TargetType68.java
Normal file
63
langtools/test/tools/javac/lambda/TargetType68.java
Normal file
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 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.
|
||||
*
|
||||
* 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 8010303
|
||||
* @summary Graph inference: missing incorporation step causes spurious inference error
|
||||
* @compile TargetType68.java
|
||||
*/
|
||||
import java.util.*;
|
||||
|
||||
class TargetType68 {
|
||||
|
||||
//derived from FX 2.2 API
|
||||
static class XYChart<X,Y> {
|
||||
static final class Series<X,Y> {
|
||||
Series(java.lang.String name, ObservableList<XYChart.Data<X,Y>> data) { }
|
||||
}
|
||||
|
||||
static final class Data<X,Y> { }
|
||||
|
||||
ObservableList<XYChart.Series<X,Y>> getData() { return null; }
|
||||
}
|
||||
|
||||
//derived from FX 2.2 API
|
||||
interface ObservableList<X> extends List<X> {
|
||||
boolean setAll(Collection<? extends X> col);
|
||||
}
|
||||
|
||||
//derived from FX 2.2 API
|
||||
static class FXCollections {
|
||||
static <E> ObservableList<E> observableList(List<E> l) { return null; }
|
||||
}
|
||||
|
||||
private void testMethod() {
|
||||
XYChart<Number, Number> numberChart = null;
|
||||
List<XYChart.Data<Number, Number>> data_1 = new ArrayList<>();
|
||||
List<XYChart.Data<Number, Number>> data_2 = new ArrayList<>();
|
||||
numberChart.getData().setAll(
|
||||
Arrays.asList(new XYChart.Series<>("Data", FXCollections.observableList(data_1)),
|
||||
new XYChart.Series<>("Data", FXCollections.observableList(data_2))));
|
||||
}
|
||||
}
|
51
langtools/test/tools/javac/lambda/TargetType69.java
Normal file
51
langtools/test/tools/javac/lambda/TargetType69.java
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 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.
|
||||
*
|
||||
* 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 8010303
|
||||
* @summary Graph inference: missing incorporation step causes spurious inference error
|
||||
* @compile TargetType68.java
|
||||
*/
|
||||
import java.util.*;
|
||||
|
||||
class TargetType68 {
|
||||
|
||||
interface Function<X,Y> {
|
||||
Y m(X x);
|
||||
}
|
||||
|
||||
abstract class TabulationAssertion<T, U> { }
|
||||
|
||||
class GroupedMapAssertion<K, M1 extends Map<K, ?>> extends TabulationAssertion<Integer, M1> {
|
||||
GroupedMapAssertion(Function<Integer, K> classifier) { }
|
||||
}
|
||||
|
||||
|
||||
<T, M2 extends Map> void exerciseMapTabulation(Function<T, ? extends M2> collector,
|
||||
TabulationAssertion<T, M2> assertion) { }
|
||||
|
||||
void test(Function<Integer, Integer> classifier, Function<Integer, Map<Integer, List<Integer>>> coll) {
|
||||
exerciseMapTabulation(coll, new GroupedMapAssertion<>(classifier));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user