[FIR] Add NAME_IN_CONSTRAINT_IS_NOT_A_TYPE_PARAMETER check

This commit is contained in:
Andrey Zinovyev
2021-04-11 16:18:07 +00:00
committed by Space
parent ea22f4b681
commit 47407c4445
20 changed files with 373 additions and 16 deletions
@@ -0,0 +1,30 @@
/*
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.fir.declarations
import org.jetbrains.kotlin.fir.FirSourceElement
import org.jetbrains.kotlin.name.Name
/**
* Constraint without corresponding type argiment
*/
data class DanglingTypeConstraint(val name: Name, val source: FirSourceElement)
private object DanglingTypeConstraintsKey : FirDeclarationDataKey()
var <T> T.danglingTypeConstraints: List<DanglingTypeConstraint>?
where T : FirDeclaration, T : FirTypeParameterRefsOwner
by FirDeclarationDataRegistry.data(DanglingTypeConstraintsKey)
fun FirDeclaration.getDanglingTypeConstraintsOrEmpty(): List<DanglingTypeConstraint> {
val res = when (this) {
is FirRegularClass -> danglingTypeConstraints
is FirSimpleFunction -> danglingTypeConstraints
is FirProperty -> danglingTypeConstraints
else -> null
}
return res ?: emptyList()
}