mirror of
https://github.com/pese-git/cherrypick.git
synced 2026-01-23 21:13:35 +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');
|
||||
switch (bindingType) {
|
||||
case BindingType.instance:
|
||||
return isAsyncInstance
|
||||
? '.toInstanceAsync(($fnArgs) => $methodName($fnArgs))'
|
||||
: '.toInstance(($fnArgs) => $methodName($fnArgs))';
|
||||
throw StateError(
|
||||
'Internal error: _generateWithParamsProvideClause called for @instance binding with @params.');
|
||||
//return isAsyncInstance
|
||||
// ? '.toInstanceAsync(($fnArgs) => $methodName($fnArgs))'
|
||||
// : '.toInstance(($fnArgs) => $methodName($fnArgs))';
|
||||
case BindingType.provide:
|
||||
default:
|
||||
if (isAsyncProvide) {
|
||||
@@ -218,6 +220,15 @@ class BindSpec {
|
||||
final bindingType =
|
||||
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.
|
||||
bool isAsyncInstance = false;
|
||||
bool isAsyncProvide = false;
|
||||
|
||||
Reference in New Issue
Block a user