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

Abierto
#186 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
68/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
csharp, java
Área
compilers

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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

Lenguaje dominante
Java
Estrellas
1
Forks
1
Merge medio
1 h 13 min
PR fusionados (30 d)
6

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de CodeLaser/maddi

Todos los issues de CodeLaser/maddi

Issues similares

Más issues de Java

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.