File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed
graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -434,13 +434,23 @@ public Iterator<PythonAbstractClass> iterator() {
434434 throw new UnsupportedOperationException ();
435435 }
436436
437+ @ TruffleBoundary
437438 public Object [] toArray () {
438- CompilerDirectives .transferToInterpreterAndInvalidate ();
439- throw new UnsupportedOperationException ();
439+ Object [] result = new Object [size ()];
440+ Iterator <Object > keys = HashingStorageLibrary .getUncached ().keys (dict .getDictStorage ());
441+ for (int i = 0 ; i < result .length ; i ++) {
442+ result [i ] = keys .next ();
443+ }
444+ return result ;
440445 }
441446
447+ @ SuppressWarnings ("unchecked" )
442448 public <T > T [] toArray (T [] a ) {
443- throw new UnsupportedOperationException ();
449+ if (a .getClass () == Object [].class ) {
450+ return (T []) toArray ();
451+ } else {
452+ throw new UnsupportedOperationException ();
453+ }
444454 }
445455
446456 public boolean add (PythonAbstractClass e ) {
You can’t perform that action at this time.
0 commit comments