Replies: 1 comment 1 reply
-
It checks whether a value of a particular type can be assigned to a variable of a particular type. It does not check whether that value can be casted to the contextually expected type. That's a completely different kind of check. In the type checker that functionality is provided by the following: If this is needed, will have to see whether the above mentioned |
Beta Was this translation helpful? Give feedback.
-
Currently in langserver we have this code-action
TypeCast
to suggest type cast code-fix whenever there'sincompatible types
diagnostic message on the code.For instance, below code snippet will suggest adding
<int>
into front of 1.0 resultingint x = <int>1.0;
Before Code-Action Execution:
After Code-Action Execution:
The initial implementation is a dump type-cast and does not take into account the assignability of the value. However, this might fail/ produce invalid type-casts in some instances. Thus, thought of using semantic api to resolve assignability.
There's
typeSymbol.assignableTo(typeSymbol)
api and when trying to invoke api for above code snippet it always returns false comparing IntTypeSymbol vs. FloatTypeSymbol.@pubudu91 @hasithaa What is the correct usage of
assignableTo()
method? I thought we are solving the above problem with that.Beta Was this translation helpful? Give feedback.
All reactions