FirUpperBoundViolatedChecker: code cleanup
This commit is contained in:
+3
-18
@@ -57,12 +57,9 @@ object FirUpperBoundViolatedChecker : FirQualifiedAccessChecker() {
|
|||||||
parameterPairs.mapValues { it.value.type }
|
parameterPairs.mapValues { it.value.type }
|
||||||
)
|
)
|
||||||
|
|
||||||
val canBeSkip = mutableSetOf<FirTypeParameterSymbol>()
|
|
||||||
|
|
||||||
parameterPairs.forEach { (proto, actual) ->
|
parameterPairs.forEach { (proto, actual) ->
|
||||||
if (actual.source == null) {
|
if (actual.source == null) {
|
||||||
// canBeSkip.add(proto) // inferred types report INAPPLICABLE_CANDIDATE in case of an error
|
// inferred types don't report INAPPLICABLE_CANDIDATE for type aliases!
|
||||||
// inferred types don't report INAPPLICABLE_CANDIDATE for typealiases!
|
|
||||||
return@forEach
|
return@forEach
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,7 +88,7 @@ object FirUpperBoundViolatedChecker : FirQualifiedAccessChecker() {
|
|||||||
// typealias A<G> = B<List<G>>
|
// typealias A<G> = B<List<G>>
|
||||||
// val a = A<Int>()
|
// val a = A<Int>()
|
||||||
when (calleeFir) {
|
when (calleeFir) {
|
||||||
is FirConstructor -> analyzeConstructorCall(functionCall, substitutor, typeCheckerContext, reporter, canBeSkip)
|
is FirConstructor -> analyzeConstructorCall(functionCall, substitutor, typeCheckerContext, reporter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,8 +96,7 @@ object FirUpperBoundViolatedChecker : FirQualifiedAccessChecker() {
|
|||||||
functionCall: FirQualifiedAccessExpression,
|
functionCall: FirQualifiedAccessExpression,
|
||||||
callSiteSubstitutor: ConeSubstitutor,
|
callSiteSubstitutor: ConeSubstitutor,
|
||||||
typeCheckerContext: AbstractTypeCheckerContext,
|
typeCheckerContext: AbstractTypeCheckerContext,
|
||||||
reporter: DiagnosticReporter,
|
reporter: DiagnosticReporter
|
||||||
canBeSkip: MutableSet<FirTypeParameterSymbol>
|
|
||||||
) {
|
) {
|
||||||
// holds Collection<Number> bound.
|
// holds Collection<Number> bound.
|
||||||
// note that if B used another type parameter here,
|
// note that if B used another type parameter here,
|
||||||
@@ -128,9 +124,7 @@ object FirUpperBoundViolatedChecker : FirQualifiedAccessChecker() {
|
|||||||
for (it in 0 until count) {
|
for (it in 0 until count) {
|
||||||
actualConstructor.typeArguments[it].safeAs<ConeSimpleKotlinType>()
|
actualConstructor.typeArguments[it].safeAs<ConeSimpleKotlinType>()
|
||||||
?.let { that ->
|
?.let { that ->
|
||||||
// if (!canBeSkip.contains(protoConstructor.typeParameters[it].symbol)) {
|
|
||||||
constructorsParameterPairs[protoConstructor.typeParameters[it].symbol] = that
|
constructorsParameterPairs[protoConstructor.typeParameters[it].symbol] = that
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,15 +223,6 @@ object FirUpperBoundViolatedChecker : FirQualifiedAccessChecker() {
|
|||||||
return AbstractTypeChecker.isSubtypeOf(typeCheckerContext, target, intersection)
|
return AbstractTypeChecker.isSubtypeOf(typeCheckerContext, target, intersection)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes the entries where either A? or B?
|
|
||||||
* is null and constructs a Map<A, B>.
|
|
||||||
*/
|
|
||||||
private fun <A, B> List<Pair<A?, B?>>.toMapWithoutNulls() = this
|
|
||||||
.filter { it.first != null && it.second != null }
|
|
||||||
.map { it.first!! to it.second!! }
|
|
||||||
.toMap()
|
|
||||||
|
|
||||||
private fun DiagnosticReporter.report(source: FirSourceElement?) {
|
private fun DiagnosticReporter.report(source: FirSourceElement?) {
|
||||||
source?.let {
|
source?.let {
|
||||||
report(FirErrors.UPPER_BOUND_VIOLATED.on(it))
|
report(FirErrors.UPPER_BOUND_VIOLATED.on(it))
|
||||||
|
|||||||
Reference in New Issue
Block a user