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

オープン
#186 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
68/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
csharp, java
領域
compilers

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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).

主要言語
Java
スター
1
フォーク
1
平均マージ
1時間 13分
マージ済み PR(30日)
6

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

CodeLaser/maddi のほかの issue

CodeLaser/maddi の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。