File tree 4 files changed +28
-4
lines changed
4 files changed +28
-4
lines changed Original file line number Diff line number Diff line change @@ -1866,7 +1866,7 @@ class _MockClassInfo {
1866
1866
_dummyFakedValue (dartType, invocation),
1867
1867
ExtensionTypeElement2 (: final typeErasure)
1868
1868
when ! typeErasure.containsPrivateName =>
1869
- _dummyValue (typeErasure, invocation),
1869
+ _dummyValue (typeErasure, invocation). asA ( _typeReference (dartType)) ,
1870
1870
ExtensionTypeElement2 () => _dummyValueFallbackToRuntime (
1871
1871
dartType,
1872
1872
invocation,
Original file line number Diff line number Diff line change @@ -4180,14 +4180,26 @@ void main() {
4180
4180
4181
4181
test ('are supported as return types' , () async {
4182
4182
await expectSingleNonNullableOutput (
4183
- dedent ('''
4183
+ dedent ('''
4184
4184
extension type E(int v) {}
4185
4185
class Foo {
4186
4186
E get v;
4187
4187
}
4188
4188
''' ),
4189
- decodedMatches (allOf (contains ('E get v' ), contains ('returnValue: 0' ))),
4190
- );
4189
+ decodedMatches (allOf (
4190
+ contains ('E get v' ), contains ('returnValue: (0 as _i2.E)' ))));
4191
+ });
4192
+
4193
+ test ('are supported as Future return types' , () async {
4194
+ await expectSingleNonNullableOutput (
4195
+ dedent ('''
4196
+ extension type E(int v) {}
4197
+ class Foo {
4198
+ Future<E> get v;
4199
+ }
4200
+ ''' ),
4201
+ decodedMatches (allOf (contains ('_i3.Future<_i2.E> get v' ),
4202
+ contains ('returnValue: _i3.Future<_i2.E>.value((0 as _i2.E))' ))));
4191
4203
});
4192
4204
});
4193
4205
group ('build_extensions support' , () {
Original file line number Diff line number Diff line change @@ -74,4 +74,7 @@ class UsesExtTypes {
74
74
Ext extTypeReturn (int _) => Ext (42 );
75
75
bool privateExtTypeArg (ExtOfPrivate _) => true ;
76
76
ExtOfPrivate privateExtTypeReturn (int _) => ExtOfPrivate (private);
77
+ Future <Ext > futureExtTypeReturn (int _) => Future .value (Ext (43 ));
78
+ Future <ExtOfPrivate > futureExtOfPrivateTypeReturn (int _) =>
79
+ Future .value (ExtOfPrivate (private));
77
80
}
Original file line number Diff line number Diff line change @@ -365,6 +365,15 @@ void main() {
365
365
expect (usesExtTypes.extTypeReturn (2 ), equals (Ext (42 )));
366
366
expect (usesExtTypes.extTypeReturn (42 ), equals (Ext (0 )));
367
367
});
368
+
369
+ test ('a method using extension type as a return type can be stubbed' ,
370
+ () async {
371
+ when (usesExtTypes.futureExtTypeReturn (2 ))
372
+ .thenAnswer ((_) => Future .value (Ext (42 )));
373
+ expect (await usesExtTypes.futureExtTypeReturn (2 ), equals (Ext (42 )));
374
+ expect (await usesExtTypes.futureExtTypeReturn (42 ), equals (Ext (0 )));
375
+ expect (await usesExtTypes.futureExtTypeReturn (42 ), equals (0 ));
376
+ });
368
377
});
369
378
});
370
379
You can’t perform that action at this time.
0 commit comments