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
|
// For scanner-style factory, pass args as two positional parameters
|
||||||
return Function.apply(factory, [positionalArgs, namedArgSymbols]);
|
return Function.apply(factory, [positionalArgs, namedArgSymbols]);
|
||||||
} else {
|
} else {
|
||||||
// For direct-style factory, wrap it to match scanner-style signature
|
// For direct-style factory, pass args directly
|
||||||
final wrappedFactory = (List args, [Map<Symbol, dynamic>? named]) {
|
if (namedArgs.isEmpty) {
|
||||||
return Function.apply(factory, args, named);
|
return Function.apply(factory, positionalArgs);
|
||||||
};
|
} else {
|
||||||
return wrappedFactory(positionalArgs, namedArgSymbols);
|
return Function.apply(factory, positionalArgs, namedArgSymbols);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw ReflectionException('Failed to create instance: $e');
|
throw ReflectionException('Failed to create instance: $e');
|
||||||
|
|
|
@ -104,15 +104,9 @@ class Scanner {
|
||||||
final name = positionalArgs[0] as String;
|
final name = positionalArgs[0] as String;
|
||||||
final age = positionalArgs[1] as int;
|
final age = positionalArgs[1] as int;
|
||||||
return Function.apply(typeObj, [name, age], {});
|
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