C#: Collection<?> / Set<?> print as non-generic ICollection, which HashSet<T>, ISet<T>, ICollection<T> do not implement

未关闭
#191 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
25/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
csharp, java, kotlin
领域
devtools

调研方向

Start by reading the CSharpTypeName.NON_GENERIC handling and the regression commit references in the issue. Compare how collection types are represented across method parameters, fields, and constructors, then examine the listed failures in timefold and langchain4j. Done means one consistent collection representation handles those positions and resolves the reported type errors and overload ambiguity.

由索引模型根据 Issue 内容生成。

描述

bug

CSharpTypeName.NON_GENERIC prints Collection<?> and Set<?> as System.Collections.ICollection. Of C#'s generic collections only List<T> and arrays implement it; HashSet<T>, ISet<T>, ICollection<T>, IReadOnlyList<T> and JavaLinkedHashSet<T> do not, so passing them is CS1503 (timefold: ConfigUtils.isEmptyCollection, JoinerType.containsAny, AbstractSingleConstraintAssertion, ~6 errors).

Tried in 281a5a054, reverted in a8ddda9af: capturing a method's Collection<?> / Set<?> parameter as ICollection<TE> (as program types' wildcards are captured). timefold 406 -> 401, but langchain4j 155 -> 163:

  • a Collection<?> field or constructor parameter stays non-generic ICollection, and goes into no ICollection<TE> (CS0411, IsIn -> NumberComparator.containsAsBigDecimals);
  • a captured parameter passed into a constructor's non-generic ICollection is CS1503 (MetadataFilterBuilder.isIn);
  • beside an Object[] overload the generic method makes the call ambiguous (CS0121, Utils.isNullOrEmpty).

A fix has to treat all positions alike: e.g. a compatibility-library read-only view type that every collection converts to, or IEnumerable plus extension members for size/isEmpty/contains.

主要语言
Java
星标
1
派生
1
平均合并
48 分钟
30 天内合并 PR
2

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

CodeLaser/maddi 的其他 Issue

查看 CodeLaser/maddi 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。