Skip to content

Fix Parser.DartMappable generating invalid Dart syntax for generic return types#901

Draft
Copilot wants to merge 2 commits intomasterfrom
copilot/fix-invalid-dart-syntax-generic-types
Draft

Fix Parser.DartMappable generating invalid Dart syntax for generic return types#901
Copilot wants to merge 2 commits intomasterfrom
copilot/fix-invalid-dart-syntax-generic-types

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 29, 2026

Parser.DartMappable appended Mapper.fromMap(...) directly onto the full display string of a generic type, producing unparseable code like ApiResponse<LoginDataModel>Mapper.fromMap(...) instead of ApiResponseMapper.fromMap<LoginDataModel>(...).

Changes

  • New helper _dartMappableFromMapString: Detects ParameterizedType with type arguments, splits the base class name from type args, and emits the correct {Base}Mapper.fromMap<{TypeArgs}>(data) form. Falls back to the non-generic form for plain types.
  • Updated 4 call sites in generator.dart where DartMappable constructed fromMap strings:
    • Direct return type deserialization
    • List<T> element deserialization
    • Map<K, List<V>> value deserialization
    • Map<K, V> value deserialization
  • Added tests covering DartMappable with non-generic, generic, List, Map<String, V>, and Map<String, List<V>> return types.

Example

// Before (invalid syntax — build failure)
_value = ApiResponse<LoginDataModel>Mapper.fromMap(_result.data!);

// After (correct DartMappable generic mapper syntax)
_value = ApiResponseMapper.fromMap<LoginDataModel>(_result.data!);

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Fix invalid Dart syntax generation for generic return types Fix Parser.DartMappable generating invalid Dart syntax for generic return types Mar 29, 2026
Copilot AI requested a review from trevorwang March 29, 2026 23:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Parser.DartMappable generates invalid Dart syntax for generic return types

2 participants