You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Dart: several type positions create no reference (extension on type, field types, generic arguments in expressions and top-level initializers) #2327
In Dart, callers / impact for a class only see parameter types, return types (including their generic arguments), and instantiations. A type named in these positions is never recorded as a reference:
Position
Example
Referenced?
parameter type
int score(Report r)
yes
return type generic argument
Future<Report?> load()
yes
extension target
extension ReportX on Report {}
no
class field type
final Report report;
no
generic argument in a top-level initializer
final p = Family<Report?, String>();
no
generic argument in an expression
Future<Report?>.value(null);
no
In Flutter apps these are the common shapes for model extensions, generated API models (fields of other models), and Riverpod providers (FutureProvider.family<Report?, String>(…)), so model-to-UI impact is substantially incomplete. In one app, these positions account for most of the missed usages of shared API types. (Distinct from #1784, which is about extension type members.)
Reproduction
Run with CODEGRAPH=/path/to/codegraph bash repro.sh (creates and deletes a temporary project):
Thanks @mg-mg-mg for the position-by-position table and the repro script. The fix was written straight against them.
Fixed on main in #2360. Dart type references used to come only from function and method signatures. They now also come from:
the type an extension is on (extension ReportX on Report)
field types (final Report report;), attributed to the class, since Dart fields have no symbols of their own, and enum fields
top-level variable types, and generic arguments in top-level final/const initializers (final reportProvider = Family<Report?, String>();)
everything a function body names as a type: local variable types, generic arguments in expressions (Future<Report?>.value(null)), casts, is checks and on X catch
Constructor class names, import prefixes, built-in types and a class's references to itself are skipped. On your script, callers Report now lists ReportX, Holder, reportProvider and run alongside load and score. On bloc, riverpod and flutter/samples this added about 1,350, 4,870 and 670 type references and removed none.
Still not covered: generic arguments in extends Bloc<E, S>, and calls inside top-level and static initializers, such as the bodies of Riverpod providers.
This ships in the next release. Re-index after upgrading (codegraph index) to pick it up. You're credited in the changelog.
Activity
Phase 4: resolution and extraction accuracy
fix(dart): link getter reads, enum-extension members and more type po…
colbymchenry commentedon Oct 5, 2026
Thanks @mg-mg-mg for the position-by-position table and the repro script. The fix was written straight against them.
Fixed on
mainin #2360. Dart type references used to come only from function and method signatures. They now also come from:on(extension ReportX on Report)final Report report;), attributed to the class, since Dart fields have no symbols of their own, and enum fieldsfinal/constinitializers (final reportProvider = Family<Report?, String>();)Future<Report?>.value(null)), casts,ischecks andon X catchConstructor class names, import prefixes, built-in types and a class's references to itself are skipped. On your script,
callers Reportnow listsReportX,Holder,reportProviderandrunalongsideloadandscore. On bloc, riverpod and flutter/samples this added about 1,350, 4,870 and 670 type references and removed none.Still not covered: generic arguments in
extends Bloc<E, S>, and calls inside top-level andstaticinitializers, such as the bodies of Riverpod providers.This ships in the next release. Re-index after upgrading (
codegraph index) to pick it up. You're credited in the changelog.