8009545: Graph inference: dependencies between inference variables should be set during incorporation

Tue, 12 Mar 2013 16:02:43 +0000

author
mcimadamore
date
Tue, 12 Mar 2013 16:02:43 +0000
changeset 1628
5ddecb91d843
parent 1627
6db9a3b1a93f
child 1629
f427043f8c65

8009545: Graph inference: dependencies between inference variables should be set during incorporation
Summary: Move all transitivity checks into the incorporation round
Reviewed-by: jjg

src/share/classes/com/sun/tools/javac/code/Type.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javac/comp/Infer.java file | annotate | diff | comparison | revisions
test/tools/javac/lambda/TargetType28.out file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/classes/com/sun/tools/javac/code/Type.java	Tue Mar 12 16:02:13 2013 +0000
     1.2 +++ b/src/share/classes/com/sun/tools/javac/code/Type.java	Tue Mar 12 16:02:43 2013 +0000
     1.3 @@ -1367,7 +1367,7 @@
     1.4              for (Type b : prevBounds) {
     1.5                  //check for redundancy - use strict version of isSameType on tvars
     1.6                  //(as the standard version will lead to false positives w.r.t. clones ivars)
     1.7 -                if (types.isSameType(b, bound2, true)) return;
     1.8 +                if (types.isSameType(b, bound2, true) || bound == qtype) return;
     1.9              }
    1.10              bounds.put(ib, prevBounds.prepend(bound2));
    1.11              notifyChange(EnumSet.of(ib));
     2.1 --- a/src/share/classes/com/sun/tools/javac/comp/Infer.java	Tue Mar 12 16:02:13 2013 +0000
     2.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java	Tue Mar 12 16:02:43 2013 +0000
     2.3 @@ -641,6 +641,8 @@
     2.4                      if (inferenceContext.inferenceVars().contains(b)) {
     2.5                          UndetVar uv2 = (UndetVar)inferenceContext.asFree(b);
     2.6                          //alpha <: beta
     2.7 +                        //0. set beta :> alpha
     2.8 +                        uv2.addBound(InferenceBound.LOWER, uv.qtype, infer.types);
     2.9                          //1. copy alpha's lower to beta's
    2.10                          for (Type l : uv.getBounds(InferenceBound.LOWER)) {
    2.11                              uv2.addBound(InferenceBound.LOWER, inferenceContext.asInstType(l), infer.types);
    2.12 @@ -664,6 +666,8 @@
    2.13                      if (inferenceContext.inferenceVars().contains(b)) {
    2.14                          UndetVar uv2 = (UndetVar)inferenceContext.asFree(b);
    2.15                          //alpha :> beta
    2.16 +                        //0. set beta <: alpha
    2.17 +                        uv2.addBound(InferenceBound.UPPER, uv.qtype, infer.types);
    2.18                          //1. copy alpha's upper to beta's
    2.19                          for (Type u : uv.getBounds(InferenceBound.UPPER)) {
    2.20                              uv2.addBound(InferenceBound.UPPER, inferenceContext.asInstType(u), infer.types);
    2.21 @@ -687,6 +691,8 @@
    2.22                      if (inferenceContext.inferenceVars().contains(b)) {
    2.23                          UndetVar uv2 = (UndetVar)inferenceContext.asFree(b);
    2.24                          //alpha == beta
    2.25 +                        //0. set beta == alpha
    2.26 +                        uv2.addBound(InferenceBound.EQ, uv.qtype, infer.types);
    2.27                          //1. copy all alpha's bounds to beta's
    2.28                          for (InferenceBound ib : InferenceBound.values()) {
    2.29                              for (Type b2 : uv.getBounds(ib)) {
    2.30 @@ -1228,10 +1234,6 @@
    2.31                          if (Type.containsAny(uv_i.getBounds(InferenceBound.values()), List.of(j))) {
    2.32                              //update i's deps
    2.33                              n_i.deps.add(n_j);
    2.34 -                            //update j's deps - only if i's bounds contain _exactly_ j
    2.35 -                            if (uv_i.getBounds(InferenceBound.values()).contains(j)) {
    2.36 -                                n_j.deps.add(n_i);
    2.37 -                            }
    2.38                          }
    2.39                      }
    2.40                  }
     3.1 --- a/test/tools/javac/lambda/TargetType28.out	Tue Mar 12 16:02:13 2013 +0000
     3.2 +++ b/test/tools/javac/lambda/TargetType28.out	Tue Mar 12 16:02:43 2013 +0000
     3.3 @@ -1,2 +1,2 @@
     3.4 -TargetType28.java:20:32: compiler.err.prob.found.req: (compiler.misc.incompatible.eq.upper.bounds: X, java.lang.String,X, java.lang.Object,java.lang.Number)
     3.5 +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)
     3.6  1 error

mercurial