Error: Cannot assign {source} to ‘{name}’ declared as {target}
A #Dim‘d variable, property or formal argument declared as an object class is given a
value of neither that class nor a subclass of it. The null oref, "", fits any class. IRIS
compiles the assignment all the same. The code that trusts the declaration fails when it
uses the value as that class, here with <METHOD DOES NOT EXIST>. Pass or assign an
instance of the declared class, or change the declared class to the value’s.
IRIS compiles the example, and do ##class(Demo.AssignIncompatible).Call() raises <METHOD DOES NOT EXIST> when it runs.
Class Demo.AssignIncompatible
{
ClassMethod Fill(list As %ListOfDataTypes) As %Status
{
Quit list.Insert("one")
}
ClassMethod Call() As %Status
{
Set array = ##class(%ArrayOfDataTypes).%New()
Quit ..Fill(array) //! A9180
}
}