Skip to content

Commit 0ee3812

Browse files
committed
Fix: Java switch expression w/o default branch does not PE well
1 parent 53ccefa commit 0ee3812

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectRichCompareBool.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import com.oracle.graal.python.nodes.object.IsNode;
4747
import com.oracle.graal.python.nodes.truffle.PythonIntegerTypes;
4848
import com.oracle.graal.python.util.PythonUtils;
49+
import com.oracle.truffle.api.CompilerDirectives;
4950
import com.oracle.truffle.api.dsl.Bind;
5051
import com.oracle.truffle.api.dsl.Cached;
5152
import com.oracle.truffle.api.dsl.Fallback;
@@ -107,6 +108,7 @@ public static boolean compareWithFakeIdentity(RichCmpOp op, double a, double b)
107108
case Py_EQ, Py_NE -> PFloat.areIdentical(a, b) == op.isEq();
108109
case Py_GT -> a > b;
109110
case Py_GE -> a >= b;
111+
default -> throw CompilerDirectives.shouldNotReachHere();
110112
};
111113
}
112114

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/RichCmpOp.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ public final boolean compareResultToBool(int result) {
147147
case Py_NE -> result != 0;
148148
case Py_GT -> result > 0;
149149
case Py_GE -> result >= 0;
150+
default -> throw CompilerDirectives.shouldNotReachHere();
150151
};
151152
}
152153

@@ -158,6 +159,7 @@ public final boolean compare(double a, double b) {
158159
case Py_NE -> a != b;
159160
case Py_GT -> a > b;
160161
case Py_GE -> a >= b;
162+
default -> throw CompilerDirectives.shouldNotReachHere();
161163
};
162164
}
163165

@@ -169,6 +171,7 @@ public final boolean compare(long a, long b) {
169171
case Py_NE -> a != b;
170172
case Py_GT -> a > b;
171173
case Py_GE -> a >= b;
174+
default -> throw CompilerDirectives.shouldNotReachHere();
172175
};
173176
}
174177

@@ -180,6 +183,7 @@ public final boolean compare(int a, int b) {
180183
case Py_NE -> a != b;
181184
case Py_GT -> a > b;
182185
case Py_GE -> a >= b;
186+
default -> throw CompilerDirectives.shouldNotReachHere();
183187
};
184188
}
185189

@@ -191,6 +195,7 @@ public final boolean compare(byte a, byte b) {
191195
case Py_NE -> a != b;
192196
case Py_GT -> a > b;
193197
case Py_GE -> a >= b;
198+
default -> throw CompilerDirectives.shouldNotReachHere();
194199
};
195200
}
196201

@@ -209,6 +214,7 @@ public final RichCmpOp getSwapped() {
209214
case Py_NE -> Py_NE;
210215
case Py_GT -> Py_LT;
211216
case Py_GE -> Py_LE;
217+
default -> throw CompilerDirectives.shouldNotReachHere();
212218
};
213219
}
214220
}

0 commit comments

Comments
 (0)