You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
C# printer: nine unit-test samples that Roslyn rejects #185
The C# printer's unit tests now have Roslyn judge every sample (CommonJavaToCSharp.translate, CSharpCheck on tools/csharp-check -serve). On the first run, 9 of 131 samples do not compile. Each test sets compile = false with a pointer here until its printer bug is fixed; this issue closes when none is left.
TestJavaToCSharpStructure.conditionalVars: var node = c ? new IndexedExists<A, B>() : new UnindexedExists<A, string>() — CS0173, C# finds no common type for a conditional of two sibling classes; Java's is the common supertype (declare it, or cast one branch).
TestJavaToCSharpStructure.innerClasses: Upcoming : IJavaIterator<long> with long? Next() — CS0738, the boxed Long next() must override as long, as it does for a top-level class.
TestJavaToCSharpStructure.localClasses: a local class that captures (Adder) is referenced but not printed anywhere — CS0246.
TestJavaToCSharpStructure.longTypeArguments: a cast through a wildcard printed as object — CS0030 (the wildcard family).
TestJavaToCSharpStructure.suppliers: sealed class Defaults<R> where R : Defaults<R> — CS0701, a class that is a type parameter's bound cannot be sealed.
TestJavaToCSharpStructure.wildcardInterfaces: the wildcard interface IImpacter and the companion static class IImpacter of IImpacter<G> clash — CS0102.
TestJavaToCSharpBcl.navigation: three errors in one sample: T[] ToArray<T>(T[] a) => items.ToArray() (CS0029, E[] to T[]), !Contains(v) && items.Add(v) where Add is void on a HashSet-backed ICollection (CS0019), and c.All(...) on the non-generic ICollection (CS1061).
TestJavaToCSharpFacts.inheritedFamilyAndStructs was the test's own fault (a package-private method implementing an interface method is not Java either) and is fixed.
Harness: maddi c8d0727fc. Fixes: e65b4878d (sealed bound, boxed override as the supertype's argument prints, self-bounded companion merged, AddReturning/ToArray(a)/ContainsAll, System.gc).
Still opted out, all the wildcard design rather than single fixes:
conditionalVars: a conditional whose common type C# cannot write (a wildcard, an intersection) stays var (CS0173). No message is reported for it yet either.
longTypeArguments: a cast through a wildcard printed as object (CS0030).
wildcardInterfaces: now compiles its declarations, but a self-bounded wildcard interface declares no member mentioning the parameter, so impacter.Impacts() on IImpacter is CS1061.
localClasses is by design (LOCAL_CLASS: a capturing local class is not translated) and no longer counted here.
Corpus check of the fixes (maddi cd0126f96): langchain4j 192 → 172 errors (the sealed bound), fernflower and the nullable warnings unchanged. Timefold 596 → 641 errors and 1330 → 1321 compiling files: merging WeightedScoreImpacter's and ConstraintMatchSupplier's companions into their wildcard interfaces removed the duplicate declarations (CS0101/CS0538), behind which Roslyn had hidden the errors of their twelve clients — the ImpactHandlers and ScoreInliners call ImpactScore through the wildcard interface, which cannot declare a member mentioning Score_. Those files compiled before only because Roslyn gives up on an error type. Recorded in the ratchets with that note; the wildcard design is where they get fixed.
toArray(new T[0]) first went through the compat ToArray(a) and inferred the wildcard's object; it is LINQ's ToArray() again for any created array (cd0126f96).
Activity
bnaudts commentedon Nov 5, 2026
Harness: maddi
c8d0727fc. Fixes:e65b4878d(sealed bound, boxed override as the supertype's argument prints, self-bounded companion merged,AddReturning/ToArray(a)/ContainsAll,System.gc).Still opted out, all the wildcard design rather than single fixes:
conditionalVars: a conditional whose common type C# cannot write (a wildcard, an intersection) staysvar(CS0173). No message is reported for it yet either.longTypeArguments: a cast through a wildcard printed asobject(CS0030).wildcardInterfaces: now compiles its declarations, but a self-bounded wildcard interface declares no member mentioning the parameter, soimpacter.Impacts()onIImpacteris CS1061.localClassesis by design (LOCAL_CLASS: a capturing local class is not translated) and no longer counted here.bnaudts commentedon Nov 5, 2026
Corpus check of the fixes (maddi
cd0126f96): langchain4j 192 → 172 errors (the sealed bound), fernflower and the nullable warnings unchanged. Timefold 596 → 641 errors and 1330 → 1321 compiling files: mergingWeightedScoreImpacter's andConstraintMatchSupplier's companions into their wildcard interfaces removed the duplicate declarations (CS0101/CS0538), behind which Roslyn had hidden the errors of their twelve clients — the ImpactHandlers and ScoreInliners callImpactScorethrough the wildcard interface, which cannot declare a member mentioningScore_. Those files compiled before only because Roslyn gives up on an error type. Recorded in the ratchets with that note; the wildcard design is where they get fixed.toArray(new T[0])first went through the compatToArray(a)and inferred the wildcard'sobject; it is LINQ'sToArray()again for any created array (cd0126f96).C# unit tests: Roslyn judges every sample (tools/csharp-check -serve …
C#: five of the samples Roslyn rejected (#185)
C#: a cast between a delegate's constructed types goes through object…
C#: the last two #185 samples compile (conditional vars, self-bounded…
C# ratchet: timefold 593 -> 591 errors, 1336 -> 1340 compiling files (#…