|
1 | 1 | /* |
2 | | - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 | 4 | * |
5 | 5 | * The Universal Permissive License (UPL), Version 1.0 |
@@ -78,10 +78,15 @@ public final ScriptArray setElementImpl(JSDynamicObject object, long index, Obje |
78 | 78 | } |
79 | 79 |
|
80 | 80 | private ScriptArray rewrite(JSDynamicObject object, long index, Object value) { |
81 | | - if (isSupportedContiguous(object, index)) { |
82 | | - return toContiguous(object, index, value); |
83 | | - } else if (isSupportedHoles(object, index)) { |
84 | | - return toHoles(object, index, value); |
| 81 | + if (JSDynamicObject.isJSDynamicObject(value)) { |
| 82 | + assert !isSupported(object, index); |
| 83 | + if (isSupportedContiguous(object, index)) { |
| 84 | + return toContiguous(object, index, value); |
| 85 | + } else if (isSupportedHoles(object, index)) { |
| 86 | + return toHoles(object, index, value); |
| 87 | + } else { |
| 88 | + return toSparse(object, index, value); |
| 89 | + } |
85 | 90 | } else { |
86 | 91 | return toObject(object, index, value); |
87 | 92 | } |
|
0 commit comments