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() {
434
434
throw new UnsupportedOperationException ();
435
435
}
436
436
437
+ @ TruffleBoundary
437
438
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 ;
440
445
}
441
446
447
+ @ SuppressWarnings ("unchecked" )
442
448
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
+ }
444
454
}
445
455
446
456
public boolean add (PythonAbstractClass e ) {
You can’t perform that action at this time.
0 commit comments