Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

C# printer: a self-bounded interface's wildcard interface and companion class share a name (CS0102)

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

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
64/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
csharp, java
Ambito
compilers, testing

Direzione di ricerca

Start with the TestJavaToCSharpStructure.wildcardInterfaces case and its wildcardInterfaces-Lifecycles.cs golden file. Check how the C# printer emits wildcard interfaces and companion statics, then choose one of the two fixes described in the issue and update the assertion. Done means the generated C# has no duplicate IImpacter declaration and the structure test expects the chosen output.

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

Descrizione

front-end:csharp

A generic interface whose type parameter is self-bounded, with a static method, gets both a wildcard interface (CSharpWildcardInterfaces) and a companion class for its statics. Both are named after the non-generic interface, so C# rejects the type (CS0102).

Java, from TestJavaToCSharpStructure.wildcardInterfaces (LIFECYCLES):

public interface Grade<G extends Grade<G>> { }
public interface Impacter<G extends Grade<G>> {
    java.util.List<G> impacts();
    static <G extends Grade<G>> Impacter<G> none() { return null; }
}
static int impacts(Impacter<?> impacter) { return impacter.impacts().size(); }

C#, from the golden file wildcardInterfaces-Lifecycles.cs:

public interface IImpacter<G> : IImpacter where G : IGrade<G> { ... }
public interface IImpacter { }
public static class IImpacter { public static IImpacter None() => null; }

Roslyn: error CS0102: The type 'Lifecycles' already contains a definition for 'IImpacter'.

For a type that isn't self-bounded, the companion's statics go into the wildcard interface itself (ITupleLifecycle.Same). The test's comment, "a self-bounded interface with a companion keeps both, as before the companion became the wildcard interface", and its assertion public static class IImpacter { both expect this output. So the golden file has never compiled, and the structure tests don't compile their golden files.

Possible fixes:

  • Put the statics into the wildcard interface here too, as static interface members.
  • Give the companion class another name.

Whichever is chosen, the test's assertion needs to change with it.

Lingua principale
Java
Stelle
1
Fork
1
Merge medio
1h 58m
PR unite (30g)
5

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.