639 Infer infer = inferenceContext.infer(); |
639 Infer infer = inferenceContext.infer(); |
640 for (Type b : uv.getBounds(InferenceBound.UPPER)) { |
640 for (Type b : uv.getBounds(InferenceBound.UPPER)) { |
641 if (inferenceContext.inferenceVars().contains(b)) { |
641 if (inferenceContext.inferenceVars().contains(b)) { |
642 UndetVar uv2 = (UndetVar)inferenceContext.asFree(b); |
642 UndetVar uv2 = (UndetVar)inferenceContext.asFree(b); |
643 //alpha <: beta |
643 //alpha <: beta |
|
644 //0. set beta :> alpha |
|
645 uv2.addBound(InferenceBound.LOWER, uv.qtype, infer.types); |
644 //1. copy alpha's lower to beta's |
646 //1. copy alpha's lower to beta's |
645 for (Type l : uv.getBounds(InferenceBound.LOWER)) { |
647 for (Type l : uv.getBounds(InferenceBound.LOWER)) { |
646 uv2.addBound(InferenceBound.LOWER, inferenceContext.asInstType(l), infer.types); |
648 uv2.addBound(InferenceBound.LOWER, inferenceContext.asInstType(l), infer.types); |
647 } |
649 } |
648 //2. copy beta's upper to alpha's |
650 //2. copy beta's upper to alpha's |
662 Infer infer = inferenceContext.infer(); |
664 Infer infer = inferenceContext.infer(); |
663 for (Type b : uv.getBounds(InferenceBound.LOWER)) { |
665 for (Type b : uv.getBounds(InferenceBound.LOWER)) { |
664 if (inferenceContext.inferenceVars().contains(b)) { |
666 if (inferenceContext.inferenceVars().contains(b)) { |
665 UndetVar uv2 = (UndetVar)inferenceContext.asFree(b); |
667 UndetVar uv2 = (UndetVar)inferenceContext.asFree(b); |
666 //alpha :> beta |
668 //alpha :> beta |
|
669 //0. set beta <: alpha |
|
670 uv2.addBound(InferenceBound.UPPER, uv.qtype, infer.types); |
667 //1. copy alpha's upper to beta's |
671 //1. copy alpha's upper to beta's |
668 for (Type u : uv.getBounds(InferenceBound.UPPER)) { |
672 for (Type u : uv.getBounds(InferenceBound.UPPER)) { |
669 uv2.addBound(InferenceBound.UPPER, inferenceContext.asInstType(u), infer.types); |
673 uv2.addBound(InferenceBound.UPPER, inferenceContext.asInstType(u), infer.types); |
670 } |
674 } |
671 //2. copy beta's lower to alpha's |
675 //2. copy beta's lower to alpha's |
685 Infer infer = inferenceContext.infer(); |
689 Infer infer = inferenceContext.infer(); |
686 for (Type b : uv.getBounds(InferenceBound.EQ)) { |
690 for (Type b : uv.getBounds(InferenceBound.EQ)) { |
687 if (inferenceContext.inferenceVars().contains(b)) { |
691 if (inferenceContext.inferenceVars().contains(b)) { |
688 UndetVar uv2 = (UndetVar)inferenceContext.asFree(b); |
692 UndetVar uv2 = (UndetVar)inferenceContext.asFree(b); |
689 //alpha == beta |
693 //alpha == beta |
|
694 //0. set beta == alpha |
|
695 uv2.addBound(InferenceBound.EQ, uv.qtype, infer.types); |
690 //1. copy all alpha's bounds to beta's |
696 //1. copy all alpha's bounds to beta's |
691 for (InferenceBound ib : InferenceBound.values()) { |
697 for (InferenceBound ib : InferenceBound.values()) { |
692 for (Type b2 : uv.getBounds(ib)) { |
698 for (Type b2 : uv.getBounds(ib)) { |
693 if (b2 != uv2) { |
699 if (b2 != uv2) { |
694 uv2.addBound(ib, inferenceContext.asInstType(b2), infer.types); |
700 uv2.addBound(ib, inferenceContext.asInstType(b2), infer.types); |
1226 Type j = n_j.data.first(); |
1232 Type j = n_j.data.first(); |
1227 UndetVar uv_i = (UndetVar)inferenceContext.asFree(i); |
1233 UndetVar uv_i = (UndetVar)inferenceContext.asFree(i); |
1228 if (Type.containsAny(uv_i.getBounds(InferenceBound.values()), List.of(j))) { |
1234 if (Type.containsAny(uv_i.getBounds(InferenceBound.values()), List.of(j))) { |
1229 //update i's deps |
1235 //update i's deps |
1230 n_i.deps.add(n_j); |
1236 n_i.deps.add(n_j); |
1231 //update j's deps - only if i's bounds contain _exactly_ j |
|
1232 if (uv_i.getBounds(InferenceBound.values()).contains(j)) { |
|
1233 n_j.deps.add(n_i); |
|
1234 } |
|
1235 } |
1237 } |
1236 } |
1238 } |
1237 } |
1239 } |
1238 ArrayList<Node> acyclicNodes = new ArrayList<Node>(); |
1240 ArrayList<Node> acyclicNodes = new ArrayList<Node>(); |
1239 for (List<? extends Node> conSubGraph : GraphUtils.tarjan(nodes)) { |
1241 for (List<? extends Node> conSubGraph : GraphUtils.tarjan(nodes)) { |