Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở
#160 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
64/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
csharp, java
Lĩnh vực
compilers, testing

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Java
Star
1
Fork
1
Merge trung bình
1 giờ 58 phút
Pull request đã merge (30 ngày)
5

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của CodeLaser/maddi

Tất cả issue của CodeLaser/maddi

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.