update: 37 pass 7 fail
This commit is contained in:
parent
8de776f5b5
commit
08e0dc9113
1 changed files with 15 additions and 7 deletions
|
@ -88,14 +88,22 @@ class RuntimeReflector {
|
||||||
(key, value) => MapEntry(Symbol(key), value),
|
(key, value) => MapEntry(Symbol(key), value),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Call the factory with the arguments spread out
|
// Try to determine if this is a scanner-style factory or a direct factory
|
||||||
if (constructor.parameters.any((p) => p.isNamed)) {
|
try {
|
||||||
// For constructors with named parameters
|
// First try scanner-style (List, Map) factory
|
||||||
|
return factory([positionalArgs, namedArgSymbols]);
|
||||||
|
} catch (e) {
|
||||||
|
try {
|
||||||
|
// Then try direct function application
|
||||||
return Function.apply(factory, positionalArgs, namedArgSymbols);
|
return Function.apply(factory, positionalArgs, namedArgSymbols);
|
||||||
} else {
|
} catch (e2) {
|
||||||
// For constructors with only positional parameters
|
// If both fail, try one more time with just the positional args
|
||||||
|
if (namedArgs.isEmpty) {
|
||||||
return Function.apply(factory, positionalArgs);
|
return Function.apply(factory, positionalArgs);
|
||||||
}
|
}
|
||||||
|
rethrow;
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw ReflectionException('Failed to create instance: $e');
|
throw ReflectionException('Failed to create instance: $e');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue