mirror of
https://github.com/pese-git/cherrypick.git
synced 2026-01-24 05:25:19 +00:00
fix: update instance generator code
This commit is contained in:
@@ -125,9 +125,11 @@ class BindSpec {
|
|||||||
final multiLine = fnArgs.length > 60 || fnArgs.contains('\n');
|
final multiLine = fnArgs.length > 60 || fnArgs.contains('\n');
|
||||||
switch (bindingType) {
|
switch (bindingType) {
|
||||||
case BindingType.instance:
|
case BindingType.instance:
|
||||||
return isAsyncInstance
|
throw StateError(
|
||||||
? '.toInstanceAsync(($fnArgs) => $methodName($fnArgs))'
|
'Internal error: _generateWithParamsProvideClause called for @instance binding with @params.');
|
||||||
: '.toInstance(($fnArgs) => $methodName($fnArgs))';
|
//return isAsyncInstance
|
||||||
|
// ? '.toInstanceAsync(($fnArgs) => $methodName($fnArgs))'
|
||||||
|
// : '.toInstance(($fnArgs) => $methodName($fnArgs))';
|
||||||
case BindingType.provide:
|
case BindingType.provide:
|
||||||
default:
|
default:
|
||||||
if (isAsyncProvide) {
|
if (isAsyncProvide) {
|
||||||
@@ -218,6 +220,15 @@ class BindSpec {
|
|||||||
final bindingType =
|
final bindingType =
|
||||||
hasInstance ? BindingType.instance : BindingType.provide;
|
hasInstance ? BindingType.instance : BindingType.provide;
|
||||||
|
|
||||||
|
// PROHIBIT @params with @instance bindings!
|
||||||
|
if (bindingType == BindingType.instance && hasParams) {
|
||||||
|
throw InvalidGenerationSourceError(
|
||||||
|
'@params() (runtime arguments) cannot be used together with @instance() on method $methodName. '
|
||||||
|
'Use @provide() instead if you want runtime arguments.',
|
||||||
|
element: method,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// -- Extract inner type for Future<T> and set async flags.
|
// -- Extract inner type for Future<T> and set async flags.
|
||||||
bool isAsyncInstance = false;
|
bool isAsyncInstance = false;
|
||||||
bool isAsyncProvide = false;
|
bool isAsyncProvide = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user