google / google/reflectable.dart

Change generated code to use explicit types

Open
#187 3 comments 2 reactions 0 assignees View on GitHub
enhancement
Dominant language
Dart
Stars
386
Forks
67
PR merge metrics
No merged PRs in 30d

Description

Reflectable currently generates code that uses the parameter type `dynamic` in a number of generated function literals, even though they are stored in the reflectable "database" and will be used in a type specific manner: A function literal that enables reflective invocation of `foo` on an instance of `Foo` may have the form `(o) => o.foo`, but it could be `(Foo o) => o.foo`.

Using explicit types will be much more friendly to static analysis, and in particular to tree-shaking, because it is then known at compile-time that this function literal body won't access any other members named `foo` than the one in `Foo`, which may allow some other members named `foo` to be eliminated from the compiled program.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.