Class ResolveDefineInferredTypeListener
- All Implemented Interfaces:
org.antlr.v4.runtime.tree.ParseTreeListener, EK9Listener
This is a really critical point, because this attempts to ensure that ANY expression results in a symbol that has been 'typed'.
But it also has to 'resolve' types or 'generic types' and for inferred declarations must work out what the types are (hence previous expressions must now be 'typed'). It will also trigger the creations of new parameterised types, from generic types and type arguments, but 'just in time'.
Due to the ways that antlr employs listeners, breaking up the processing of listener events in to separate listeners in a type hierarchy seems to make most sense. But the bulk of any real actual processing is pulled out to separate functions and classes. So that these large and quite complex 'flows' can just focus on the event cycles and manage the scope stacks.
In general the listener methods in this class and it's supers are either very simple processing or just delegate the processing to a Function/Consumer to 'Process' or 'emit' compiler errors.
-
Field Summary
Fields inherited from class ExpressionsListener
errorListener, symbolFactoryFields inherited from class AbstractEK9PhaseListener
symbolsAndScopes -
Constructor Summary
ConstructorsConstructorDescriptionResolveDefineInferredTypeListener(ParsedModule parsedModule) Create a new instance to define or resolve inferred types. -
Method Summary
Modifier and TypeMethodDescriptionvoidEnter a parse tree produced byEK9Parser.classDeclaration().voidEnter a parse tree produced byEK9Parser.dynamicClassDeclaration().voidEnter a parse tree produced byEK9Parser.dynamicFunctionDeclaration().voidEnter a parse tree produced byEK9Parser.dynamicVariableCapture().voidIMPORTANT, because we automatically make supers of functions that meet specific signatures (where they don't have a super) it means that behind the scenes we alter a function to have a parameterised generic super function.voidEnter a parse tree produced byEK9Parser.parameterisedType().voidEnter a parse tree produced byEK9Parser.programBlock().voidEnter a parse tree produced byEK9Parser.traitDeclaration().voidEnter a parse tree produced byEK9Parser.typeDeclaration().voidExit a parse tree produced byEK9Parser.classDeclaration().voidExit a parse tree produced byEK9Parser.componentDeclaration().voidExit a parse tree produced byEK9Parser.dynamicClassDeclaration().voidExit a parse tree produced byEK9Parser.dynamicFunctionDeclaration().voidExit a parse tree produced byEK9Parser.dynamicVariableCapture().voidExit a parse tree produced byEK9Parser.functionDeclaration().voidExit a parse tree produced byEK9Parser.recordDeclaration().voidExit a parse tree produced byEK9Parser.registerStatement().voidExit a parse tree produced byEK9Parser.textDeclaration().voidExit a parse tree produced byEK9Parser.traitDeclaration().voidExit a parse tree produced byEK9Parser.typeDeclaration().Methods inherited from class ExpressionsListener
enterSwitchStatementExpression, enterTryStatementExpression, enterWhileStatementExpression, exitAssertDoesNotThrowExpression, exitAssertPanicExpression, exitAssertStatement, exitAssertThrowsExpression, exitAssignmentExpression, exitAssignmentStatement, exitCall, exitDict, exitExpression, exitForLoop, exitForRange, exitForStatementExpression, exitIdentifierReference, exitIfStatement, exitInstructionBlock, exitList, exitObjectAccessExpression, exitObjectAccessStart, exitPipelinePart, exitPreFlowStatement, exitPrimary, exitPrimaryReference, exitRange, exitRequireStatement, exitStatement, exitStreamCat, exitStreamExpression, exitStreamExpressionTermination, exitStreamFor, exitStreamStatement, exitStreamStatementTermination, exitSwitchStatementExpression, exitThrowStatement, exitTraitReference, exitTryStatementExpression, exitVariableDeclaration, exitVariableOnlyDeclaration, exitWhileStatementExpressionMethods inherited from class ScopeStackConsistencyListener
enterApplicationDeclaration, enterBlock, enterCatchStatementExpression, enterComponentDeclaration, enterFinallyStatementExpression, enterForStatementExpression, enterIfStatement, enterInstructionBlock, enterMethodDeclaration, enterOperatorDeclaration, enterPackageBlock, enterRecordDeclaration, enterReturningParam, enterServiceDeclaration, enterServiceOperationDeclaration, enterSingleStatementBlock, enterStreamExpression, enterStreamStatement, enterTernaryPart, enterTextBodyDeclaration, enterTextDeclarationMethods inherited from class AbstractEK9PhaseListener
exitApplicationDeclaration, exitBlock, exitCatchStatementExpression, exitFinallyStatementExpression, exitMethodDeclaration, exitModuleDeclaration, exitOperatorDeclaration, exitPackageBlock, exitReturningParam, exitServiceDeclaration, exitServiceOperationDeclaration, exitSingleStatementBlock, exitTernaryPart, exitTextBodyDeclaration, getErrorListener, getParsedModule, isScopeStackEmpty, pullBlockTerminationUp, pullIfElseTerminationUp, pullSwitchCaseDefaultUp, pullTryCatchFinallyUpMethods inherited from class EK9BaseListener
enterAccessModifier, enterAggregateParts, enterAggregateProperty, enterAllowingOnly, enterApplicationBlock, enterArgumentParam, enterAspectDeclaration, enterAssertDoesNotThrowExpression, enterAssertPanicExpression, enterAssertStatement, enterAssertThrowsExpression, enterAssignmentExpression, enterAssignmentStatement, enterBinaryLit, enterBinaryLiteral, enterBlockStatement, enterBooleanLit, enterBooleanLiteral, enterBytesLit, enterBytesLiteral, enterCall, enterCaseExpression, enterCaseStatement, enterCharacterLit, enterCharacterLiteral, enterClassBlock, enterColourLit, enterColourLiteral, enterCompilationUnit, enterComponentBlock, enterConstantBlock, enterConstantDeclaration, enterConstantInitialiser, enterConstrainDeclaration, enterConstrainType, enterDateLit, enterDateLiteral, enterDateTimeLit, enterDateTimeLiteral, enterDeclareArgumentParam, enterDecorationDimensionLiteral, enterDecorationResolutionLiteral, enterDefaultOperator, enterDict, enterDimensionLit, enterDirective, enterDirectivePart, enterDottedName, enterDurationLit, enterDurationLiteral, enterDynamicFunctionBody, enterElseOnlyBlock, enterEmptyBlock, enterEnumerationDeclaration, enterEveryRule, enterExcludedControlFlowStatement, enterExcludedInstantiation, enterExcludedListComprehension, enterExcludedLiteral, enterExcludedParameters, enterExpression, enterExpressionParam, enterExtendDeclaration, enterExtendPreamble, enterFloatingPointLit, enterFloatingPointLiteral, enterForLoop, enterForRange, enterFunctionBlock, enterHttpAccess, enterHttpVerb, enterIdentifier, enterIdentifierReference, enterIfControlBlock, enterInitValuePair, enterIntegerLit, enterIntegerLiteral, enterList, enterMillisecondLit, enterMillisecondLiteral, enterModuleBlock, enterModuleDeclaration, enterModuleSegment, enterMoneyLit, enterMoneyLiteral, enterNonIdentifierOperator, enterObjectAccess, enterObjectAccessExpression, enterObjectAccessStart, enterObjectAccessType, enterOperationCall, enterOperationDetails, enterOperator, enterParameterisedArgs, enterParameterisedDetail, enterParameterisedParams, enterParamExpression, enterPathLit, enterPathLiteral, enterPipelinePart, enterPreFlowAndControl, enterPreFlowStatement, enterPrimary, enterPrimaryReference, enterRange, enterRecordBlock, enterReferencesBlock, enterRegExLit, enterRegisterStatement, enterRegularExpressionLiteral, enterRequireStatement, enterReservedWord, enterResolutionLit, enterSecurityConstraint, enterServiceBlock, enterSheBang, enterStatement, enterStreamCat, enterStreamExpressionTermination, enterStreamFor, enterStreamPart, enterStreamSource, enterStreamStatementTermination, enterStringLit, enterStringLiteral, enterStringPart, enterTextBlock, enterThrowStatement, enterTimeLit, enterTimeLiteral, enterTraitBlock, enterTraitPreamble, enterTraitReference, enterTraitsList, enterTypeBlock, enterTypeDef, enterVariableDeclaration, enterVariableOnlyDeclaration, enterVersionNumberLit, enterVersionNumberLiteral, enterWebVariableCorrelation, exitAccessModifier, exitAggregateParts, exitAggregateProperty, exitAllowingOnly, exitApplicationBlock, exitArgumentParam, exitAspectDeclaration, exitBinaryLit, exitBinaryLiteral, exitBlockStatement, exitBooleanLit, exitBooleanLiteral, exitBytesLit, exitBytesLiteral, exitCaseExpression, exitCaseStatement, exitCharacterLit, exitCharacterLiteral, exitClassBlock, exitColourLit, exitColourLiteral, exitCompilationUnit, exitComponentBlock, exitConstantBlock, exitConstantDeclaration, exitConstantInitialiser, exitConstrainDeclaration, exitConstrainType, exitDateLit, exitDateLiteral, exitDateTimeLit, exitDateTimeLiteral, exitDeclareArgumentParam, exitDecorationDimensionLiteral, exitDecorationResolutionLiteral, exitDefaultOperator, exitDimensionLit, exitDirective, exitDirectivePart, exitDottedName, exitDurationLit, exitDurationLiteral, exitDynamicFunctionBody, exitElseOnlyBlock, exitEmptyBlock, exitEnumerationDeclaration, exitEveryRule, exitExcludedControlFlowStatement, exitExcludedInstantiation, exitExcludedListComprehension, exitExcludedLiteral, exitExcludedParameters, exitExpressionParam, exitExtendDeclaration, exitExtendPreamble, exitFloatingPointLit, exitFloatingPointLiteral, exitFunctionBlock, exitHttpAccess, exitHttpVerb, exitIdentifier, exitIfControlBlock, exitInitValuePair, exitIntegerLit, exitIntegerLiteral, exitMillisecondLit, exitMillisecondLiteral, exitModuleBlock, exitModuleSegment, exitMoneyLit, exitMoneyLiteral, exitNonIdentifierOperator, exitObjectAccess, exitObjectAccessType, exitOperationCall, exitOperationDetails, exitOperator, exitParameterisedArgs, exitParameterisedDetail, exitParameterisedParams, exitParameterisedType, exitParamExpression, exitPathLit, exitPathLiteral, exitPreFlowAndControl, exitProgramBlock, exitRecordBlock, exitReferencesBlock, exitRegExLit, exitRegularExpressionLiteral, exitReservedWord, exitResolutionLit, exitSecurityConstraint, exitServiceBlock, exitSheBang, exitStreamPart, exitStreamSource, exitStringLit, exitStringLiteral, exitStringPart, exitTextBlock, exitTimeLit, exitTimeLiteral, exitTraitBlock, exitTraitPreamble, exitTraitsList, exitTypeBlock, exitTypeDef, exitVersionNumberLit, exitVersionNumberLiteral, exitWebVariableCorrelation, visitErrorNode, visitTerminal
-
Constructor Details
-
ResolveDefineInferredTypeListener
ResolveDefineInferredTypeListener(ParsedModule parsedModule) Create a new instance to define or resolve inferred types.
-
-
Method Details
-
enterParameterisedType
Description copied from class:EK9BaseListenerEnter a parse tree produced byEK9Parser.parameterisedType().The default implementation does nothing.
- Specified by:
enterParameterisedTypein interfaceEK9Listener- Overrides:
enterParameterisedTypein classEK9BaseListener- Parameters:
ctx- the parse tree
-
enterDynamicVariableCapture
Description copied from class:EK9BaseListenerEnter a parse tree produced byEK9Parser.dynamicVariableCapture().The default implementation does nothing.
- Specified by:
enterDynamicVariableCapturein interfaceEK9Listener- Overrides:
enterDynamicVariableCapturein classScopeStackConsistencyListener- Parameters:
ctx- the parse tree
-
exitDynamicVariableCapture
Description copied from class:EK9BaseListenerExit a parse tree produced byEK9Parser.dynamicVariableCapture().The default implementation does nothing.
- Specified by:
exitDynamicVariableCapturein interfaceEK9Listener- Overrides:
exitDynamicVariableCapturein classAbstractEK9PhaseListener- Parameters:
ctx- the parse tree
-
enterTypeDeclaration
Description copied from class:EK9BaseListenerEnter a parse tree produced byEK9Parser.typeDeclaration().The default implementation does nothing.
- Specified by:
enterTypeDeclarationin interfaceEK9Listener- Overrides:
enterTypeDeclarationin classScopeStackConsistencyListener- Parameters:
ctx- the parse tree
-
exitRecordDeclaration
Description copied from class:EK9BaseListenerExit a parse tree produced byEK9Parser.recordDeclaration().The default implementation does nothing.
- Specified by:
exitRecordDeclarationin interfaceEK9Listener- Overrides:
exitRecordDeclarationin classAbstractEK9PhaseListener- Parameters:
ctx- the parse tree
-
enterClassDeclaration
Description copied from class:EK9BaseListenerEnter a parse tree produced byEK9Parser.classDeclaration().The default implementation does nothing.
- Specified by:
enterClassDeclarationin interfaceEK9Listener- Overrides:
enterClassDeclarationin classScopeStackConsistencyListener- Parameters:
ctx- the parse tree
-
exitClassDeclaration
Description copied from class:EK9BaseListenerExit a parse tree produced byEK9Parser.classDeclaration().The default implementation does nothing.
- Specified by:
exitClassDeclarationin interfaceEK9Listener- Overrides:
exitClassDeclarationin classAbstractEK9PhaseListener- Parameters:
ctx- the parse tree
-
enterDynamicClassDeclaration
Description copied from class:EK9BaseListenerEnter a parse tree produced byEK9Parser.dynamicClassDeclaration().The default implementation does nothing.
- Specified by:
enterDynamicClassDeclarationin interfaceEK9Listener- Overrides:
enterDynamicClassDeclarationin classScopeStackConsistencyListener- Parameters:
ctx- the parse tree
-
exitDynamicClassDeclaration
Description copied from class:EK9BaseListenerExit a parse tree produced byEK9Parser.dynamicClassDeclaration().The default implementation does nothing.
- Specified by:
exitDynamicClassDeclarationin interfaceEK9Listener- Overrides:
exitDynamicClassDeclarationin classAbstractEK9PhaseListener- Parameters:
ctx- the parse tree
-
enterTraitDeclaration
Description copied from class:EK9BaseListenerEnter a parse tree produced byEK9Parser.traitDeclaration().The default implementation does nothing.
- Specified by:
enterTraitDeclarationin interfaceEK9Listener- Overrides:
enterTraitDeclarationin classScopeStackConsistencyListener- Parameters:
ctx- the parse tree
-
exitTraitDeclaration
Description copied from class:EK9BaseListenerExit a parse tree produced byEK9Parser.traitDeclaration().The default implementation does nothing.
- Specified by:
exitTraitDeclarationin interfaceEK9Listener- Overrides:
exitTraitDeclarationin classAbstractEK9PhaseListener- Parameters:
ctx- the parse tree
-
exitComponentDeclaration
Description copied from class:EK9BaseListenerExit a parse tree produced byEK9Parser.componentDeclaration().The default implementation does nothing.
- Specified by:
exitComponentDeclarationin interfaceEK9Listener- Overrides:
exitComponentDeclarationin classAbstractEK9PhaseListener- Parameters:
ctx- the parse tree
-
enterFunctionDeclaration
IMPORTANT, because we automatically make supers of functions that meet specific signatures (where they don't have a super) it means that behind the scenes we alter a function to have a parameterised generic super function. But the initial (phase 3) creation does not fully populate all the types. (This is because we want to support inference in other areas). But it also means that the call to expand the arguments and types is done in two stages. Normally the second stage is done in the FULL_RESOLUTION when part of source that defines a parameterised type is processed again. But because these parameterised types are synthetically created it is important to expand them in on function entry. Because on exit there will be argument checks.- Specified by:
enterFunctionDeclarationin interfaceEK9Listener- Overrides:
enterFunctionDeclarationin classScopeStackConsistencyListener- Parameters:
ctx- the parse tree
-
exitFunctionDeclaration
Description copied from class:EK9BaseListenerExit a parse tree produced byEK9Parser.functionDeclaration().The default implementation does nothing.
- Specified by:
exitFunctionDeclarationin interfaceEK9Listener- Overrides:
exitFunctionDeclarationin classAbstractEK9PhaseListener- Parameters:
ctx- the parse tree
-
enterDynamicFunctionDeclaration
Description copied from class:EK9BaseListenerEnter a parse tree produced byEK9Parser.dynamicFunctionDeclaration().The default implementation does nothing.
- Specified by:
enterDynamicFunctionDeclarationin interfaceEK9Listener- Overrides:
enterDynamicFunctionDeclarationin classScopeStackConsistencyListener- Parameters:
ctx- the parse tree
-
exitDynamicFunctionDeclaration
Description copied from class:EK9BaseListenerExit a parse tree produced byEK9Parser.dynamicFunctionDeclaration().The default implementation does nothing.
- Specified by:
exitDynamicFunctionDeclarationin interfaceEK9Listener- Overrides:
exitDynamicFunctionDeclarationin classAbstractEK9PhaseListener- Parameters:
ctx- the parse tree
-
exitTextDeclaration
Description copied from class:EK9BaseListenerExit a parse tree produced byEK9Parser.textDeclaration().The default implementation does nothing.
- Specified by:
exitTextDeclarationin interfaceEK9Listener- Overrides:
exitTextDeclarationin classAbstractEK9PhaseListener- Parameters:
ctx- the parse tree
-
exitTypeDeclaration
Description copied from class:EK9BaseListenerExit a parse tree produced byEK9Parser.typeDeclaration().The default implementation does nothing.
- Specified by:
exitTypeDeclarationin interfaceEK9Listener- Overrides:
exitTypeDeclarationin classAbstractEK9PhaseListener- Parameters:
ctx- the parse tree
-
enterProgramBlock
Description copied from class:EK9BaseListenerEnter a parse tree produced byEK9Parser.programBlock().The default implementation does nothing.
- Specified by:
enterProgramBlockin interfaceEK9Listener- Overrides:
enterProgramBlockin classEK9BaseListener- Parameters:
ctx- the parse tree
-
exitRegisterStatement
Description copied from class:EK9BaseListenerExit a parse tree produced byEK9Parser.registerStatement().The default implementation does nothing.
- Specified by:
exitRegisterStatementin interfaceEK9Listener- Overrides:
exitRegisterStatementin classEK9BaseListener- Parameters:
ctx- the parse tree
-