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
I know the title mentions json_serializable, but the errors printed (below) mention to file an issue here and I haven't had the time to test whether it's this package or another down the line causing the issue. I also can't inspect the code generated by json_serializable as it fails to produce any output but I can copy this issue to json_serializable if it turns out the problem lies there.
Anyway -- the issue appears whenever there is a constructor parameter with the name override (the field mentioned in the "trying to get location information on" and "Could not resolve annotation for" messages is the first field in the constructor, however after experimentation it is clearly the override field that is the culprit).
@immutable@freezedclassTestClasswith_$TestClass {
constTestClass._();
constfactoryTestClass({
requiredfinalint? id, // <-- errors will mention this line...requiredfinalbool? override, // <-- but removing this causes the code to be generated successfully.
}) =_TestClass;
factoryTestClass.fromJson(finalMap<String, dynamic> json) =>_$TestClassFromJson(json);
}
Stacktrace/Error Log
[INFO] ------------------------------------------------------------------------
[INFO] Starting Build
[INFO] Updating asset graph completed, took 0ms
[WARNING] json_serializable on [[FILEPATH REDACTED]]:
An unexpected error was thrown trying to get location information on `bool? override` (ConstFieldElementImpl).
Please file an issue at https://github.com/dart-lang/source_gen/issues/new
Include the contents of this warning and the stack trace along with
the version of `package:source_gen`, `package:analyzer` from `pubspec.lock`.
RangeError: Index: 0, Size: 0
[SEVERE] json_serializable on [[FILEPATH REDACTED]]:
Could not resolve annotation for `bool? override`.
[INFO] Running build completed, took 147ms
[INFO] Caching finalized dependency graph completed, took 44ms
[SEVERE] Failed after 193ms
[INFO] ------------------------------------------------------------------------
The @override in each of these is actually pointing to the local variable and not the constant from dart:core. This is why you see the error on the int? id also - it is the first place the @override annotation appears.
To fix this freezed should import dart:core with a prefix, and use that prefix in the @override annotations. Or it should just give an error saying that you can name a field @override.
I am closing the issue here since I can't transfer it to another repo, but please re-open the issue on the freezed repo.
Oh actually I just realized since this is a part file, freezed can't generate its own imports, so likely the issue would be closed as not feasible to fix. But it is worth still filing an issue over there to start a discussion.
I think freezed should give an explicit error here.
I know the title mentions
json_serializable
, but the errors printed (below) mention to file an issue here and I haven't had the time to test whether it's this package or another down the line causing the issue. I also can't inspect the code generated byjson_serializable
as it fails to produce any output but I can copy this issue tojson_serializable
if it turns out the problem lies there.Anyway -- the issue appears whenever there is a constructor parameter with the name
override
(the field mentioned in the "trying to get location information on" and "Could not resolve annotation for" messages is the first field in the constructor, however after experimentation it is clearly theoverride
field that is the culprit).Stacktrace/Error Log
Relevant Excerpt of pubspec.lock
The text was updated successfully, but these errors were encountered: