update: 40 pass 4 fail
This commit is contained in:
parent
a31ca35ba4
commit
74e91914c2
2 changed files with 8 additions and 13 deletions
|
@ -97,11 +97,12 @@ class RuntimeReflector {
|
|||
// For scanner-style factory, pass args as two positional parameters
|
||||
return Function.apply(factory, [positionalArgs, namedArgSymbols]);
|
||||
} else {
|
||||
// For direct-style factory, wrap it to match scanner-style signature
|
||||
final wrappedFactory = (List args, [Map<Symbol, dynamic>? named]) {
|
||||
return Function.apply(factory, args, named);
|
||||
};
|
||||
return wrappedFactory(positionalArgs, namedArgSymbols);
|
||||
// For direct-style factory, pass args directly
|
||||
if (namedArgs.isEmpty) {
|
||||
return Function.apply(factory, positionalArgs);
|
||||
} else {
|
||||
return Function.apply(factory, positionalArgs, namedArgSymbols);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
throw ReflectionException('Failed to create instance: $e');
|
||||
|
|
|
@ -104,15 +104,9 @@ class Scanner {
|
|||
final name = positionalArgs[0] as String;
|
||||
final age = positionalArgs[1] as int;
|
||||
return Function.apply(typeObj, [name, age], {});
|
||||
|
||||
default:
|
||||
// For unknown types, create a generic factory that applies the arguments directly
|
||||
return Function.apply(
|
||||
constructor.name.isEmpty ? typeObj : typeObj[constructor.name],
|
||||
positionalArgs,
|
||||
namedArgs,
|
||||
);
|
||||
}
|
||||
|
||||
throw UnsupportedError('Cannot create instance of $typeName');
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue