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 {
16661666 _dummyFakedValue (dartType, invocation),
16671667 ExtensionTypeElement (: final typeErasure)
16681668 when ! typeErasure.containsPrivateName =>
1669- _dummyValue (typeErasure, invocation),
1669+ _dummyValue (typeErasure, invocation). asA ( _typeReference (dartType)) ,
16701670 ExtensionTypeElement () =>
16711671 _dummyValueFallbackToRuntime (dartType, invocation),
16721672 _ => throw StateError (
Original file line number Diff line number Diff line change @@ -3775,8 +3775,20 @@ void main() {
37753775 E get v;
37763776 }
37773777 ''' ),
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))' ))));
37803792 });
37813793 });
37823794 group ('build_extensions support' , () {
Original file line number Diff line number Diff line change @@ -74,4 +74,7 @@ class UsesExtTypes {
7474 Ext extTypeReturn (int _) => Ext (42 );
7575 bool privateExtTypeArg (ExtOfPrivate _) => true ;
7676 ExtOfPrivate privateExtTypeReturn (int _) => ExtOfPrivate (private);
77+ Future <Ext > futureExtTypeReturn (int _) => Future .value (Ext (43 ));
78+ Future <ExtOfPrivate > futureExtOfPrivateTypeReturn (int _) =>
79+ Future .value (ExtOfPrivate (private));
7780}
Original file line number Diff line number Diff line change @@ -365,6 +365,15 @@ void main() {
365365 expect (usesExtTypes.extTypeReturn (2 ), equals (Ext (42 )));
366366 expect (usesExtTypes.extTypeReturn (42 ), equals (Ext (0 )));
367367 });
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+ });
368377 });
369378 });
370379
You can’t perform that action at this time.
0 commit comments