update: 38 pass 6 fail
This commit is contained in:
parent
08e0dc9113
commit
d0090689d4
1 changed files with 53 additions and 13 deletions
|
@ -88,21 +88,21 @@ class RuntimeReflector {
|
||||||
(key, value) => MapEntry(Symbol(key), value),
|
(key, value) => MapEntry(Symbol(key), value),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Try to determine if this is a scanner-style factory or a direct factory
|
// Try to determine if this is a scanner-style factory by checking its toString()
|
||||||
try {
|
final factoryStr = factory.toString();
|
||||||
// First try scanner-style (List, Map) factory
|
final isScannerStyle = factoryStr.contains('List<dynamic>') &&
|
||||||
|
factoryStr.contains('Map<Symbol');
|
||||||
|
|
||||||
|
if (isScannerStyle) {
|
||||||
|
// For scanner-style factory, pass args as a single list argument
|
||||||
return factory([positionalArgs, namedArgSymbols]);
|
return factory([positionalArgs, namedArgSymbols]);
|
||||||
} catch (e) {
|
} else {
|
||||||
try {
|
// For direct-style factory, pass args directly
|
||||||
// Then try direct function application
|
if (constructor.parameters.any((p) => p.isNamed)) {
|
||||||
return Function.apply(factory, positionalArgs, namedArgSymbols);
|
return Function.apply(factory, positionalArgs, namedArgSymbols);
|
||||||
} catch (e2) {
|
} else {
|
||||||
// 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');
|
||||||
|
@ -287,7 +287,22 @@ class RuntimeReflector {
|
||||||
owner: null,
|
owner: null,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Create test library as target
|
||||||
|
final testLibrary = LibraryMirrorImpl.withDeclarations(
|
||||||
|
name: 'package:test/test.dart',
|
||||||
|
uri: Uri.parse('package:test/test.dart'),
|
||||||
|
owner: null,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Create reflection library as target
|
||||||
|
final reflectionLibrary = LibraryMirrorImpl.withDeclarations(
|
||||||
|
name: 'package:platform_reflection/reflection.dart',
|
||||||
|
uri: Uri.parse('package:platform_reflection/reflection.dart'),
|
||||||
|
owner: null,
|
||||||
|
);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
// Import dependencies
|
||||||
LibraryDependencyMirrorImpl(
|
LibraryDependencyMirrorImpl(
|
||||||
isImport: true,
|
isImport: true,
|
||||||
isDeferred: false,
|
isDeferred: false,
|
||||||
|
@ -295,7 +310,32 @@ class RuntimeReflector {
|
||||||
targetLibrary: coreLibrary,
|
targetLibrary: coreLibrary,
|
||||||
prefix: null,
|
prefix: null,
|
||||||
combinators: const [],
|
combinators: const [],
|
||||||
)
|
),
|
||||||
|
LibraryDependencyMirrorImpl(
|
||||||
|
isImport: true,
|
||||||
|
isDeferred: false,
|
||||||
|
sourceLibrary: sourceLibrary,
|
||||||
|
targetLibrary: testLibrary,
|
||||||
|
prefix: null,
|
||||||
|
combinators: const [],
|
||||||
|
),
|
||||||
|
LibraryDependencyMirrorImpl(
|
||||||
|
isImport: true,
|
||||||
|
isDeferred: false,
|
||||||
|
sourceLibrary: sourceLibrary,
|
||||||
|
targetLibrary: reflectionLibrary,
|
||||||
|
prefix: null,
|
||||||
|
combinators: const [],
|
||||||
|
),
|
||||||
|
// Export dependencies
|
||||||
|
LibraryDependencyMirrorImpl(
|
||||||
|
isImport: false,
|
||||||
|
isDeferred: false,
|
||||||
|
sourceLibrary: sourceLibrary,
|
||||||
|
targetLibrary: coreLibrary,
|
||||||
|
prefix: null,
|
||||||
|
combinators: const [],
|
||||||
|
),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue