Class NoCaseVariantNameOrError
- All Implemented Interfaces:
BiPredicate<List<ISymbol>, ISymbol>
NoNameCollisionOrError already rejects names that match EXACTLY. This is the
'too similar' companion to that rule, and follows the same opinion already applied to
enumerated values in BasicSymbolFactory.populateEnumeration - the same word in a
different case is highly likely to confuse a reader.
Beyond readability there is a hard failure behind this rule. Each module construct is
emitted to <simpleName>.class, so on a case-INSENSITIVE filesystem (macOS APFS by
default, Windows NTFS) fibonacci.class and Fibonacci.class are one file:
the second write silently clobbers the first, while the directory entry keeps the name the
first write created. The result compiles 100% clean and then dies at run time with
NoClassDefFoundError. Rejecting the pair up front removes that whole failure mode,
and keeps a build portable across case-sensitive and case-insensitive filesystems.
Note this deliberately normalises by CASE only. The enumerated-value rule also strips '_', but construct names legitimately use a leading underscore for synthetic/internal symbols, so stripping it here would over-fire.
-
Constructor Details
-
NoCaseVariantNameOrError
-
-
Method Details
-
test
Check the symbol being defined against those already defined in the same module. If this returns true then an error will have been added to the error listener.- Specified by:
testin interfaceBiPredicate<List<ISymbol>, ISymbol>- Parameters:
alreadyDefined- the symbols already defined in this module (all of its scopes).symbol- the symbol now being defined.
-