update: 39 pass 5 fail

This commit is contained in:
Patrick Stewart 2024-11-29 09:30:54 -07:00
parent d0090689d4
commit f08454f447
2 changed files with 21 additions and 14 deletions

View file

@ -94,15 +94,14 @@ class RuntimeReflector {
factoryStr.contains('Map<Symbol');
if (isScannerStyle) {
// For scanner-style factory, pass args as a single list argument
return factory([positionalArgs, namedArgSymbols]);
// For scanner-style factory, pass args as two positional parameters
return Function.apply(factory, [positionalArgs, namedArgSymbols]);
} else {
// For direct-style factory, pass args directly
if (constructor.parameters.any((p) => p.isNamed)) {
return Function.apply(factory, positionalArgs, namedArgSymbols);
} else {
return Function.apply(factory, positionalArgs);
}
// 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);
}
} catch (e) {
throw ReflectionException('Failed to create instance: $e');

View file

@ -110,15 +110,19 @@ class TypeMirrorImpl extends TypedMirror implements TypeMirror {
if (this == other) return true;
if (other is! TypeMirrorImpl) return false;
// Dynamic is a supertype of all types
if (other.type == dynamicType) return true;
// Never is a subtype of all types
if (type == Never) return true;
// Dynamic is a supertype of all types except void
if (other.type == dynamicType && type != voidType) return true;
// void is only a subtype of itself
if (type == voidType) return other.type == voidType;
// Get type metadata
final metadata = Reflector.getConstructorMetadata(type);
if (metadata == null) return false;
// For now, just handle basic type relationships
// TODO: Implement proper type relationship checking
return false;
}
@ -126,8 +130,12 @@ class TypeMirrorImpl extends TypedMirror implements TypeMirror {
bool isAssignableTo(TypeMirror other) {
// A type T may be assigned to a type S if either:
// 1. T is a subtype of S, or
// 2. S is dynamic
if (other is TypeMirrorImpl && other.type == dynamicType) return true;
// 2. S is dynamic (except for void)
if (other is TypeMirrorImpl &&
other.type == dynamicType &&
type != voidType) {
return true;
}
return isSubtypeOf(other);
}