Skip to content

Commit ae9263b

Browse files
committed
[GR-13642] Add simple check for instantiable types when we define a Python type
1 parent cc49693 commit ae9263b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

graalpython/com.oracle.graal.python.tck/src/com/oracle/graal/python/tck/PythonProvider.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
import static org.graalvm.polyglot.tck.TypeDescriptor.NUMBER;
5151
import static org.graalvm.polyglot.tck.TypeDescriptor.OBJECT;
5252
import static org.graalvm.polyglot.tck.TypeDescriptor.STRING;
53+
import static org.graalvm.polyglot.tck.TypeDescriptor.INSTANTIABLE;
5354
import static org.graalvm.polyglot.tck.TypeDescriptor.array;
5455
import static org.graalvm.polyglot.tck.TypeDescriptor.executable;
5556
import static org.graalvm.polyglot.tck.TypeDescriptor.intersection;
@@ -81,6 +82,9 @@ public class PythonProvider implements LanguageProvider {
8182
private static final TypeDescriptor NUMBER_OBJECT = TypeDescriptor.union(NUMBER, BOOLEAN, OBJECT, array(ANY));
8283
private static final TypeDescriptor PSEQUENCE_OBJECT = TypeDescriptor.union(array(ANY), STRING);
8384

85+
// Python types are just objects
86+
private static final TypeDescriptor PYTHON_TYPE = TypeDescriptor.union(OBJECT, INSTANTIABLE);
87+
8488
public String getId() {
8589
return ID;
8690
}
@@ -268,7 +272,7 @@ public Collection<? extends Snippet> createStatements(Context context) {
268272
addStatementSnippet(context, snippets, "class", "class Custom0:\n" +
269273
" def __init__(self, val):\n" +
270274
" self.val = val\n" +
271-
"Custom0", OBJECT, ANY);
275+
"Custom0", PYTHON_TYPE, ANY);
272276
addStatementSnippet(context, snippets, "class", "class Custom1:\n" +
273277
" def __call__(self, val):\n" +
274278
" return val\n" +

0 commit comments

Comments
 (0)