From f08454f447412dc7b8330f78ae14b874474dd1c6 Mon Sep 17 00:00:00 2001 From: Patrick Stewart Date: Fri, 29 Nov 2024 09:30:54 -0700 Subject: [PATCH] update: 39 pass 5 fail --- .../lib/src/core/runtime_reflector.dart | 15 +++++++------- .../lib/src/mirrors/type_mirror_impl.dart | 20 +++++++++++++------ 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/packages/reflection/lib/src/core/runtime_reflector.dart b/packages/reflection/lib/src/core/runtime_reflector.dart index 4618c41..0aa9dc9 100644 --- a/packages/reflection/lib/src/core/runtime_reflector.dart +++ b/packages/reflection/lib/src/core/runtime_reflector.dart @@ -94,15 +94,14 @@ class RuntimeReflector { factoryStr.contains('Map 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? named]) { + return Function.apply(factory, args, named); + }; + return wrappedFactory(positionalArgs, namedArgSymbols); } } catch (e) { throw ReflectionException('Failed to create instance: $e'); diff --git a/packages/reflection/lib/src/mirrors/type_mirror_impl.dart b/packages/reflection/lib/src/mirrors/type_mirror_impl.dart index 27d9a18..1e3481a 100644 --- a/packages/reflection/lib/src/mirrors/type_mirror_impl.dart +++ b/packages/reflection/lib/src/mirrors/type_mirror_impl.dart @@ -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); }