Revert "Forbid implicit type conversion in GDScript"

This commit is contained in:
Rémi Verschelde 2019-03-04 12:25:59 +01:00 committed by GitHub
parent 49d82f245b
commit 425ec6914c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 110 additions and 16 deletions

View file

@ -55,7 +55,7 @@ struct GDScriptDataType {
StringName native_type;
Ref<Script> script_type;
bool is_type(const Variant &p_variant) const {
bool is_type(const Variant &p_variant, bool p_allow_implicit_conversion = false) const {
if (!has_type) return true; // Can't type check
switch (kind) {
@ -63,7 +63,11 @@ struct GDScriptDataType {
break;
case BUILTIN: {
Variant::Type var_type = p_variant.get_type();
return builtin_type == var_type;
bool valid = builtin_type == var_type;
if (!valid && p_allow_implicit_conversion) {
valid = Variant::can_convert_strict(var_type, builtin_type);
}
return valid;
} break;
case NATIVE: {
if (p_variant.get_type() == Variant::NIL) {