[FIR] Implement annotation checker for underscored type arguments

This commit is contained in:
Victor Petukhov
2021-10-26 15:40:59 +03:00
parent 697ef03d57
commit b29aeaa596
3 changed files with 81 additions and 0 deletions
@@ -1192,6 +1192,17 @@ fun FlyweightCapableTreeStructure<LighterASTNode>.inlineModifier(declaration: Li
fun FlyweightCapableTreeStructure<LighterASTNode>.typeParametersList(declaration: LighterASTNode): LighterASTNode? =
findChildByType(declaration, KtNodeTypes.TYPE_PARAMETER_LIST)
fun FlyweightCapableTreeStructure<LighterASTNode>.annotations(node: LighterASTNode): List<LighterASTNode>? {
val typeReference = findChildByType(node, KtNodeTypes.TYPE_REFERENCE) ?: return null
val modifiers = modifierList(typeReference) ?: return null
return collectDescendantsOfType(modifiers, KtNodeTypes.ANNOTATION_ENTRY)
}
fun FlyweightCapableTreeStructure<LighterASTNode>.userType(node: LighterASTNode): LighterASTNode? {
val typeReference = findChildByType(node, KtNodeTypes.TYPE_REFERENCE) ?: return null
return findChildByType(typeReference, KtNodeTypes.USER_TYPE)
}
private fun FlyweightCapableTreeStructure<LighterASTNode>.supertypesList(node: LighterASTNode): LighterASTNode? =
findChildByType(node, KtNodeTypes.SUPER_TYPE_LIST)