Class ConstantSymbol
- All Implemented Interfaces:
Serializable, ISymbol, ISymbolNature, ITokenReference
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConstantSymbol(String name) ConstantSymbol(String name, boolean fromLiteral) ConstantSymbol(String name, Optional<ISymbol> type) ConstantSymbol(String name, Optional<ISymbol> type, boolean fromLiteral) Construction of a Constant.ConstantSymbol(String name, ISymbol type) ConstantSymbol(String name, ISymbol type, boolean fromLiteral) -
Method Summary
Modifier and TypeMethodDescriptionClone the symbol and re-parent if this symbol like a method should have a parent.protected ConstantSymbolcloneIntoConstant(ConstantSymbol newCopy) booleanTwo symbols are the same symbol when they agree on name, category, genus, mutability AND the declaration site they came from.inthashCode()Mixes in exactly the fieldsSymbol.equals(Object)compares, and nothing else.booleanbooleantoString()Methods inherited from class Symbol
clearInitialisedBy, cloneIntoSymbol, copySymbolProperties, getAssignableCostTo, getAssignableCostTo, getCategory, getFriendlyName, getFullyQualifiedName, getGenus, getInitialisedBy, getName, getParsedModule, getProduceFullyQualifiedName, getSourceToken, getSquirrelledData, getSymbolTypeAsString, getType, getUnCoercedAssignableCostTo, isAssignableTo, isAssignableTo, isDevSource, isEk9Core, isExactSameType, isInjectionExpected, isLibSource, isMarkedPure, isMutable, isNullAllowed, isPromotionSupported, isReferenced, putSquirrelledData, setCategory, setEk9Core, setGenus, setInitialisedBy, setInjectionExpected, setMarkedPure, setName, setNotMutable, setNullAllowed, setParsedModule, setProduceFullyQualifiedName, setReferenced, setSourceToken, setTypeMethods inherited from interface ISymbol
isDeclaredAsConstant, isExtensionOfInjectable, isIncomingParameter, isInitialised, isInjectable, isLoopVariable, isMarkedAbstract, isPrivate, isPropertyField, isProtected, isPublic, isReturningParameter, setTypeMethods inherited from interface ISymbolNature
isApplication, isConceptualTypeParameter, isControl, isFunction, isGenericInNature, isMethod, isParameterisedType, isPrimitiveType, isTemplateFunction, isTemplateType, isType, isVariable
-
Constructor Details
-
ConstantSymbol
-
ConstantSymbol
-
ConstantSymbol
-
ConstantSymbol
-
ConstantSymbol
-
ConstantSymbol
-
-
Method Details
-
isFromLiteral
public boolean isFromLiteral() -
isConstant
public boolean isConstant() -
clone
Description copied from interface:ISymbolClone the symbol and re-parent if this symbol like a method should have a parent. Other symbols like VariableSymbols are un-parented -
cloneIntoConstant
-
equals
Description copied from class:SymbolTwo symbols are the same symbol when they agree on name, category, genus, mutability AND the declaration site they came from.The source token is part of identity deliberately. Name alone is not enough: symbol names are unqualified here, so two unrelated variables both called
count, or two types calledFooin different modules, would otherwise compare equal. The compiler relies on telling those apart -CodeFlowMapkeys initialisation state onMap<IScope, Map<ISymbol, SymbolAccess>>, and conflating two same-named declarations there makes flow analysis attribute one variable's initialisation to another.That distinction used to be present ONLY in
Symbol.hashCode(), which is why this looked like it worked: two same-named symbols compared equal yet hashed apart, so hash collections usually - but not reliably - kept them separate, while any directequalscall saw them as one. Encoding it here makes the two agree. SeeSymbolEqualsHashCodeContractTest. -
hashCode
public int hashCode()Description copied from class:SymbolMixes in exactly the fieldsSymbol.equals(Object)compares, and nothing else.A hashCode may legitimately use FEWER fields than equals (that only causes collisions, which are correct), but never MORE: any extra field makes two symbols that compare equal land in different buckets, so a HashSet silently holds visible duplicates and a HashMap lookup misses an entry that is present. This method used to mix in purity, which no equals at THIS level consults - purity belongs in
FunctionSymbol, the level whose equals compares it. The source token stays, and is now matched bySymbol.equals(Object). SeeSymbolEqualsHashCodeContractTest. -
toString
-