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

Aperta
#191 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
csharp, java, kotlin
Ambito
devtools

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Java
Stelle
1
Fork
1
Merge medio
48m
PR unite (30g)
2

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di CodeLaser/maddi

Tutte le issue di CodeLaser/maddi

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.