update: 39 pass 5 fail
This commit is contained in:
parent
d0090689d4
commit
f08454f447
2 changed files with 21 additions and 14 deletions
|
@ -94,15 +94,14 @@ class RuntimeReflector {
|
||||||
factoryStr.contains('Map<Symbol');
|
factoryStr.contains('Map<Symbol');
|
||||||
|
|
||||||
if (isScannerStyle) {
|
if (isScannerStyle) {
|
||||||
// For scanner-style factory, pass args as a single list argument
|
// For scanner-style factory, pass args as two positional parameters
|
||||||
return factory([positionalArgs, namedArgSymbols]);
|
return Function.apply(factory, [positionalArgs, namedArgSymbols]);
|
||||||
} else {
|
} else {
|
||||||
// For direct-style factory, pass args directly
|
// For direct-style factory, wrap it to match scanner-style signature
|
||||||
if (constructor.parameters.any((p) => p.isNamed)) {
|
final wrappedFactory = (List args, [Map<Symbol, dynamic>? named]) {
|
||||||
return Function.apply(factory, positionalArgs, namedArgSymbols);
|
return Function.apply(factory, args, named);
|
||||||
} else {
|
};
|
||||||
return Function.apply(factory, positionalArgs);
|
return wrappedFactory(positionalArgs, namedArgSymbols);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw ReflectionException('Failed to create instance: $e');
|
throw ReflectionException('Failed to create instance: $e');
|
||||||
|
|
|
@ -110,15 +110,19 @@ class TypeMirrorImpl extends TypedMirror implements TypeMirror {
|
||||||
if (this == other) return true;
|
if (this == other) return true;
|
||||||
if (other is! TypeMirrorImpl) return false;
|
if (other is! TypeMirrorImpl) return false;
|
||||||
|
|
||||||
// Dynamic is a supertype of all types
|
// Never is a subtype of all types
|
||||||
if (other.type == dynamicType) return true;
|
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
|
// Get type metadata
|
||||||
final metadata = Reflector.getConstructorMetadata(type);
|
final metadata = Reflector.getConstructorMetadata(type);
|
||||||
if (metadata == null) return false;
|
if (metadata == null) return false;
|
||||||
|
|
||||||
// For now, just handle basic type relationships
|
|
||||||
// TODO: Implement proper type relationship checking
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,8 +130,12 @@ class TypeMirrorImpl extends TypedMirror implements TypeMirror {
|
||||||
bool isAssignableTo(TypeMirror other) {
|
bool isAssignableTo(TypeMirror other) {
|
||||||
// A type T may be assigned to a type S if either:
|
// A type T may be assigned to a type S if either:
|
||||||
// 1. T is a subtype of S, or
|
// 1. T is a subtype of S, or
|
||||||
// 2. S is dynamic
|
// 2. S is dynamic (except for void)
|
||||||
if (other is TypeMirrorImpl && other.type == dynamicType) return true;
|
if (other is TypeMirrorImpl &&
|
||||||
|
other.type == dynamicType &&
|
||||||
|
type != voidType) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return isSubtypeOf(other);
|
return isSubtypeOf(other);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue