FIR: make possible to use differently typed IDs in ScopeSession
This commit is contained in:
@@ -356,5 +356,5 @@ fun FqName.topLevelName() =
|
|||||||
asString().substringBefore(".")
|
asString().substringBefore(".")
|
||||||
|
|
||||||
|
|
||||||
private val JAVA_ENHANCEMENT = scopeSessionKey<JavaClassEnhancementScope>()
|
private val JAVA_ENHANCEMENT = scopeSessionKey<FirRegularClassSymbol, JavaClassEnhancementScope>()
|
||||||
private val JAVA_USE_SITE = scopeSessionKey<JavaClassUseSiteMemberScope>()
|
private val JAVA_USE_SITE = scopeSessionKey<FirRegularClassSymbol, JavaClassUseSiteMemberScope>()
|
||||||
|
|||||||
@@ -38,25 +38,25 @@ fun lookupSuperTypes(
|
|||||||
}
|
}
|
||||||
|
|
||||||
class ScopeSession {
|
class ScopeSession {
|
||||||
private val scopes = hashMapOf<FirClassifierSymbol<*>, HashMap<ScopeSessionKey<*>, FirScope>>()
|
private val scopes = hashMapOf<Any, HashMap<ScopeSessionKey<*, *>, FirScope>>()
|
||||||
fun <T : FirScope> getOrBuild(symbol: FirClassifierSymbol<*>, key: ScopeSessionKey<T>, build: () -> T): T {
|
fun <ID : Any, FS : FirScope> getOrBuild(id: ID, key: ScopeSessionKey<ID, FS>, build: () -> FS): FS {
|
||||||
return scopes.getOrPut(symbol) {
|
return scopes.getOrPut(id) {
|
||||||
hashMapOf()
|
hashMapOf()
|
||||||
}.getOrPut(key) {
|
}.getOrPut(key) {
|
||||||
build()
|
build()
|
||||||
} as T
|
} as FS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class ScopeSessionKey<T : FirScope>()
|
abstract class ScopeSessionKey<ID : Any, FS : FirScope>
|
||||||
|
|
||||||
inline fun <reified T : FirScope> scopeSessionKey(): ScopeSessionKey<T> {
|
inline fun <reified ID : Any, reified FS : FirScope> scopeSessionKey(): ScopeSessionKey<ID, FS> {
|
||||||
return object : ScopeSessionKey<T>() {}
|
return object : ScopeSessionKey<ID, FS>() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
val USE_SITE = scopeSessionKey<FirScope>()
|
val USE_SITE = scopeSessionKey<FirClassSymbol<*>, FirScope>()
|
||||||
|
|
||||||
data class SubstitutionScopeKey(val type: ConeClassLikeType) : ScopeSessionKey<FirClassSubstitutionScope>() {}
|
data class SubstitutionScopeKey(val type: ConeClassLikeType) : ScopeSessionKey<FirClassLikeSymbol<*>, FirClassSubstitutionScope>() {}
|
||||||
|
|
||||||
fun FirClassSymbol<*>.buildUseSiteMemberScope(useSiteSession: FirSession, builder: ScopeSession): FirScope? {
|
fun FirClassSymbol<*>.buildUseSiteMemberScope(useSiteSession: FirSession, builder: ScopeSession): FirScope? {
|
||||||
return when (this) {
|
return when (this) {
|
||||||
|
|||||||
+1
-1
@@ -76,7 +76,7 @@ class FirIntegerLiteralTypeScope(private val session: FirSession) : FirScope() {
|
|||||||
private val ALL_OPERATORS = FirIntegerOperator.Kind.values().map { it.operatorName to it }.toMap()
|
private val ALL_OPERATORS = FirIntegerOperator.Kind.values().map { it.operatorName to it }.toMap()
|
||||||
|
|
||||||
val ILT_SYMBOL: FirClassifierSymbol<*> = FirIntegerLiteralTypeClassifierSymbol
|
val ILT_SYMBOL: FirClassifierSymbol<*> = FirIntegerLiteralTypeClassifierSymbol
|
||||||
val SCOPE_SESSION_KEY = scopeSessionKey<FirIntegerLiteralTypeScope>()
|
val SCOPE_SESSION_KEY = scopeSessionKey<FirClassifierSymbol<*>, FirIntegerLiteralTypeScope>()
|
||||||
}
|
}
|
||||||
|
|
||||||
private val BINARY_OPERATOR_SYMBOLS = BINARY_OPERATOR_NAMES.map { name ->
|
private val BINARY_OPERATOR_SYMBOLS = BINARY_OPERATOR_NAMES.map { name ->
|
||||||
|
|||||||
Reference in New Issue
Block a user