File tree Expand file tree Collapse file tree 4 files changed +27
-3
lines changed Expand file tree Collapse file tree 4 files changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -1666,7 +1666,7 @@ class _MockClassInfo {
1666
1666
_dummyFakedValue (dartType, invocation),
1667
1667
ExtensionTypeElement (: final typeErasure)
1668
1668
when ! typeErasure.containsPrivateName =>
1669
- _dummyValue (typeErasure, invocation),
1669
+ _dummyValue (typeErasure, invocation). asA ( _typeReference (dartType)) ,
1670
1670
ExtensionTypeElement () =>
1671
1671
_dummyValueFallbackToRuntime (dartType, invocation),
1672
1672
_ => throw StateError (
Original file line number Diff line number Diff line change @@ -3775,8 +3775,20 @@ void main() {
3775
3775
E get v;
3776
3776
}
3777
3777
''' ),
3778
- decodedMatches (
3779
- allOf (contains ('E get v' ), contains ('returnValue: 0' ))));
3778
+ decodedMatches (allOf (
3779
+ contains ('E get v' ), contains ('returnValue: (0 as _i2.E)' ))));
3780
+ });
3781
+
3782
+ test ('are supported as Future return types' , () async {
3783
+ await expectSingleNonNullableOutput (
3784
+ dedent ('''
3785
+ extension type E(int v) {}
3786
+ class Foo {
3787
+ Future<E> get v;
3788
+ }
3789
+ ''' ),
3790
+ decodedMatches (allOf (contains ('_i3.Future<_i2.E> get v' ),
3791
+ contains ('returnValue: _i3.Future<_i2.E>.value((0 as _i2.E))' ))));
3780
3792
});
3781
3793
});
3782
3794
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