diff options
| author | Joseph Battelle <bttelle@iom.io> | 2020-09-16 12:32:57 -0700 |
|---|---|---|
| committer | Joseph Battelle <bttelle@iom.io> | 2020-09-16 12:32:57 -0700 |
| commit | 3a3d415295f061a2ad530a76e0e3c100be4c026b (patch) | |
| tree | 5fda7d1e8877d585e76baace945cd970be57a3f5 /src/check_expr.cpp | |
| parent | 33003d1bc162a3ba0bdb465db5da95a4bbb1fd62 (diff) | |
Fix issue #486
Use `check_is_assignable_to_using_subtype` in
`is_polymorphic_type_assignable`.
The polymorphic procedure in #486 can now also be written without the
cast:
```odin
print_entity :: proc(e : ^$E, p : proc(^$T) = print_base) { p(e); }
```
Diffstat (limited to 'src/check_expr.cpp')
| -rw-r--r-- | src/check_expr.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp index aea72c9b3..9a48aadb7 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -852,6 +852,10 @@ bool is_polymorphic_type_assignable(CheckerContext *c, Type *poly, Type *source, return false; case Type_Pointer: if (source->kind == Type_Pointer) { + isize level = check_is_assignable_to_using_subtype(source->Pointer.elem, poly->Pointer.elem); + if (level > 0) { + return true; + } return is_polymorphic_type_assignable(c, poly->Pointer.elem, source->Pointer.elem, true, modify_type); } return false; |