improve support for ternary operators in assignments and method invocations

This commit is contained in:
Dave Holoway
2020-06-23 11:26:14 +01:00
parent 3073dfcd25
commit ce345965e5
3 changed files with 74 additions and 37 deletions

View File

@@ -244,7 +244,7 @@ const valid_primitive_types = {
/**
* Returns true if a value of value_type is assignable to a variable of dest_type
* @param {JavaType} dest_type
* @param {JavaType|NumberLiteral|LambdaType} value_type
* @param {JavaType|NumberLiteral|LambdaType|MultiValueType} value_type
*/
function isTypeAssignable(dest_type, value_type) {
@@ -256,6 +256,14 @@ function isTypeAssignable(dest_type, value_type) {
return isLambdaAssignable(dest_type, value_type) === true;
}
if (value_type instanceof MultiValueType) {
return value_type.types.every(t => {
if (t instanceof JavaType || t instanceof NumberLiteral || t instanceof LambdaType || t instanceof MultiValueType)
return isTypeAssignable(dest_type, t);
return false;
});
}
let is_assignable = false;
if (dest_type.typeSignature === value_type.typeSignature) {
// exact signature match