Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[shared_preferences] Prepare for change in handling of NoSuchMethod. #6318

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ abstract class SharedPreferencesStorePlatform {
if (!value.isMock) {
try {
value._verifyProvidesDefaultImplementations();
} on NoSuchMethodError catch (_) {
} catch (_) {
throw AssertionError(
'Platform interfaces must not be implemented with `implements`');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ void main() {
throwsAssertionError,
);
});

test('disallows implementing interface, unusual exception', () {
expect(
() {
SharedPreferencesStorePlatform.instance =
IllegalImplementationWithUnusualException();
},
throwsAssertionError,
);
});
});
}

Expand Down Expand Up @@ -46,3 +56,12 @@ class IllegalImplementation implements SharedPreferencesStorePlatform {
throw UnimplementedError();
}
}

class IllegalImplementationWithUnusualException extends IllegalImplementation {
@override
dynamic noSuchMethod(Invocation invocation) {
throw _UnusualException();
}
}

class _UnusualException {}