Skip to content

C# printer: an inner class of a generic class needs the outer type's arguments (Outer<A>.Inner) #142

Closed

Description

@bnaudts

Problem

A class nested in a generic class, used from outside it, needs the outer class's type arguments in C#: Java's
ElementAwareArrayList<Mapped_>.Entry is C#'s ElementAwareArrayList<Mapped_>.Entry. The CST's ParameterizedType
of Entry does not carry the outer type's arguments, so the C# printer writes ElementAwareArrayList.Entry, which
names the non-generic companion class of the static members, where there is no Entry (CS0426).

In timefold this is 5 errors (AbstractToListSlot, AbstractToCollectionSlot, AbstractLeftDatasetInstance,
RandomAccessLeafIndexer). A smaller sample:

public class Holder {
    static final class Store<T> {
        final class Entry { }
        Entry add(T value) { return new Entry(); }
    }
    private Store<String>.Entry cached;
    void keep(Store<String> store) { cached = store.add("x"); }
}

prints private Holder.Store.Entry cached; (wanted: Holder.Store<string>.Entry), and also qualifies Entry
inside Store<T> itself as Holder.Store.Entry, where plain Entry (or Store<T>.Entry) would do.

What is needed

  • front end: the outer type's arguments on the ParameterizedType of an inner class's use (javac has them on the
    ClassType's enclosing type);
  • C# printer: print them, Outer<A>.Inner, and inside the generic class leave a nested type simple.

Part of #115.

Activity

  1. bnaudts commented on Nov 10, 2026

    @bnaudts
    ContributorAuthor

    Fixed on devel: the front end carries the outer type's arguments on an inner class's use (f4cccf3). The C# printer writes Outer<T>.Inner (0e36107, probe in 56348e8), and the Kotlin printer handles an inner class constructed by its simple name (bf19316).

    🤖 Generated with Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    front-end:csharpParsing/resolution through a C# (Roslyn) front end

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions