1# ArkCompiler Subsystem Changelog 2 3## cl.arkcompiler.1 Introduced New ArkTS Syntax Check Scenarios 4 5**Access Level** 6 7Other 8 9**Reason for Change** 10 11The ArkTS syntax check tool is designed for syntax validation in the following scenarios: full build, incremental build, initial preview, and initial hot reload. Previously, during the preview and hot reload processes, when changes were made to the code and saved, triggering real-time previews and hot reloads, no ArkTS syntax check is performed. With this change, the ArkTS syntax check is introduced for these scenarios to ensure that the check result is the same as that in other scenarios. 12 13**Change Impact** 14 15Prior to this change, in scenarios involving preview and hot reload, if code was modified incrementally and saved for another round of preview and hot reload, no ArkTS syntax check is performed. If the code introduces syntax errors according to ArkTS rules, the preview and hot reload processes will still proceed. However, with this change, introducing code that breaks ArkTS rules will interrupt the build process, thereby stopping real-time preview and hot reload. 16 17**Start API Level** 18 19API version 10 20 21**Change Since** 22 23OpenHarmony SDK 5.0.0.18 24 25**Key API/Component Changes** 26 27N/A 28 29**Adaptation Guide** 30 31No adaptation is required for applications that can be fully compiled successfully. 32 33 34## cl.arkcompiler.2 Compilation Check Standardized for ArkTS Sendable Syntax Rules 35 36**Access Level** 37 38Other 39 40**Reason for Change** 41 42In API version 11, ArkTS introduces the concepts of the @Sendable decorator and Sendable class. However, some Sendable syntax constraints are not validated during compilation. In this change, compilation checks against these ArkTS Sendable syntax rules are added, providing clearer rules for you to use the ArkTS Sendable feature for development. 43 44**Change Impact** 45 46This change is an incompatible change. In this change, the following Sendable syntax rules are added. 47 48#### Rule 1: A Sendable class can inherit only from another Sendable class. 49 50The rule scenario is optimized. When a Sendable class inherits from a variable (even if the variable is assigned a Sendable class), a compilation error is reported. 51 52```ts 53@Sendable 54class A {} // Sendable class 55 56let a = A 57 58@Sendable 59class B extends A {} 60 61@Sendable 62class C extends a {} // Compilation error: The Sendable class cannot inherit from a variable. 63``` 64 65Affected scenario: If the Sendable class inherits from a variable (even if the variable is assigned a Sendable class), the compilation fails after the change. This is an incompatible change. 66 67--- 68 69#### Rule 2: A non-Sendable class can inherit only from another non-Sendable class. 70 71If a non-Sendable class inherits from a Sendable class, a compilation error is reported. 72 73```ts 74@Sendable 75class A {} 76 77class B extends A {} // Compilation error: A non-Sendable class cannot inherit from a Sendable class. 78``` 79 80Affected scenario: If a non-Sendable class inherits from a Sendable class, the compilation fails after the change. This is an incompatible change. 81 82--- 83 84#### Rule 3: The template type of a Sendable class, collections.Array, collections.Map, and collections.Set in the generic class must be Sendable. 85 86During compilation, there is no longer any check or interception for the use of the template type by the Sendable class property, meaning that the Sendable class property can use the template type. The type of the generic class is checked during instantiation. If the template type of the Sendable class in the generic class is non-Sendable, an error is reported during compilation. 87 88```ts 89@Sendable 90class B {} // Sendable class 91 92@Sendable 93class C<T> { 94 v: T; // Allow the Sendable class property to use the template type. No compilation error is reported. 95 constructor(v: T) { 96 this.v = v; 97 } 98} 99 100let c = new C<B>(); 101 102function foo(a: C<B>) {} 103``` 104 105```ts 106class B {} // Non-sendable class 107 108@Sendable 109class C<T> {} 110 111let c = new C<B>(); // Compilation error: The template type of the Sendable class in the generic class cannot be non-Sendable. 112``` 113 114Affected scenarios: 1. If the Sendable class property uses the template type, no compilation error is reported. 2. If the template type of the Sendable class in the generic class is non-Sendable, the compilation fails. This is an incompatible change. 115 116--- 117 118#### Rule 4: Do not use other decorators (class, property, method, or parameter decorators) for the Sendable class. 119 120When the Sendable class uses other decorators, a compilation error is reported. 121 122```ts 123// a.ts 124export function foo(a: Function) { 125 a.prototype = String 126} 127 128// b.ets 129import { foo } from 'a' 130 131@foo 132@Sendable 133class A {} // Compilation error: A Sendable class cannot use other decorators. 134``` 135 136Affected scenario: If the Sendable class uses other decorators, the compilation fails after the change. This is an incompatible change. 137 138--- 139 140#### Rule 5: The Sendable type cannot be initialized using an object literal or array literal. 141 142When an object literal or array literal is used to initialize the Sendable type, a compilation error is reported. 143 144```ts 145@Sendable 146class C {} 147 148let c: C = {}; // Compilation error: Do not use object literals or array literals to initialize the Sendable type. 149``` 150 151Affected scenario: When an object literal or array literal is used to initialize a variable of the Sendable type, the compilation fails. 152 153--- 154 155#### Rule 6: Do not use as to forcibly convert the non-Sendable type to the Sendable type. 156 157When **as** is used to forcibly convert the non-Sendable type to the Sendable type, a compilation error is reported. 158 159```ts 160class A {} 161 162@Sendable 163class B {} 164 165function foo(a: A) { 166 a as B; // Compilation error: Do not use as to forcibly convert the non-Sendable type to the Sendable type. 167} 168``` 169 170Affected scenario: A non-Sendable variable after forcible conversion cannot be compiled. 171 172--- 173 174 175**Start API Level** 176 177API version 10 178 179**Change Since** 180 181OpenHarmony SDK 5.0.0.18 182 183**Key API/Component Changes** 184 185N/A 186 187**Adaptation Guide** 188 189Make adaptations in your ArkTS code involved in the preceding scenarios according to the specifications. 190