Skip to content

UnimplementedError: (TypeParameterTypeImpl) T #1047

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

Closed
leshkovichpvl opened this issue Nov 30, 2021 · 6 comments · Fixed by #1068
Closed

UnimplementedError: (TypeParameterTypeImpl) T #1047

leshkovichpvl opened this issue Nov 30, 2021 · 6 comments · Fixed by #1068
Assignees

Comments

@leshkovichpvl
Copy link

leshkovichpvl commented Nov 30, 2021

Flutter 2.5.3 • channel stable, json_serializable: 6.0.1

import 'package:json_annotation/json_annotation.dart';

part 'pageable_list.g.dart';

@JsonSerializable(explicitToJson: true, genericArgumentFactories: true)
class PageableList<T> {
  const PageableList({required this.edges});

  factory PageableList.fromJson(Map<String, dynamic> json, T Function(Object? json) fromJsonT) => _$PageableListFromJson<T>(json, fromJsonT);

  final List<Edge<T>> edges;

  Map<String, dynamic> toJson(Object? Function(T value) toJsonT) => _$PageableListToJson(this, toJsonT);

}

@JsonSerializable(genericArgumentFactories: true)
class Edge<T> {
  Edge({
    required this.node,
    required this.cursor,
  });
  
  factory Edge.fromJson(Map<String, dynamic> json, T Function(Object? json) fromJsonT) => _$EdgeFromJson<T>(json, fromJsonT);

  final String cursor;
  final T node;
  
  Map<String, dynamic> toJson(Object? Function(T value) toJsonT) => _$EdgeToJson(this, toJsonT);
}

Error:

[INFO] Running build...
[INFO] 1.1s elapsed, 0/10 actions completed.
[INFO] 2.1s elapsed, 0/10 actions completed.
[INFO] 3.1s elapsed, 0/10 actions completed.
[SEVERE] json_serializable:json_serializable on lib/src/utils/pagination/pageable_list.dart:

UnimplementedError: (TypeParameterTypeImpl) T
[INFO] 10.0s elapsed, 1/10 actions completed.

I'm guessing the problem might be with List<Edge<T>> ?

@kevmoo
Copy link
Collaborator

kevmoo commented Nov 30, 2021

Please run with --verbose!

@kevmoo
Copy link
Collaborator

kevmoo commented Nov 30, 2021

...and include the information

@leshkovichpvl
Copy link
Author

Please run with --verbose!

UnimplementedError: (TypeParameterTypeImpl) T
package:json_serializable/src/utils.dart 194:3                         typeToCode
dart:_internal                                                         ListIterable.join
package:json_serializable/src/utils.dart 190:48                        typeToCode
package:json_serializable/src/type_helpers/json_helper.dart 133:17     JsonHelper.deserialize
package:json_serializable/src/type_helper_ctx.dart 68:29               TypeHelperCtx.deserialize.<fn>
dart:core                                                              Iterable.firstWhere
package:json_serializable/src/type_helper_ctx.dart 88:46               TypeHelperCtx._run
package:json_serializable/src/type_helper_ctx.dart 65:19               TypeHelperCtx.deserialize
package:json_serializable/src/type_helpers/iterable_helper.dart 76:32  IterableHelper.deserialize
package:json_serializable/src/type_helper_ctx.dart 68:29               TypeHelperCtx.deserialize.<fn>
dart:core                                                              Iterable.firstWhere
package:json_serializable/src/type_helper_ctx.dart 88:46               TypeHelperCtx._run
package:json_serializable/src/type_helper_ctx.dart 65:19               TypeHelperCtx.deserialize
package:json_serializable/src/decode_helper.dart 197:10                DecodeHelper._deserializeForField.deserialize
package:json_serializable/src/decode_helper.dart 216:17                DecodeHelper._deserializeForField
package:json_serializable/src/decode_helper.dart 56:9                  DecodeHelper.createFactory.deserializeFun
package:json_serializable/src/decode_helper.dart 314:32                _writeConstructorInvocation.<fn>
dart:core                                                              StringBuffer.writeAll
package:json_serializable/src/decode_helper.dart 312:9                 _writeConstructorInvocation
package:json_serializable/src/decode_helper.dart 59:18                 DecodeHelper.createFactory
package:json_serializable/src/generator_helper.dart 85:28              GeneratorHelper.generate
dart:_internal                                                         WhereIterator.moveNext
package:json_serializable/src/json_part_builder.dart 64:27             _UnifiedGenerator.generate
package:source_gen/src/builder.dart 328:23                             _generate

@yousinix
Copy link

I have the same issue too.
I had to downgrade json_serializable to ^4.1.2 to get it to work.
Seems like the issue exists in v5.X.X too.

@mohan-sai-manthri-sg
Copy link

I'm facing this issue in version 6.1.1 and I cannot downgrade to 4.1.2 as there are other depedent packages. Is there any other solution?

@kevmoo kevmoo self-assigned this Dec 16, 2021
@kevmoo kevmoo changed the title UnimplementedError: (TypeParameterTypeImpl) T No support for generics nested within generics with genericArgumentFactories: true Dec 16, 2021
@kevmoo kevmoo changed the title No support for generics nested within generics with genericArgumentFactories: true UnimplementedError: (TypeParameterTypeImpl) T Dec 16, 2021
@kevmoo
Copy link
Collaborator

kevmoo commented Dec 16, 2021

Published! https://pub.dev/packages/json_serializable/changelog#612

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants