C#: an interface's nested types are printed unqualified outside the interface (CS0246)

Đang mở
#186 0 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
68/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
csharp, java
Lĩnh vực
compilers

Hướng nghiên cứu

Start in CSharpTypeName.name around lines 507–518 and compare its qualification logic with CSharpTypeName.inHeader, which the issue says emits the expected qualified names for the lambda adapter. Reproduce the reported Plain and Use cases or use the PromptTemplateFactory corpus example; done means generated C# qualifies nested interface types as IFactory.ITemplate and IFactory.IInput so the reported compiler errors are resolved.

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

Mô tả

front-end:csharp

Found while adding the variance tests (ws/maddi-csharp, after b13471627). A class that names a nested type of an interface prints the simple name, which C# does not resolve outside the interface:

interface Factory {
    interface Input { }
    interface Template { }
    Template create(Input in);
}
class Plain implements Factory {
    public Template create(Input in) { return null; }   // Java: member types inherited from the interface
}
class Use {
    static Factory make(Factory.Template t) { return in -> t; }   // Java: explicitly qualified
}

prints

internal sealed class Plain : IFactory { public ITemplate Create(IInput @in) => null; }   // CS0246 ×2, CS0535
internal sealed class Use { internal static IFactory Make(ITemplate t) => new FactoryLambda(@in => t); }   // CS0246

Expected IFactory.ITemplate / IFactory.IInput, as the lambda adapter beside the interface now prints them (CSharpTypeName.inHeader). C# does not inherit member types from interfaces, so an implementing class needs the qualification as much as an unrelated one. Probably the Qualification treating the nested types as in scope by their simple name; CSharpTypeName.name lines ~507-518.

In the corpus: dev/langchain4j/spi/prompt/PromptTemplateFactory (IInput, ITemplate).

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

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.