Skip to content
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

Nested Generics don't work with extends #212

Open
BenjiFarquhar opened this issue Jul 20, 2024 · 0 comments
Open

Nested Generics don't work with extends #212

BenjiFarquhar opened this issue Jul 20, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@BenjiFarquhar
Copy link

BenjiFarquhar commented Jul 20, 2024

This code works:

@MappableClass()
class VgnItmEst<V extends VgnItm<T>, T extends Tag> with VgnItmEstMappable<V, T> {
  final V vgnItm;

  const VgnItmEst({
    required this.vgnItm,
  });
}

@MappableClass()
abstract class VgnItm<T extends Tag> with VgnItmMappable<T> {
  final List<T>? tags;

  const VgnItm({
    this.tags,
  });
}

abstract class Tag {
  int get iconCodePoint;
  String get name;
  int get value;
}

Add an extends - causes 2 exceptions in the mapper file:

@MappableClass()
class VgnItmEst<V extends VgnItm<T>, T extends Tag> extends Entity<int> with VgnItmEstMappable<V, T> {
  final V vgnItm;

  const VgnItmEst({
    required this.vgnItm,
    super.id,
  });
}

@MappableClass()
abstract class VgnItm<T extends Tag> extends Entity<int> with VgnItmMappable<T> {
  final List<T>? tags;

  const VgnItm({
    this.tags,
    super.id,
  });
}

abstract class Tag {
  int get iconCodePoint;
  String get name;
  int get value;
}

@MappableClass()
abstract class Entity<T> with EntityMappable<T> {
  final T? id;

  const Entity({
    this.id,
  });
}

Exception 1:

abstract class VgnItmEstCopyWith<
    $R,
    $In extends VgnItmEst<V, T>,
    $Out,
    V extends VgnItm<T>,
    T extends Tag> implements EntityCopyWith<$R, $In, $Out, dynamic> {
  VgnItmCopyWith<$R, VgnItm<Tag>, V> get vgnItm;
  @override
  $R call({V? vgnItm, dynamic id});
  VgnItmEstCopyWith<$R2, $In, $Out2, V, T> $chain<$R2, $Out2>(
      Then<$Out2, $R2> t);
}

The type 'VgnItmCopyWith' is declared with 4 type parameters, but 3 type arguments were given.
Try adjusting the number of type arguments to match the number of type parameters.dartwrong_number_of_type_arguments

Exception 2:

class _VgnItmEstCopyWithImpl<$R, $Out, V extends VgnItm<T>, T extends Tag>
    extends ClassCopyWithBase<$R, VgnItmEst<V, T>, $Out>
    implements VgnItmEstCopyWith<$R, VgnItmEst<V, T>, $Out, V, T> {
  _VgnItmEstCopyWithImpl(super.value, super.then, super.then2);

  @override
  late final ClassMapperBase<VgnItmEst> $mapper =
      VgnItmEstMapper.ensureInitialized();
  @override
  VgnItmCopyWith<$R, VgnItm<Tag>, V> get vgnItm =>
      $value.vgnItm.copyWith.$chain((v) => call(vgnItm: v));
  @override
  $R call({V? vgnItm, Object? id = $none}) => $apply(FieldCopyWithData(
      {if (vgnItm != null) #vgnItm: vgnItm, if (id != $none) #id: id}));
  @override
  VgnItmEst<V, T> $make(CopyWithData data) => VgnItmEst(
      vgnItm: data.get(#vgnItm, or: $value.vgnItm),
      id: data.get(#id, or: $value.id));

  @override
  VgnItmEstCopyWith<$R2, VgnItmEst<V, T>, $Out2, V, T> $chain<$R2, $Out2>(
          Then<$Out2, $R2> t) =>
      _VgnItmEstCopyWithImpl($value, $cast, t);
}

The type 'VgnItmCopyWith' is declared with 4 type parameters, but 3 type arguments were given.
Try adjusting the number of type arguments to match the number of type parameters.dartwrong_number_of_type_arguments

@schultek schultek added the bug Something isn't working label Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants