Tech Tip: Strict Type Checking for 'cs' Class Assignments in 20 R10
PRODUCT: 4D | VERSION: 20 R | PLATFORM: Mac & Win
Published On: October 6, 2025
In 4D v20 R10, assigning an object instance of one 'cs' class to a variable or parameter declared with a different 'cs' class type now triggers a syntax error, such as "Impossible to cast cs.ClassA to cs.ClassB." This behavior change enhances type safety, as documented in the official 4D release notes.
Visualize this change in the Method Editor: Create two empty classes, ClassA and ClassB, then in a test method, write:
The method editor highlights the assignment $b := $a with an error, and the compiler displays the error "Impossible to cast cs.ClassA to cs.ClassB.".
As a solution, redesign with inheritance by making one class extend the other using the keyword Class extends and use upcasting.
Visualize this change in the Method Editor: Create two empty classes, ClassA and ClassB, then in a test method, write:
var $a : cs.ClassA var $b : cs.ClassB $a := cs.ClassA.new() $b:=$a |
The method editor highlights the assignment $b := $a with an error, and the compiler displays the error "Impossible to cast cs.ClassA to cs.ClassB.".
As a solution, redesign with inheritance by making one class extend the other using the keyword Class extends and use upcasting.