|
140 | 140 | import com.oracle.graal.python.nodes.classes.IsSubtypeNode;
|
141 | 141 | import com.oracle.graal.python.nodes.control.GetIteratorNode;
|
142 | 142 | import com.oracle.graal.python.nodes.control.GetNextNode;
|
| 143 | +import com.oracle.graal.python.nodes.datamodel.IsCallableNode; |
143 | 144 | import com.oracle.graal.python.nodes.datamodel.IsIndexNode;
|
144 | 145 | import com.oracle.graal.python.nodes.datamodel.IsSequenceNode;
|
145 | 146 | import com.oracle.graal.python.nodes.expression.CastToListNode;
|
@@ -2378,13 +2379,23 @@ public Object generator(Object args, Object kwargs) {
|
2378 | 2379 | @GenerateNodeFactory
|
2379 | 2380 | public abstract static class MethodTypeNode extends PythonTernaryBuiltinNode {
|
2380 | 2381 | @Specialization
|
2381 |
| - Object method(LazyPythonClass cls, Object self, PFunction func) { |
| 2382 | + Object method(LazyPythonClass cls, PFunction func, Object self) { |
2382 | 2383 | return factory().createMethod(cls, self, func);
|
2383 | 2384 | }
|
2384 | 2385 |
|
2385 |
| - @Specialization(guards = "isPythonBuiltinClass(cls)") |
2386 |
| - Object methodGeneric(@SuppressWarnings("unused") LazyPythonClass cls, Object self, PBuiltinFunction func) { |
2387 |
| - return factory().createBuiltinMethod(self, func); |
| 2386 | + @Specialization |
| 2387 | + Object methodBuiltin(@SuppressWarnings("unused") LazyPythonClass cls, PBuiltinFunction func, Object self) { |
| 2388 | + return factory().createMethod(self, func); |
| 2389 | + } |
| 2390 | + |
| 2391 | + @Specialization |
| 2392 | + Object methodGeneric(@SuppressWarnings("unused") LazyPythonClass cls, Object func, Object self, |
| 2393 | + @Cached("create()") IsCallableNode isCallable) { |
| 2394 | + if (isCallable.execute(func)) { |
| 2395 | + return factory().createMethod(self, func); |
| 2396 | + } else { |
| 2397 | + throw raise(TypeError, "first argument must be callable"); |
| 2398 | + } |
2388 | 2399 | }
|
2389 | 2400 | }
|
2390 | 2401 |
|
|
0 commit comments