Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

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

Open
#160 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
64/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
csharp, java
Domain
compilers, testing

Research direction

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.

Written by the indexing model from the issue text.

Description

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.

Dominant language
Java
Stars
1
Forks
1
Avg merge
1h 34m
Merged PRs (30d)
7

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from CodeLaser/maddi

All issues in CodeLaser/maddi

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.