(Warning) Breaking changes:
- Class hints have been completely removed in this update because they were not an elegant solution and were made much less useful by the type changes in this update. As well as increasing parsing complexity a lot for a feature designed for a fairly niche scenario.
- The user pattern for non-typed instances was changed to instance. This was necessary to fix a bug with typed expressions not converting. Additionally concrete types are no longer required to be in proper case (although this is still good practice). Keep in mind it may not immediately error since class instance now matches as instance of type 'class'.
Improvements
- Concrete types rework.
TypedInstanceWrapper is no longer a thing. Instances now exist as a direct subclass of
ClassInstance.
- This will improve performance for typed function arguments as it no longer needs to wrap and unwrap through converters. It should generally be on par with non-typed class arguments.
- As a result of this change, the
[un]typed %classinstance% expression has been removed as it no longer serves a purpose.
- An instance's type can now be inferred from the input expressions return type allowing for more accurate parsing if type hints are enabled or the input naturally reports typed class information. This should also make call chains much more reliable.
- Method arguments can now be marked optional by adding a
? to the end of the argument name. For example in
public example(arg1?: int), 'arg1' will be not be set if not specified by the caller.
- Static / non-static methods with the same signature can now co-exist on the same class.
- Static constant fields are now re-evaluated each time the script reloads.
Changes/Bugfixes
- Default value parsing for methods and fields is now delayed until the pre-load stage. This should allow you to reliably reference other classes/functions as default values.
- Significantly cleaned up field & serialization code. Fields no longer have their own signature data, instead it always refers to the class structure. If that field no longer exists on the class it isn't accessible on instances through normal means.
- Optimized method call caching. If a method was already figured out at parse-time it is not re-validated at runtime. Runtime re-validation now only occurs when the class of the given instance is different from the last cached method.
- Changed the
new instance section logic to support proper section claiming which allows method chaining on newly created instances, useful for builder-like classes. This also applies to any section-expression parsing throughout the addon.
C#:
set {_item} to new ItemBuilder::build():
item: diamond
name: "test"