Skip to content

Commit

Permalink
Initial push
Browse files Browse the repository at this point in the history
  • Loading branch information
mcimadamore committed Dec 12, 2024
1 parent 4000e92 commit d008508
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 30 deletions.
40 changes: 12 additions & 28 deletions src/jdk.compiler/share/classes/com/sun/tools/javac/code/Type.java
Original file line number Diff line number Diff line change
Expand Up @@ -2004,11 +2004,11 @@ public UndetVar(TypeVar origin, UndetVarListener listener, Types types) {
bounds.put(InferenceBound.EQ, List.nil());
for (Type t : declaredBounds.reverse()) {
//add bound works in reverse order
addBound(InferenceBound.UPPER, t, types, true);
addBound(InferenceBound.UPPER, t, types);
}
if (origin.isCaptured() && !origin.lower.hasTag(BOT)) {
//add lower bound if needed
addBound(InferenceBound.LOWER, origin.lower, types, true);
addBound(InferenceBound.LOWER, origin.lower, types);
}
}

Expand Down Expand Up @@ -2070,7 +2070,7 @@ public void dupTo(UndetVar uv2, Types types) {
for (InferenceBound ib : InferenceBound.values()) {
uv2.bounds.put(ib, List.nil());
for (Type t : getBounds(ib)) {
uv2.addBound(ib, t, types, true);
uv2.addBound(ib, t, types);
}
}
uv2.inst = inst;
Expand Down Expand Up @@ -2130,31 +2130,15 @@ public void setBounds(InferenceBound ib, List<Type> newBounds) {

/** add a bound of a given kind - this might trigger listener notification */
public final void addBound(InferenceBound ib, Type bound, Types types) {
addBound(ib, bound, types, false);
}

@SuppressWarnings("fallthrough")
private void addBound(InferenceBound ib, Type bound, Types types, boolean update) {
if (kind == Kind.CAPTURED && !update) {
//Captured inference variables bounds must not be updated during incorporation,
//except when some inference variable (beta) has been instantiated in the
//right-hand-side of a 'C<alpha> = capture(C<? extends/super beta>) constraint.
if (bound.hasTag(UNDETVAR) && !((UndetVar)bound).isCaptured()) {
//If the new incoming bound is itself a (regular) inference variable,
//then we are allowed to propagate this inference variable bounds to it.
((UndetVar)bound).addBound(ib.complement(), this, types, false);
}
} else {
Type bound2 = bound.map(toTypeVarMap).baseType();
List<Type> prevBounds = bounds.get(ib);
if (bound == qtype) return;
for (Type b : prevBounds) {
//check for redundancy - do not add same bound twice
if (types.isSameType(b, bound2)) return;
}
bounds.put(ib, prevBounds.prepend(bound2));
notifyBoundChange(ib, bound2, false);
Type bound2 = bound.map(toTypeVarMap).baseType();
List<Type> prevBounds = bounds.get(ib);
if (bound == qtype) return;
for (Type b : prevBounds) {
//check for redundancy - do not add same bound twice
if (types.isSameType(b, bound2)) return;
}
bounds.put(ib, prevBounds.prepend(bound2));
notifyBoundChange(ib, bound2, false);
}
//where
TypeMapping<Void> toTypeVarMap = new StructuralTypeMapping<Void>() {
Expand Down Expand Up @@ -2191,7 +2175,7 @@ public void substBounds(List<Type> from, List<Type> to, Types types) {
bounds.put(ib, newBounds.toList());
//step 3 - for each dependency, add new replaced bound
for (Type dep : deps) {
addBound(ib, types.subst(dep, from, to), types, true);
addBound(ib, types.subst(dep, from, to), types);
}
}
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1104,7 +1104,6 @@ public void varInstantiated(UndetVar uv) {

@Override
public void varBoundChanged(UndetVar uv, InferenceBound ib, Type bound, boolean update) {
if (uv.isCaptured()) return;
uv.incorporationActions.addAll(getIncorporationActions(uv, ib, bound, update));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
CrashDueToUnreportedError.java:14:43: compiler.err.prob.found.req: (compiler.misc.infer.no.conforming.assignment.exists: E,compiler.misc.type.captureof: 1, ? extends CrashDueToUnreportedError.Entity<Root>,Root, (compiler.misc.inconvertible.types: java.util.List<compiler.misc.type.captureof: 2, ? extends CrashDueToUnreportedError.Entity<Root>>, java.util.List<? extends CrashDueToUnreportedError.Entity<java.lang.Object>>))
CrashDueToUnreportedError.java:14:20: compiler.err.cant.apply.symbol: kindname.constructor, Builder, CrashDueToUnreportedError.Person,java.lang.String, CrashDueToUnreportedError.Person, kindname.class, CrashDueToUnreportedError.Builder, (compiler.misc.arg.length.mismatch)
1 error

0 comments on commit d008508

Please sign in to comment.