1e41f4b71Sopenharmony_ci# ArkCompiler Subsystem Changelog 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci## cl.arkcompiler.1 Callback Function Declaration of map Provided by Sendable TypedArray Is Changed 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci**Access Level** 6e41f4b71Sopenharmony_ci 7e41f4b71Sopenharmony_ciPublic API 8e41f4b71Sopenharmony_ci 9e41f4b71Sopenharmony_ci**Reason for Change** 10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_ciThe sendable TypedArray container provides the **map** API. This API performs an operation or conversion (through the return value of **callbackFn**) on each element in a typed array and returns a new typed array that contains the elements after the processing. 12e41f4b71Sopenharmony_ci 13e41f4b71Sopenharmony_ciThe following uses Uint8Array as an example. Before the change, the **callbackFn** function declaration of the **map** API has no return value. As a result, the data after conversion is lost. 14e41f4b71Sopenharmony_ci- Declare the callback function of the **map** API as follows: **map(callbackFn: TypedArrayForEachCallback\<number, Uint8Array>): Uint8Array**. 15e41f4b71Sopenharmony_ci- **TypedArrayForEachCallback** is defined without a return value, as follows: **type TypedArrayForEachCallback\<ElementType, ArrayType> = (value: ElementType, index: number, array: ArrayType) => void**. 16e41f4b71Sopenharmony_ci 17e41f4b71Sopenharmony_ci**Change Impact** 18e41f4b71Sopenharmony_ci 19e41f4b71Sopenharmony_ciThis change is a non-compatible change. 20e41f4b71Sopenharmony_ci 21e41f4b71Sopenharmony_ci**Before Change** 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_ci- Case 1: The **callbackFn** function in the **map** API has no return value. The code can be compiled, but the implementation is different from that expected. 24e41f4b71Sopenharmony_ci- Case 2: The **callbackFn** function in the **map** API has a return value, the type of which is not number. The code can be compiled, and the implementation is the same as that expected. 25e41f4b71Sopenharmony_ci- Case 3: The **callbackFn** function in the **map** API has a return value, the type of which is number. The code can be compiled, and the implementation is the same as that expected. 26e41f4b71Sopenharmony_ci 27e41f4b71Sopenharmony_ci ``` 28e41f4b71Sopenharmony_ci let arr = [1, 2, 3, 4, 5]; 29e41f4b71Sopenharmony_ci 30e41f4b71Sopenharmony_ci // Create a Uint8Array. 31e41f4b71Sopenharmony_ci let uint8: collections.Uint8Array = new collections.Uint8Array(arr); 32e41f4b71Sopenharmony_ci 33e41f4b71Sopenharmony_ci // Case 1: The feature of map is not implemented. callbackFn has no return value, and the map API returns a new collections.Uint8Array. 34e41f4b71Sopenharmony_ci let zeroMappedArray: collections.Uint8Array = uint8.map((value: number) => {}); // The compilation is successful. 35e41f4b71Sopenharmony_ci console.info('' + zeroMappedArray); // Output: collections.Uint8Array [0, 0, 0, 0, 0] 36e41f4b71Sopenharmony_ci 37e41f4b71Sopenharmony_ci // Case 2: The feature of map is implemented. callbackFn returns an element value (in the form of a string) after map is called, and the map API returns a new collections.Uint8Array. 38e41f4b71Sopenharmony_ci let wrongTypeMapped: collections.Uint8Array = uint8.map((value: number) => value + "1"); // The compilation is successful. 39e41f4b71Sopenharmony_ci console.info('' + wrongTypeMapped); //Output: collections.Uint8Array [11, 21, 31, 41, 51] 40e41f4b71Sopenharmony_ci 41e41f4b71Sopenharmony_ci // Case 3: The feature of map is implemented. callbackFn returns an element value after map is called, and the map API returns a new collections.Uint8Array. 42e41f4b71Sopenharmony_ci let normalMapped: collections.Uint8Array = uint8.map((value: number) => value * 2); // The compilation is successful. 43e41f4b71Sopenharmony_ci console.info('' + normalMapped); // Output: collections.Uint8Array [2, 4, 6, 8, 10] 44e41f4b71Sopenharmony_ci ``` 45e41f4b71Sopenharmony_ci 46e41f4b71Sopenharmony_ci**After Change** 47e41f4b71Sopenharmony_ci 48e41f4b71Sopenharmony_ci- Case 1: The **callbackFn** function in the **map** API has no return value. The code cannot be compiled. (This change is incompatible.) 49e41f4b71Sopenharmony_ci- Case 2: The **callbackFn** function in the **map** API has a return value, the type of which is not number. The code cannot be compiled. (This change is incompatible.) 50e41f4b71Sopenharmony_ci- Case 3: The **callbackFn** function in the **map** API has a return value, the type of which is number. The code can be compiled, and the implementation is the same as that expected. (This change is compatible.) 51e41f4b71Sopenharmony_ci 52e41f4b71Sopenharmony_ci 53e41f4b71Sopenharmony_ci ``` 54e41f4b71Sopenharmony_ci let arr = [1, 2, 3, 4, 5]; 55e41f4b71Sopenharmony_ci 56e41f4b71Sopenharmony_ci // Create a Uint8Array. 57e41f4b71Sopenharmony_ci let uint8: collections.Uint8Array = new collections.Uint8Array(arr); 58e41f4b71Sopenharmony_ci 59e41f4b71Sopenharmony_ci // Case 1: The feature of map is not implemented. callbackFn has no return value, and the map API returns a new collections.Uint8Array. 60e41f4b71Sopenharmony_ci let zeroMappedArray: collections.Uint8Array = uint8.map((value: number) => {}); // An incompatible change. The compilation fails. 61e41f4b71Sopenharmony_ci 62e41f4b71Sopenharmony_ci // Case 2: The feature of map is implemented. callbackFn returns a string after map is called, and the map API returns a new collections.Uint8Array. 63e41f4b71Sopenharmony_ci let wrongTypeMapped: collections.Uint8Array = uint8.map((value: number) => value + "1"); // An incompatible change. The compilation fails. 64e41f4b71Sopenharmony_ci 65e41f4b71Sopenharmony_ci // Case 3: The feature of map is implemented. callbackFn returns an element value after map is called, and the map API returns a new collections.Uint8Array. 66e41f4b71Sopenharmony_ci let normalMapped: collections.Uint8Array = uint8.map((value: number) => value * 2); // The compilation is successful. 67e41f4b71Sopenharmony_ci console.info('' + normalMapped); // Output: collections.Uint8Array [2, 4, 6, 8, 10] 68e41f4b71Sopenharmony_ci ``` 69e41f4b71Sopenharmony_ci 70e41f4b71Sopenharmony_ci**Start API Level** 71e41f4b71Sopenharmony_ci 72e41f4b71Sopenharmony_ciAPI version 12 73e41f4b71Sopenharmony_ci 74e41f4b71Sopenharmony_ci**Change Since** 75e41f4b71Sopenharmony_ci 76e41f4b71Sopenharmony_ciOpenHarmony SDK 5.0.0.31 77e41f4b71Sopenharmony_ci 78e41f4b71Sopenharmony_ci**Key API/Component Changes** 79e41f4b71Sopenharmony_ci 80e41f4b71Sopenharmony_ci**map** API of TypedArray (including Int8Array/Uint8Array/Int16Array/Uint16Array/Int32Array/Uint32Array) in the **/interface/sdk-js/arkts/@arkts.collections.d.ets** file. 81e41f4b71Sopenharmony_ci 82e41f4b71Sopenharmony_ci**Adaptation Guide** 83e41f4b71Sopenharmony_ci 84e41f4b71Sopenharmony_ci- In the preceding case 2, you can make adaptation as follows: 85e41f4b71Sopenharmony_ci 86e41f4b71Sopenharmony_ci ``` 87e41f4b71Sopenharmony_ci let wrongTypeMapped: collections.Uint8Array = uint8.map((value: number) => parseInt(value + "1")); // Use parseInt to convert a string to a number. 88e41f4b71Sopenharmony_ci ``` 89e41f4b71Sopenharmony_ci 90e41f4b71Sopenharmony_ci- For details, see the following sample code: 91e41f4b71Sopenharmony_ci 92e41f4b71Sopenharmony_ci [ArkTS Collections - Typed Array](../../../application-dev/reference/apis-arkts/js-apis-arkts-collections.md#collectionstypedarray) 93e41f4b71Sopenharmony_ci 94e41f4b71Sopenharmony_ci## cl.arkcompiler.2 Compilation Check Enhanced for ArkTS Sendable Syntax Rules 95e41f4b71Sopenharmony_ci 96e41f4b71Sopenharmony_ci**Access Level** 97e41f4b71Sopenharmony_ci 98e41f4b71Sopenharmony_ciOthers 99e41f4b71Sopenharmony_ci 100e41f4b71Sopenharmony_ci**Reason for Change** 101e41f4b71Sopenharmony_ci 102e41f4b71Sopenharmony_ciA sendable object must comply with the [usage rules](../../..//application-dev/arkts-utils/arkts-sendable.md#sendable-usage-rules). In sendable generic class scenarios where some constraints should be made, the compiler does not check for these constraints. As a result, a sendable object using these syntaxes runs abnormally in concurrent scenarios, but no compilation error is reported. In this version update, a compile-time check is added for these constraints. You can find the code that fails to meet the sendable usage constraints earlier through compile-time errors, reducing fault locating costs at the runtime. 103e41f4b71Sopenharmony_ci 104e41f4b71Sopenharmony_ci**Change Impact** 105e41f4b71Sopenharmony_ci 106e41f4b71Sopenharmony_ciThis change is a non-compatible change. 107e41f4b71Sopenharmony_ci 108e41f4b71Sopenharmony_ci 109e41f4b71Sopenharmony_ciBefore the change: When a sendable generic class is declared as a type, the formal parameter of the type can be of a non-sendable type. In this case, no error message is displayed on the DevEco Studio editing page, and no compilation error is reported. 110e41f4b71Sopenharmony_ci 111e41f4b71Sopenharmony_ciAfter the change: When a sendable generic class is declared as a type, the formal parameter of the type cannot be of a non-sendable type. Otherwise, an error message is displayed on the DevEco Studio editing page, and a compilation error is reported. 112e41f4b71Sopenharmony_ci 113e41f4b71Sopenharmony_ciFor variables, parameters, and return values that are declared using a sendable generic class but assigned to a non-sendable object, if they are used in concurrent instance sharing scenarios, runtime exceptions occur before the change, whereas compilation errors are reported after the change. If they are used as common objects, no runtime error is reported before the change, whereas compilation errors are reported after the change. 114e41f4b71Sopenharmony_ci 115e41f4b71Sopenharmony_ci 116e41f4b71Sopenharmony_ciExample scenarios: 117e41f4b71Sopenharmony_ci 118e41f4b71Sopenharmony_ciSendable Generic Class Constraints 119e41f4b71Sopenharmony_ci 120e41f4b71Sopenharmony_ciScenario 1: When a sendable object is shared by multiple threads, a runtime exception is reported before the change, whereas a compilation error is reported after the change. 121e41f4b71Sopenharmony_ci 122e41f4b71Sopenharmony_ciBefore change: 123e41f4b71Sopenharmony_ci 124e41f4b71Sopenharmony_ci```ts 125e41f4b71Sopenharmony_ci// declaration.ets 126e41f4b71Sopenharmony_ciexport class NonSendableClass {}; 127e41f4b71Sopenharmony_ci 128e41f4b71Sopenharmony_ci// main.ets 129e41f4b71Sopenharmony_ciimport { NonSendableClass } from './declaration'; 130e41f4b71Sopenharmony_ciimport collections from '@arkts.collections'; 131e41f4b71Sopenharmony_ci 132e41f4b71Sopenharmony_ci@Sendable 133e41f4b71Sopenharmony_ciclass SendableClass { 134e41f4b71Sopenharmony_ci private arr: collections.Array<NonSendableClass> = new collections.Array(); 135e41f4b71Sopenharmony_ci constructor() { 136e41f4b71Sopenharmony_ci this.arr.push(new NonSendableClass()); // Runtime ERROR 137e41f4b71Sopenharmony_ci } 138e41f4b71Sopenharmony_ci} 139e41f4b71Sopenharmony_cilet sendableclassObject: SendableClass = new SendableClass(); 140e41f4b71Sopenharmony_ci``` 141e41f4b71Sopenharmony_ci 142e41f4b71Sopenharmony_ciAfter change: 143e41f4b71Sopenharmony_ci 144e41f4b71Sopenharmony_ci```ts 145e41f4b71Sopenharmony_ci// declaration.ets 146e41f4b71Sopenharmony_ciexport class NonSendableClass {}; 147e41f4b71Sopenharmony_ci 148e41f4b71Sopenharmony_ci// main.ets 149e41f4b71Sopenharmony_ciimport { NonSendableClass } from './declaration'; 150e41f4b71Sopenharmony_ciimport collections from '@arkts.collections'; 151e41f4b71Sopenharmony_ci 152e41f4b71Sopenharmony_ci@Sendable 153e41f4b71Sopenharmony_ciclass SendableClass { 154e41f4b71Sopenharmony_ci private arr: collections.Array<NonSendableClass> = new collections.Array(); // ArkTS compile-time error 155e41f4b71Sopenharmony_ci constructor() { 156e41f4b71Sopenharmony_ci this.arr.push(new NonSendableClass()); 157e41f4b71Sopenharmony_ci } 158e41f4b71Sopenharmony_ci} 159e41f4b71Sopenharmony_cilet sendableclassObject: SendableClass = new SendableClass(); 160e41f4b71Sopenharmony_ci``` 161e41f4b71Sopenharmony_ci 162e41f4b71Sopenharmony_ciScenario 2: When a sendable object is used as a common object, no error is reported before the change, whereas a compilation error is reported after the change. This change is incompatible. 163e41f4b71Sopenharmony_ci 164e41f4b71Sopenharmony_ciBefore change: 165e41f4b71Sopenharmony_ci 166e41f4b71Sopenharmony_ci```ts 167e41f4b71Sopenharmony_ci@Sendable 168e41f4b71Sopenharmony_ciclass SendableClassA<T> { 169e41f4b71Sopenharmony_ci one: string = '1'; 170e41f4b71Sopenharmony_ci} 171e41f4b71Sopenharmony_ciclass NoneSendableClassA<T> { 172e41f4b71Sopenharmony_ci one: string = '1'; 173e41f4b71Sopenharmony_ci} 174e41f4b71Sopenharmony_cilet sendableObjectA: SendableClassA<NoneSendableClassA<number>> = new SendableClassA(); 175e41f4b71Sopenharmony_ci``` 176e41f4b71Sopenharmony_ci 177e41f4b71Sopenharmony_ciAfter change: 178e41f4b71Sopenharmony_ci 179e41f4b71Sopenharmony_ci```ts 180e41f4b71Sopenharmony_ci@Sendable 181e41f4b71Sopenharmony_ciclass SendableClassA<T> { 182e41f4b71Sopenharmony_ci one: string = '1'; 183e41f4b71Sopenharmony_ci} 184e41f4b71Sopenharmony_ciclass NoneSendableClassA<T> { 185e41f4b71Sopenharmony_ci one: string = '1'; 186e41f4b71Sopenharmony_ci} 187e41f4b71Sopenharmony_cilet sendableObjectA: SendableClassA<NoneSendableClassA<number>> = new SendableClassA(); // ArkTS compile-time error 188e41f4b71Sopenharmony_ci``` 189e41f4b71Sopenharmony_ci 190e41f4b71Sopenharmony_ci**Start API Level** 191e41f4b71Sopenharmony_ci 192e41f4b71Sopenharmony_ciAPI version 12 193e41f4b71Sopenharmony_ci 194e41f4b71Sopenharmony_ci**Change Since** 195e41f4b71Sopenharmony_ci 196e41f4b71Sopenharmony_ciOpenHarmony SDK 5.0.0.31 197e41f4b71Sopenharmony_ci 198e41f4b71Sopenharmony_ci**Key API/Component Changes** 199e41f4b71Sopenharmony_ci 200e41f4b71Sopenharmony_ciN/A 201e41f4b71Sopenharmony_ci 202e41f4b71Sopenharmony_ci**Adaptation Guide** 203e41f4b71Sopenharmony_ci 204e41f4b71Sopenharmony_ciThe type of a sendable generic class must be sendable. 205e41f4b71Sopenharmony_ci 206e41f4b71Sopenharmony_ci## cl.arkcompiler.3 Compilation Check Enhanced for ArkTS Sendable Syntax Rules for Assigning Values 207e41f4b71Sopenharmony_ci 208e41f4b71Sopenharmony_ci**Access Level** 209e41f4b71Sopenharmony_ci 210e41f4b71Sopenharmony_ciOthers 211e41f4b71Sopenharmony_ci 212e41f4b71Sopenharmony_ci**Reason for Change** 213e41f4b71Sopenharmony_ci 214e41f4b71Sopenharmony_ciSendable value assignment must comply with the [usage rules](../../..//application-dev/arkts-utils/arkts-sendable.md#sendable-usage-rules). However, a non-sendable object can be assigned to the sendable type, and the compiler does not provide a check for this scenario. As a result, a runtime exception occurs when a non-sendable object is used as a sendable object, but no compilation error is reported. In this version update, a compile-time check is added for the constraint. You can find the code that fails to meet the sendable usage constraints earlier through compile-time errors, reducing fault locating costs at the runtime. 215e41f4b71Sopenharmony_ci 216e41f4b71Sopenharmony_ciError object: a variable, parameter, or return value that is declared using the sendable type or interface but assigned to a non-sendable object. 217e41f4b71Sopenharmony_ci 218e41f4b71Sopenharmony_ci**Change Impact** 219e41f4b71Sopenharmony_ci 220e41f4b71Sopenharmony_ciThis change is a non-compatible change. 221e41f4b71Sopenharmony_ci 222e41f4b71Sopenharmony_ciBefore the change: In some scenarios where a non-sendable object is assigned to the sendable type, no error message is displayed on the DevEco Studio editing page, and no compilation error is reported. 223e41f4b71Sopenharmony_ci 224e41f4b71Sopenharmony_ciAfter the change: In some scenarios where a non-sendable object is assigned to the sendable type, an error message is displayed on the DevEco Studio editing page, and a compilation error is reported. 225e41f4b71Sopenharmony_ci 226e41f4b71Sopenharmony_ciWhen the error object is used as a sendable object, a runtime exception is reported before the change, whereas a compilation error is reported after the change. When the error object is used as a common object, no error is reported before the change, whereas a compilation error is reported after the change. Before the change, a non-sendable object can be assigned to the sendable type in some scenarios. After the change, a non-sendable object cannot be assigned to the sendable type. 227e41f4b71Sopenharmony_ci 228e41f4b71Sopenharmony_ciAn error is reported in the following scenarios: 229e41f4b71Sopenharmony_ci 230e41f4b71Sopenharmony_ciCase 1: The error object is used as a sendable object. 231e41f4b71Sopenharmony_ci 232e41f4b71Sopenharmony_ciBefore change: 233e41f4b71Sopenharmony_ci 234e41f4b71Sopenharmony_ci```ts 235e41f4b71Sopenharmony_ci// declaration.ets 236e41f4b71Sopenharmony_ciexport class NonSendableClass {}; 237e41f4b71Sopenharmony_ci@Sendable 238e41f4b71Sopenharmony_ciexport class SendableClass {}; 239e41f4b71Sopenharmony_ci 240e41f4b71Sopenharmony_ciexport class NonSendableClassT<T> {}; 241e41f4b71Sopenharmony_ci@Sendable 242e41f4b71Sopenharmony_ciexport class SendableClassT<T> {}; 243e41f4b71Sopenharmony_ci 244e41f4b71Sopenharmony_ci// main.ets 245e41f4b71Sopenharmony_ciimport { NonSendableClass, SendableClass, NonSendableClassT, SendableClassT } from './declaration'; 246e41f4b71Sopenharmony_ciimport collections from '@arkts.collections'; 247e41f4b71Sopenharmony_ci 248e41f4b71Sopenharmony_ci@Sendable 249e41f4b71Sopenharmony_ciclass SendableData { 250e41f4b71Sopenharmony_ci propA: SendableClass = new NonSendableClass(); // Runtime ERROR 251e41f4b71Sopenharmony_ci propB: SendableClassT<number>; 252e41f4b71Sopenharmony_ci propC: SendableClass; 253e41f4b71Sopenharmony_ci propD: SendableClass; 254e41f4b71Sopenharmony_ci propE: SendableClass; 255e41f4b71Sopenharmony_ci 256e41f4b71Sopenharmony_ci constructor(sendableT: SendableClassT<number>) { 257e41f4b71Sopenharmony_ci const sendableList: SendableClass[] = [new NonSendableClass()]; 258e41f4b71Sopenharmony_ci this.propB = new NonSendableClassT<number>(); // Runtime ERROR 259e41f4b71Sopenharmony_ci this.propC = this.getSendable(); // Runtime ERROR 260e41f4b71Sopenharmony_ci this.propD = sendableList[0]; // Runtime ERROR 261e41f4b71Sopenharmony_ci this.propE = sendableT; // Runtime ERROR 262e41f4b71Sopenharmony_ci } 263e41f4b71Sopenharmony_ci 264e41f4b71Sopenharmony_ci getSendable(): SendableClass { 265e41f4b71Sopenharmony_ci return new NonSendableClass(); 266e41f4b71Sopenharmony_ci } 267e41f4b71Sopenharmony_ci} 268e41f4b71Sopenharmony_ci 269e41f4b71Sopenharmony_cinew SendableData(new NonSendableClassT<number>()); 270e41f4b71Sopenharmony_ci 271e41f4b71Sopenharmony_ciconst sendable: SendableClassT<number> = new NonSendableClassT<number>(); 272e41f4b71Sopenharmony_ciconst sendableArray: collections.Array<SendableClass> = new collections.Array<SendableClass>(); 273e41f4b71Sopenharmony_cisendableArray.push(sendable); // Runtime ERROR 274e41f4b71Sopenharmony_ci 275e41f4b71Sopenharmony_ci``` 276e41f4b71Sopenharmony_ci 277e41f4b71Sopenharmony_ciAfter change: 278e41f4b71Sopenharmony_ci 279e41f4b71Sopenharmony_ci```ts 280e41f4b71Sopenharmony_ci// declaration.ets 281e41f4b71Sopenharmony_ciexport class NonSendableClass {}; 282e41f4b71Sopenharmony_ci@Sendable 283e41f4b71Sopenharmony_ciexport class SendableClass {}; 284e41f4b71Sopenharmony_ci 285e41f4b71Sopenharmony_ciexport class NonSendableClassT<T> {}; 286e41f4b71Sopenharmony_ci@Sendable 287e41f4b71Sopenharmony_ciexport class SendableClassT<T> {}; 288e41f4b71Sopenharmony_ci 289e41f4b71Sopenharmony_ci// main.ets 290e41f4b71Sopenharmony_ciimport { NonSendableClass, SendableClass, NonSendableClassT, SendableClassT } from './declaration'; 291e41f4b71Sopenharmony_ciimport collections from '@arkts.collections'; 292e41f4b71Sopenharmony_ci 293e41f4b71Sopenharmony_ci@Sendable 294e41f4b71Sopenharmony_ciclass SendableData { 295e41f4b71Sopenharmony_ci propA: SendableClass = new NonSendableClass(); // ArkTS compile-time error 296e41f4b71Sopenharmony_ci propB: SendableClassT<number>; 297e41f4b71Sopenharmony_ci propC: SendableClass; 298e41f4b71Sopenharmony_ci propD: SendableClass; 299e41f4b71Sopenharmony_ci propE: SendableClass; 300e41f4b71Sopenharmony_ci 301e41f4b71Sopenharmony_ci constructor(sendableT: SendableClassT<number>) { 302e41f4b71Sopenharmony_ci const sendableList: SendableClass[] = [new NonSendableClass()]; // ArkTS compile-time error 303e41f4b71Sopenharmony_ci this.propB = new NonSendableClassT<number>(); // ArkTS compile-time error 304e41f4b71Sopenharmony_ci this.propC = this.getSendable(); 305e41f4b71Sopenharmony_ci this.propD = sendableList[0]; 306e41f4b71Sopenharmony_ci this.propE = sendableT; 307e41f4b71Sopenharmony_ci } 308e41f4b71Sopenharmony_ci 309e41f4b71Sopenharmony_ci getSendable(): SendableClass { 310e41f4b71Sopenharmony_ci return new NonSendableClass(); // ArkTS compile-time error 311e41f4b71Sopenharmony_ci } 312e41f4b71Sopenharmony_ci} 313e41f4b71Sopenharmony_ci 314e41f4b71Sopenharmony_cinew SendableData(new NonSendableClassT<number>()); // ArkTS compile-time error 315e41f4b71Sopenharmony_ci 316e41f4b71Sopenharmony_ciconst sendable: SendableClassT<number> = new NonSendableClassT<number>(); // ArkTS compile-time error 317e41f4b71Sopenharmony_ciconst sendableArray: collections.Array<SendableClass> = new collections.Array<SendableClass>(); 318e41f4b71Sopenharmony_cisendableArray.push(sendable); 319e41f4b71Sopenharmony_ci 320e41f4b71Sopenharmony_ci``` 321e41f4b71Sopenharmony_ci 322e41f4b71Sopenharmony_ciCase 2: The error object is used as a common object. 323e41f4b71Sopenharmony_ci 324e41f4b71Sopenharmony_ciBefore change: 325e41f4b71Sopenharmony_ci 326e41f4b71Sopenharmony_ci```ts 327e41f4b71Sopenharmony_ciclass NonSendableClass {}; 328e41f4b71Sopenharmony_ci@Sendable 329e41f4b71Sopenharmony_ciclass SendableClass {}; 330e41f4b71Sopenharmony_ci 331e41f4b71Sopenharmony_ciclass NonSendableClassT<T> {}; 332e41f4b71Sopenharmony_ci@Sendable 333e41f4b71Sopenharmony_ciclass SendableClassT<T> {}; 334e41f4b71Sopenharmony_ci 335e41f4b71Sopenharmony_cifunction getSendable(): SendableClass { 336e41f4b71Sopenharmony_ci return new NonSendableClass(); 337e41f4b71Sopenharmony_ci} 338e41f4b71Sopenharmony_ci 339e41f4b71Sopenharmony_ciconst objectA: SendableClass = getSendable(); 340e41f4b71Sopenharmony_ciconst objectB: SendableClassT<number> = new NonSendableClassT<number>(); 341e41f4b71Sopenharmony_ci 342e41f4b71Sopenharmony_ci``` 343e41f4b71Sopenharmony_ci 344e41f4b71Sopenharmony_ciAfter change: 345e41f4b71Sopenharmony_ci 346e41f4b71Sopenharmony_ci```ts 347e41f4b71Sopenharmony_ciclass NonSendableClass {}; 348e41f4b71Sopenharmony_ci@Sendable 349e41f4b71Sopenharmony_ciclass SendableClass {}; 350e41f4b71Sopenharmony_ci 351e41f4b71Sopenharmony_ciclass NonSendableClassT<T> {}; 352e41f4b71Sopenharmony_ci@Sendable 353e41f4b71Sopenharmony_ciclass SendableClassT<T> {}; 354e41f4b71Sopenharmony_ci 355e41f4b71Sopenharmony_cifunction getSendable(): SendableClass { 356e41f4b71Sopenharmony_ci return new NonSendableClass(); // ArkTS compile-time error 357e41f4b71Sopenharmony_ci} 358e41f4b71Sopenharmony_ci 359e41f4b71Sopenharmony_ciconst objectA: SendableClass = getSendable(); 360e41f4b71Sopenharmony_ciconst objectB: SendableClassT<number> = new NonSendableClassT<number>(); // ArkTS compile-time error 361e41f4b71Sopenharmony_ci 362e41f4b71Sopenharmony_ci``` 363e41f4b71Sopenharmony_ci 364e41f4b71Sopenharmony_ci**Start API Level** 365e41f4b71Sopenharmony_ci 366e41f4b71Sopenharmony_ciAPI version 12 367e41f4b71Sopenharmony_ci 368e41f4b71Sopenharmony_ci**Change Since** 369e41f4b71Sopenharmony_ci 370e41f4b71Sopenharmony_ciOpenHarmony SDK 5.0.0.31 371e41f4b71Sopenharmony_ci 372e41f4b71Sopenharmony_ci**Key API/Component Changes** 373e41f4b71Sopenharmony_ci 374e41f4b71Sopenharmony_ciN/A 375e41f4b71Sopenharmony_ci 376e41f4b71Sopenharmony_ci**Adaptation Guide** 377e41f4b71Sopenharmony_ci 378e41f4b71Sopenharmony_ciDo not assign a non-sendable object to a sendable variable, parameter, or return value. 379