-
Notifications
You must be signed in to change notification settings - Fork 351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"type 'Null' is not a subtype of type 'InterfaceElement' in type cast" during code generation #2883
Comments
It's worrying that this happens a lot, but seemingly not all the time? Looking at the stack trace, this happens when the builder is trying to resolve some classes from If you're willing to take a look at |
Same here with the next versions:
I could "solve" it cleaning the cache and the generated files using
I choose 1, then the problem seems it is solved. |
@ivanhercaz do you have other |
Yes, I have one for Riverpod ( |
@simolus3 I was able to get to this and checked out
final exportNamespace = helper.exportNamespace;
final invoke = Random().nextInt(1000);
for (final key in exportNamespace.definedNames.keys) {
print('BRANDON: $invoke|$key');
}
This printed the following in console: [WARNING] drift_dev on lib/ynab_api/_category.dart:
BRANDON: 263|Uint8List
[WARNING] drift_dev on lib/ynab_api/_category.dart:
BRANDON: 263|TypeConverter
[WARNING] drift_dev on lib/ynab_api/_category.dart:
BRANDON: 263|JsonTypeConverter2
[WARNING] drift_dev on lib/ynab_api/_category.dart:
BRANDON: 263|DriftAny
[WARNING] drift_dev on lib/ynab_api/_category.dart:
BRANDON: 263|UserDefinedSqlType
[WARNING] drift_dev on lib/ynab_api/_category.dart:
BRANDON: 263|DriftDatabase
[WARNING] drift_dev on lib/ynab_api/_category.dart:
BRANDON: 263|DriftAccessor
[WARNING] drift_dev on lib/ynab_api/_category.dart:
BRANDON: 263|Table
[WARNING] drift_dev on lib/ynab_api/_category.dart:
BRANDON: 263|View
[WARNING] drift_dev on lib/ynab_api/_category.dart:
BRANDON: 263|TableIndex
[SEVERE] drift_dev on lib/ynab_api/_category.dart: From what I can tell, the missing key is I hope this helps; that may be as far as I can take it without additional breadcrumbs 🙃 |
OK scratch that. I had a hunch that since it was exported, it just wasn't being resolved for some reason, so I swapped out the current implementation of @override
Future<LibraryElement> readDart(Uri uri) async {
final result = await context.currentSession.getResolvedLibrary(uri.path);
if (result is ResolvedLibraryResult) {
return result.element;
}
throw NotALibraryException(uri);
} With that done, I'm unable to reproduce with the steps indicated above. I'll admit that despite having done some code gen myself, I still struggle with understanding the full implications of the difference between resolving the element model versus the AST, both from a performance perspective but also from an actual functionality perspective, so I can't be confident that there's no downstream impacts of this change, but I at least wanted to point out that it seems to work as intended. |
Actually only works for first time. Second run generates same error. Problem in cache. Only cleaning of |
Describe the bug
I'm seeing the following error just about every time I run
build_runner
locally. It can be cleared up with aflutter clean
. I can try and take a peek intodrift_dev
later to see if it's something I can open a PR for, but wanted to open the issue in the meantime.Drift version
Flutter Version
FWIW, I'm using
json_serializable
andcopy_with_extension
builders as well.The text was updated successfully, but these errors were encountered: