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

Extension type with generic #755

Open
PlugFox opened this issue Jun 12, 2024 · 0 comments
Open

Extension type with generic #755

PlugFox opened this issue Jun 12, 2024 · 0 comments

Comments

@PlugFox
Copy link

PlugFox commented Jun 12, 2024

It is impossible to use the library if an extension type contains generics.
For extension types without generics, it works fine (at the master branch only).

  • pubspec.yaml
dev_dependencies:
  # https://github.com/dart-lang/mockito/issues/732
  # https://github.com/dart-lang/mockito/pull/738
  # https://github.com/dart-lang/mockito/issues/755
  mockito:
    git:
      url: https://github.com/dart-lang/mockito.git
      ref: master
  • example.dart
import 'dart:async';

import 'package:mockito/annotations.dart';

extension type ET$Generic<T extends num>(Stream<T> _) implements Stream<T> {
  ET$Generic<S> filter<S extends num>() =>
      ET$Generic<S>(transform<S>(StreamTransformer<T, S>.fromHandlers(
        handleData: (data, sink) => switch (data) {
          S valid => sink.add(valid),
          _ => null,
        },
      )));
}

abstract interface class Interface {
  abstract final ET$Generic<num> stream;
}

@GenerateMocks([Interface])
void main() {}
  • output
Built build_runner:build_runner.
[INFO] Generating build script completed, took 129ms
[INFO] Reading cached asset graph completed, took 46ms
[INFO] Checking for updates since last build completed, took 328ms
[SEVERE] mockito:mockBuilder on test/unit/example.dart:

Bad state: T extends num not found, scopes: [{}]
package:mockito/src/builder.dart 2024:8                      _MockClassInfo._lookupTypeParameter
package:mockito/src/builder.dart 2162:22                     _MockClassInfo._typeReference.<fn>
package:code_builder/src/specs/type_reference.g.dart 164:33  _$TypeReferenceBuilder.update
package:code_builder/src/specs/type_reference.g.dart 22:36   new _$TypeReference
package:mockito/src/builder.dart 2160:14                     _MockClassInfo._typeReference
package:mockito/src/builder.dart 1527:27                     _MockClassInfo._dummyValue
package:mockito/src/builder.dart 1650:11                     _MockClassInfo._dummyValueImplementing
package:mockito/src/builder.dart 1547:12                     _MockClassInfo._dummyValue
package:mockito/src/builder.dart 1945:24                     _MockClassInfo._buildOverridingGetter
package:mockito/src/builder.dart 1222:36                     _MockClassInfo.fieldOverrides.<fn>
package:code_builder/src/specs/method.g.dart 323:33          _$MethodBuilder.update
package:code_builder/src/specs/method.g.dart 38:29           new _$Method
package:mockito/src/builder.dart 1222:15                     _MockClassInfo.fieldOverrides
dart:core                                                    List.addAll
package:built_collection/src/list/list_builder.dart 98:14    ListBuilder.addAll
package:mockito/src/builder.dart 1180:28                     _MockClassInfo._buildMockClass.<fn>.<fn>
package:mockito/src/builder.dart 2069:24                     _MockClassInfo._withTypeParameters
package:mockito/src/builder.dart 1134:7                      _MockClassInfo._buildMockClass.<fn>
package:code_builder/src/specs/class.g.dart 345:33           _$ClassBuilder.update
package:code_builder/src/specs/class.g.dart 40:28            new _$Class
package:mockito/src/builder.dart 1112:12                     _MockClassInfo._buildMockClass
package:mockito/src/builder.dart 1058:9                      new _MockLibraryInfo
package:mockito/src/builder.dart 94:29                       MockBuilder.build

[INFO] Running build completed, took 384ms
[INFO] Caching finalized dependency graph completed, took 32ms
[SEVERE] Failed after 421ms
make: *** [generate] Error 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant