Open PlugFox opened 2 weeks ago
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(Stream ) implements Stream { ET$Generic filter() => ET$Generic(transform(StreamTransformer<T, S>.fromHandlers( handleData: (data, sink) => switch (data) { S valid => sink.add(valid), => null, }, ))); }
abstract interface class Interface { abstract final ET$Generic stream; }
@GenerateMocks([Interface]) void main() {}
- output ```log 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
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
example.dart
import 'package:mockito/annotations.dart';
extension type ET$Generic(Stream ) implements Stream {
ET$Generic => null,
},
)));
}
filter() => ET$Generic(transform(StreamTransformer<T, S>.fromHandlers( handleData: (data, sink) => switch (data) { S valid => sink.add(valid),abstract interface class Interface { abstract final ET$Generic stream;
}
@GenerateMocks([Interface]) void main() {}