Class AggregateWithTraitsSymbol
- All Implemented Interfaces:
Serializable, IAggregateSymbol, ICanBeGeneric, ICanCaptureVariables, IScope, IScopedSymbol, ISymbol, ISymbolNature, ITokenReference
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface IScope
IScope.ScopeType -
Constructor Summary
ConstructorsConstructorDescriptionAggregateWithTraitsSymbol(String name, Optional<ISymbol> type, IScope enclosingScope) AggregateWithTraitsSymbol(String name, IScope enclosingScope) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAllowedExtender(IAggregateSymbol extenderSymbol) For use with constraining types to be limited to a declared set.voidaddTrait(AggregateWithTraitsSymbol traitSymbol) mark this aggregate as having additional 'trait'.Clone the symbol and re-parent if this symbol like a method should have a parent.protected AggregateWithTraitsSymbolbooleanTwo symbols are the same symbol when they agree on name, category, genus, mutability AND the declaration site they came from.Gets all abstract methods in this aggregate and any super classes.Gets all methods that are effective, by this I mean if supers (classes or traits) have the same method name but, it has been overridden then we would only retain the 'overridden' one as that has taken effect.Gets all sealed ancestors (traits AND super classes) that have extension constraints.Get all methods on this and any supers or traits.Get all methods not marked as abstract in this or any supers.getAllSymbolsMatchingName(String symbolName) Return a list of all the symbols that match the name.Get all the traits this aggregate implements - this means all the traits any of these traits extends.doubleGet the traits that this aggregates implements.doubleinthashCode()Mixes in exactly the fieldsSymbol.equals(Object)compares, and nothing else.booleanDoes this aggregate have the trait passed in as an immediate trait.booleanisAllowingExtensionBy(IAggregateSymbol extenderSymbol) Is the extender allowed to implement this aggregate (normally a trait).booleanbooleanisImplementingInSomeWay(IAggregateSymbol traitSymbol) Only really used by aggregates that can have one or more traits.resolveMatchingMethods(MethodSymbolSearch search, MethodSymbolSearchResult result) Looks in scope and parent scopes.resolveMember(SymbolSearch search) Just try and resolve a member in this or super scopes.resolveWithParentScope(SymbolSearch search) Resolve using super aggregate and or any traits we have.Methods inherited from class AggregateSymbol
addBlockCallEntry, addInjectionField, addRegistration, addTraitsIfNotPresent, cloneIntoAggregateSymbol, define, getAggregateDescription, getAllAbstractMethodsInThisScopeOnly, getAllMethodInThisScopeOnly, getAllNonAbstractMethodsInThisScopeOnly, getAllOperators, getAnySuperTypeOrFunction, getApplication, getBlockCallEntries, getConstraint, getConstructors, getFriendlyName, getInjectionFields, getPipeSinkType, getPipeSourceType, getProperties, getRegistrations, getSuperAggregate, getType, hasImmediateSuper, isExtensionOfInjectable, isInAggregateHierarchy, isInjectable, isMarkedAsDispatcher, methodNotPresent, methodsMatch, setAggregateDescription, setApplication, setConstraint, setInjectable, setMarkedAsDispatcher, setPipeSinkType, setPipeSourceType, setSuperAggregate, setSuperAggregate, setTypeMethods inherited from class PossibleGenericSymbol
addGenericSymbolReference, addTypeParameterOrArgument, cloneIntoPossibleGenericSymbol, getAnyConceptualTypeParameters, getAnyGenericParamsAsFriendlyNames, getDefinitionContext, getGenericSymbolReferences, getGenericType, getTypeParameterOrArguments, isConceptualTypeParameter, isGenericInNature, isOpenForExtension, isParameterisedType, resolve, resolveFromParameterTypes, resolveInThisScopeOnly, setConceptualTypeParameter, setDefinitionContext, setGenericType, setGenericType, setOpenForExtensionMethods inherited from class CaptureScopedSymbol
cloneIntoCaptureScopedSymbol, getCapturedVariables, getModuleScope, getPrivateVariablesForDisplay, isMarkedAbstract, resolveExcludingCapturedVariables, setCapturedVariables, setCapturedVariables, setCapturedVariablesVisibility, setMarkedAbstract, setModuleScopeMethods inherited from class ScopedSymbol
cloneIntoScopeSymbol, copyScopedSymbolProperties, findNearestDynamicBlockScopeInEnclosingScopes, findNearestNonBlockScopeInEnclosingScopes, getActualScope, getEnclosingScope, getEncounteredExceptionToken, getFriendlyScopeName, getOuterMostTypeOrFunction, getScopeName, getScopeType, getSymbolsForThisScope, isMarkedPure, isMutable, isNotMarkedPure, isScopeAMatchForEnclosingScope, isTerminatedNormally, resolveMatchingMethodsInThisScopeOnly, setEncounteredExceptionToken, setMarkedPure, setOuterMostTypeOrFunction, setScopeTypeMethods inherited from class Symbol
clearInitialisedBy, cloneIntoSymbol, copySymbolProperties, getAssignableCostTo, getCategory, getFullyQualifiedName, getGenus, getInitialisedBy, getName, getParsedModule, getProduceFullyQualifiedName, getSourceToken, getSquirrelledData, getSymbolTypeAsString, isAssignableTo, isAssignableTo, isDevSource, isEk9Core, isExactSameType, isInjectionExpected, isLibSource, isNullAllowed, isPromotionSupported, isReferenced, putSquirrelledData, setCategory, setEk9Core, setGenus, setInitialisedBy, setInjectionExpected, setName, setNotMutable, setNullAllowed, setParsedModule, setProduceFullyQualifiedName, setReferenced, setSourceToken, toStringMethods inherited from interface IAggregateSymbol
getName, getScopeTypeMethods inherited from interface ICanBeGeneric
addGenericSymbolReference, addTypeParameterOrArgument, getAnyConceptualTypeParameters, getGenericSymbolReferences, getGenericType, getTypeParameterOrArguments, isOpenForExtensionMethods inherited from interface IScope
findNearestDynamicBlockScopeInEnclosingScopes, findNearestNonBlockScopeInEnclosingScopes, getEnclosingScope, getEncounteredExceptionToken, getFriendlyScopeName, getScopeName, getSymbolsForThisScope, isMarkedPure, isScopeAMatchForEnclosingScope, isTerminatedNormally, resolve, resolveInThisScopeOnly, resolveMatchingMethodsInThisScopeOnly, setEncounteredExceptionTokenMethods inherited from interface ISymbol
clearInitialisedBy, getAssignableCostTo, getFullyQualifiedName, getInitialisedBy, getParsedModule, getSourceToken, getSquirrelledData, isAssignableTo, isAssignableTo, isDeclaredAsConstant, isDevSource, isExactSameType, isFromLiteral, isIncomingParameter, isInitialised, isInjectionExpected, isLibSource, isLoopVariable, isMarkedAbstract, isMarkedPure, isMutable, isNullAllowed, isPrivate, isPromotionSupported, isPropertyField, isProtected, isPublic, isReferenced, isReturningParameter, putSquirrelledData, setInitialisedBy, setInjectionExpected, setName, setNotMutable, setNullAllowed, setParsedModule, setReferenced, setTypeMethods inherited from interface ISymbolNature
getCategory, getGenus, isApplication, isConceptualTypeParameter, isConstant, isControl, isEk9Core, isFunction, isGenericInNature, isMethod, isParameterisedType, isPrimitiveType, isTemplateFunction, isTemplateType, isType, isVariable, setGenusMethods inherited from interface ITokenReference
setSourceToken
-
Constructor Details
-
AggregateWithTraitsSymbol
-
AggregateWithTraitsSymbol
-
-
Method Details
-
cloneIntoAggregateWithTraitsSymbol
protected AggregateWithTraitsSymbol cloneIntoAggregateWithTraitsSymbol(AggregateWithTraitsSymbol newCopy) -
addTrait
mark this aggregate as having additional 'trait'. -
hasImmediateTrait
Does this aggregate have the trait passed in as an immediate trait. i.e. one it implements itself. Note this is different from being compatible with the trait via hierarchy!- Parameters:
trait- The trait to check.- Returns:
- true if it does false otherwise.
-
addAllowedExtender
For use with constraining types to be limited to a declared set. -
getAllowedExtenders
-
isAllowingExtensionBy
Is the extender allowed to implement this aggregate (normally a trait).- Parameters:
extenderSymbol- The class (normally the one we are testing)- Returns:
- true if extending is allowed.
-
getAllSymbolsMatchingName
Description copied from interface:IScopeReturn a list of all the symbols that match the name. So for class and traits this must include supers and traits.- Specified by:
getAllSymbolsMatchingNamein interfaceIScope- Overrides:
getAllSymbolsMatchingNamein classAggregateSymbol
-
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- Specified by:
clonein interfaceIAggregateSymbol- Specified by:
clonein interfaceIScope- Specified by:
clonein interfaceIScopedSymbol- Specified by:
clonein interfaceISymbol- Overrides:
clonein classAggregateSymbol
-
getUnCoercedAssignableCostTo
- Specified by:
getUnCoercedAssignableCostToin interfaceISymbol- Overrides:
getUnCoercedAssignableCostToin classAggregateSymbol
-
getAssignableCostTo
- Specified by:
getAssignableCostToin interfaceISymbol- Overrides:
getAssignableCostToin classSymbol
-
isImplementingInSomeWay
Description copied from interface:IAggregateSymbolOnly really used by aggregates that can have one or more traits. But also super classes or super traits. So can either be implementing directly, super, super - super or traits and supe traits.- Specified by:
isImplementingInSomeWayin interfaceIAggregateSymbol- Overrides:
isImplementingInSomeWayin classAggregateSymbol
-
getTraits
Get the traits that this aggregates implements.- Returns:
- The list of traits.
-
getAllExtensionConstrainedTraits
Gets all sealed ancestors (traits AND super classes) that have extension constraints. Walks the full trait hierarchy AND the super class chain to find all ancestors where 'allow only' is declared. The caller checks whether this aggregate is permitted. -
getAllTraits
Get all the traits this aggregate implements - this means all the traits any of these traits extends. But also going up the class supers and getting those traits and any of the traits they extend.- Specified by:
getAllTraitsin interfaceIAggregateSymbol- Overrides:
getAllTraitsin classAggregateSymbol
-
getAllEffectiveMethods
Description copied from interface:IAggregateSymbolGets all methods that are effective, by this I mean if supers (classes or traits) have the same method name but, it has been overridden then we would only retain the 'overridden' one as that has taken effect. In the case of a trait that has multiple traits where the same method has been overridden in the trait only one method is now in effect. However, if there are multiple traits (or a super has the same method name) we would end up with 'duplicate' methods of the same name in this list 'CheckConflictingMethods' will need to detect this.- Specified by:
getAllEffectiveMethodsin interfaceIAggregateSymbol- Overrides:
getAllEffectiveMethodsin classAggregateSymbol- Returns:
- A List of methods that are in effect.
-
getAllMethods
Description copied from interface:IAggregateSymbolGet all methods on this and any supers or traits.- Specified by:
getAllMethodsin interfaceIAggregateSymbol- Overrides:
getAllMethodsin classAggregateSymbol- Returns:
- the list
-
getAllAbstractMethods
Gets all abstract methods in this aggregate and any super classes.- Specified by:
getAllAbstractMethodsin interfaceIAggregateSymbol- Overrides:
getAllAbstractMethodsin classAggregateSymbol- Returns:
- A list of all the methods marked as abstract.
-
isExtensionConstrained
public boolean isExtensionConstrained() -
getAllNonAbstractMethods
Description copied from interface:IAggregateSymbolGet all methods not marked as abstract in this or any supers.- Specified by:
getAllNonAbstractMethodsin interfaceIAggregateSymbol- Overrides:
getAllNonAbstractMethodsin classAggregateSymbol- Returns:
- The list.
-
resolveMatchingMethods
public MethodSymbolSearchResult resolveMatchingMethods(MethodSymbolSearch search, MethodSymbolSearchResult result) Description copied from interface:IScopeLooks in scope and parent scopes.- Specified by:
resolveMatchingMethodsin interfaceIAggregateSymbol- Specified by:
resolveMatchingMethodsin interfaceIScope- Overrides:
resolveMatchingMethodsin classAggregateSymbol
-
resolveMember
Description copied from class:AggregateSymbolJust try and resolve a member in this or super scopes.- Specified by:
resolveMemberin interfaceIAggregateSymbol- Specified by:
resolveMemberin interfaceIScope- Overrides:
resolveMemberin classAggregateSymbol
-
resolveWithParentScope
Resolve using super aggregate and or any traits we have. Look in our traits first then go to the normal AggregateSymbol resolution.- Overrides:
resolveWithParentScopein classScopedSymbol
-
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.- Overrides:
equalsin classAggregateSymbol
-
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.- Overrides:
hashCodein classAggregateSymbol
-