Add raw type comparison for Java (J2K mapping is taken into account)
NB: Java enhancement scope does not perform substitution, so we could have some duplicates inside "type enhancement" testData Related to KT-29937
This commit is contained in:
+17
-5
@@ -5,6 +5,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.fir.java.scopes
|
||||
|
||||
import org.jetbrains.kotlin.builtins.jvm.JavaToKotlinClassMap
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.FirNamedFunction
|
||||
@@ -18,8 +19,8 @@ import org.jetbrains.kotlin.fir.symbols.ConeCallableSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.ConeFunctionSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.ConePropertySymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol
|
||||
import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
||||
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
||||
import org.jetbrains.kotlin.fir.typeContext
|
||||
import org.jetbrains.kotlin.fir.types.*
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
|
||||
class JavaClassUseSiteScope(
|
||||
@@ -33,10 +34,21 @@ class JavaClassUseSiteScope(
|
||||
//base symbol as key, overridden as value
|
||||
private val overriddenByBase = mutableMapOf<ConeFunctionSymbol, ConeFunctionSymbol?>()
|
||||
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
private val context: ConeTypeContext = session.typeContext
|
||||
|
||||
private fun isEqualTypes(a: ConeKotlinType, b: ConeKotlinType): Boolean {
|
||||
// TODO: introduce normal type comparison
|
||||
return true
|
||||
if (a is ConeFlexibleType) return isEqualTypes(a.lowerBound, b)
|
||||
if (b is ConeFlexibleType) return isEqualTypes(a, b.lowerBound)
|
||||
with(context) {
|
||||
if (a is ConeClassLikeType && b is ConeClassLikeType) {
|
||||
val aId = a.lookupTag.classId
|
||||
val bId = b.lookupTag.classId
|
||||
val aMapped = JavaToKotlinClassMap.mapJavaToKotlin(aId.asSingleFqName()) ?: aId
|
||||
val bMapped = JavaToKotlinClassMap.mapJavaToKotlin(bId.asSingleFqName()) ?: bId
|
||||
return aMapped == bMapped
|
||||
}
|
||||
return isEqualTypeConstructors(a.typeConstructor(), b.typeConstructor())
|
||||
}
|
||||
}
|
||||
|
||||
private fun isEqualTypes(a: FirTypeRef, b: FirTypeRef) =
|
||||
|
||||
@@ -14,4 +14,14 @@ import org.jetbrains.kotlin.name.ClassId
|
||||
|
||||
class FirClassSymbol(override val classId: ClassId) : ConeClassSymbol, AbstractFirBasedSymbol<FirRegularClass>() {
|
||||
override fun toLookupTag(): ConeClassLikeLookupTag = ConeClassLikeLookupTagImpl(classId)
|
||||
|
||||
override fun equals(other: Any?): Boolean =
|
||||
other is FirClassSymbol && classId == other.classId && fir == other.fir
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = 31
|
||||
result = result * 19 + classId.hashCode()
|
||||
result = result * 19 + fir.hashCode()
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,16 @@ class FirTypeAliasSymbol(
|
||||
override val classId: ClassId
|
||||
) : ConeTypeAliasSymbol, AbstractFirBasedSymbol<FirTypeAlias>() {
|
||||
override fun toLookupTag(): ConeClassLikeLookupTag = TypeAliasLookupTagImpl(classId)
|
||||
|
||||
override fun equals(other: Any?): Boolean =
|
||||
other is FirTypeAliasSymbol && classId == other.classId && fir == other.fir
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = 31
|
||||
result = result * 19 + classId.hashCode()
|
||||
result = result * 19 + fir.hashCode()
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
class TypeAliasLookupTagImpl(
|
||||
|
||||
@@ -19,4 +19,12 @@ class FirTypeParameterSymbol : AbstractFirBasedSymbol<FirTypeParameter>(), ConeT
|
||||
get() = this
|
||||
|
||||
override fun toLookupTag(): ConeTypeParameterLookupTag = this
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
return other is FirTypeParameterSymbol && fir == other.fir
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return fir.hashCode()
|
||||
}
|
||||
}
|
||||
|
||||
+2
@@ -1,4 +1,6 @@
|
||||
<K, V> public abstract interface SubclassOfMapEntry : R|java/util/Map.Entry<K, V>| {
|
||||
public abstract operator function setValue(value: R|ft<V, V?>|!): R|ft<V, V?>|!
|
||||
|
||||
public abstract operator function setValue(<anonymous Java parameter>: R|ft<V, V?>|!): R|ft<V, V?>|!
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user