Fix incorrect usages of @NotNull type parameters in project sources
^KT-36770 In progress
This commit is contained in:
+1
-1
@@ -301,7 +301,7 @@ class JvmSerializerExtension @JvmOverloads constructor(
|
||||
super.serializeErrorType(type, builder)
|
||||
}
|
||||
|
||||
private fun <K, V> getBinding(slice: SerializationMappingSlice<K, V>, key: K): V? =
|
||||
private fun <K : Any, V> getBinding(slice: SerializationMappingSlice<K, V>, key: K): V? =
|
||||
bindings.get(slice, key) ?: globalBindings.get(slice, key)
|
||||
|
||||
private inner class SignatureSerializer {
|
||||
|
||||
+5
-3
@@ -12,7 +12,9 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnosticFactory0
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors
|
||||
import org.jetbrains.kotlin.fir.declarations.FirErrorFunction
|
||||
import org.jetbrains.kotlin.fir.diagnostics.*
|
||||
import org.jetbrains.kotlin.fir.diagnostics.ConeDiagnostic
|
||||
import org.jetbrains.kotlin.fir.diagnostics.ConeSimpleDiagnostic
|
||||
import org.jetbrains.kotlin.fir.diagnostics.ConeStubDiagnostic
|
||||
import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind.*
|
||||
import org.jetbrains.kotlin.fir.expressions.FirErrorExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.FirErrorLoop
|
||||
@@ -48,7 +50,7 @@ class ErrorNodeDiagnosticCollectorComponent(collector: AbstractDiagnosticCollect
|
||||
|
||||
private fun reportFirDiagnostic(diagnostic: ConeDiagnostic, source: FirSourceElement, reporter: DiagnosticReporter) {
|
||||
val coneDiagnostic = when (diagnostic) {
|
||||
is ConeUnresolvedReferenceError -> FirErrors.UNRESOLVED_REFERENCE.on(source, diagnostic.name?.asString())
|
||||
is ConeUnresolvedReferenceError -> FirErrors.UNRESOLVED_REFERENCE.on(source, diagnostic.name?.asString() ?: "<No name>")
|
||||
is ConeUnresolvedSymbolError -> FirErrors.UNRESOLVED_REFERENCE.on(source, diagnostic.classId.asString())
|
||||
is ConeUnresolvedNameError -> FirErrors.UNRESOLVED_REFERENCE.on(source, diagnostic.name.asString())
|
||||
is ConeInapplicableCandidateError -> FirErrors.INAPPLICABLE_CANDIDATE.on(source, diagnostic.candidates.map { it.symbol })
|
||||
@@ -87,4 +89,4 @@ class ErrorNodeDiagnosticCollectorComponent(collector: AbstractDiagnosticCollect
|
||||
else -> throw IllegalArgumentException("Unsupported diagnostic kind: $kind at $javaClass")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+10
-10
@@ -24,18 +24,18 @@ sealed class FirSimpleDiagnostic<out E : FirSourceElement> : FirDiagnostic<E>()
|
||||
abstract override val factory: FirDiagnosticFactory0<*, *>
|
||||
}
|
||||
|
||||
sealed class FirDiagnosticWithParameters1<out E : FirSourceElement, A> : FirDiagnostic<E>() {
|
||||
sealed class FirDiagnosticWithParameters1<out E : FirSourceElement, A : Any> : FirDiagnostic<E>() {
|
||||
abstract val a: A
|
||||
abstract override val factory: FirDiagnosticFactory1<*, *, A>
|
||||
}
|
||||
|
||||
sealed class FirDiagnosticWithParameters2<out E : FirSourceElement, A, B> : FirDiagnostic<E>() {
|
||||
sealed class FirDiagnosticWithParameters2<out E : FirSourceElement, A : Any, B : Any> : FirDiagnostic<E>() {
|
||||
abstract val a: A
|
||||
abstract val b: B
|
||||
abstract override val factory: FirDiagnosticFactory2<*, *, A, B>
|
||||
}
|
||||
|
||||
sealed class FirDiagnosticWithParameters3<out E : FirSourceElement, A, B, C> : FirDiagnostic<E>() {
|
||||
sealed class FirDiagnosticWithParameters3<out E : FirSourceElement, A : Any, B : Any, C : Any> : FirDiagnostic<E>() {
|
||||
abstract val a: A
|
||||
abstract val b: B
|
||||
abstract val c: C
|
||||
@@ -59,7 +59,7 @@ data class FirPsiSimpleDiagnostic<P : PsiElement>(
|
||||
}
|
||||
}
|
||||
|
||||
data class FirPsiDiagnosticWithParameters1<P : PsiElement, A>(
|
||||
data class FirPsiDiagnosticWithParameters1<P : PsiElement, A : Any>(
|
||||
override val element: FirPsiSourceElement<P>,
|
||||
override val a: A,
|
||||
override val severity: Severity,
|
||||
@@ -70,7 +70,7 @@ data class FirPsiDiagnosticWithParameters1<P : PsiElement, A>(
|
||||
}
|
||||
}
|
||||
|
||||
data class FirPsiDiagnosticWithParameters2<P : PsiElement, A, B>(
|
||||
data class FirPsiDiagnosticWithParameters2<P : PsiElement, A : Any, B : Any>(
|
||||
override val element: FirPsiSourceElement<P>,
|
||||
override val a: A,
|
||||
override val b: B,
|
||||
@@ -82,7 +82,7 @@ data class FirPsiDiagnosticWithParameters2<P : PsiElement, A, B>(
|
||||
}
|
||||
}
|
||||
|
||||
data class FirPsiDiagnosticWithParameters3<P : PsiElement, A, B, C>(
|
||||
data class FirPsiDiagnosticWithParameters3<P : PsiElement, A : Any, B : Any, C : Any>(
|
||||
override val element: FirPsiSourceElement<P>,
|
||||
override val a: A,
|
||||
override val b: B,
|
||||
@@ -107,14 +107,14 @@ data class FirLightSimpleDiagnostic(
|
||||
override val factory: FirDiagnosticFactory0<*, *>
|
||||
) : FirSimpleDiagnostic<FirLightSourceElement>(), FirLightDiagnostic
|
||||
|
||||
data class FirLightDiagnosticWithParameters1<A>(
|
||||
data class FirLightDiagnosticWithParameters1<A : Any>(
|
||||
override val element: FirLightSourceElement,
|
||||
override val a: A,
|
||||
override val severity: Severity,
|
||||
override val factory: FirDiagnosticFactory1<*, *, A>
|
||||
) : FirDiagnosticWithParameters1<FirLightSourceElement, A>(), FirLightDiagnostic
|
||||
|
||||
data class FirLightDiagnosticWithParameters2<A, B>(
|
||||
data class FirLightDiagnosticWithParameters2<A : Any, B : Any>(
|
||||
override val element: FirLightSourceElement,
|
||||
override val a: A,
|
||||
override val b: B,
|
||||
@@ -122,11 +122,11 @@ data class FirLightDiagnosticWithParameters2<A, B>(
|
||||
override val factory: FirDiagnosticFactory2<*, *, A, B>
|
||||
) : FirDiagnosticWithParameters2<FirLightSourceElement, A, B>(), FirLightDiagnostic
|
||||
|
||||
data class FirLightDiagnosticWithParameters3<A, B, C>(
|
||||
data class FirLightDiagnosticWithParameters3<A : Any, B : Any, C : Any>(
|
||||
override val element: FirLightSourceElement,
|
||||
override val a: A,
|
||||
override val b: B,
|
||||
override val c: C,
|
||||
override val severity: Severity,
|
||||
override val factory: FirDiagnosticFactory3<*, *, A, B, C>
|
||||
) : FirDiagnosticWithParameters3<FirLightSourceElement, A, B, C>(), FirLightDiagnostic
|
||||
) : FirDiagnosticWithParameters3<FirLightSourceElement, A, B, C>(), FirLightDiagnostic
|
||||
|
||||
+3
-3
@@ -36,7 +36,7 @@ class FirDiagnosticFactory0<E : FirSourceElement, P : PsiElement>(
|
||||
}
|
||||
}
|
||||
|
||||
class FirDiagnosticFactory1<E : FirSourceElement, P : PsiElement, A>(
|
||||
class FirDiagnosticFactory1<E : FirSourceElement, P : PsiElement, A : Any>(
|
||||
name: String, severity: Severity, override val psiDiagnosticFactory: DiagnosticFactory1<P, A>
|
||||
) : AbstractFirDiagnosticFactory<E, FirDiagnosticWithParameters1<E, A>>(name, severity) {
|
||||
fun on(element: E, a: A): FirDiagnosticWithParameters1<E, A> {
|
||||
@@ -50,7 +50,7 @@ class FirDiagnosticFactory1<E : FirSourceElement, P : PsiElement, A>(
|
||||
}
|
||||
}
|
||||
|
||||
class FirDiagnosticFactory2<E : FirSourceElement, P : PsiElement, A, B>(
|
||||
class FirDiagnosticFactory2<E : FirSourceElement, P : PsiElement, A : Any, B : Any>(
|
||||
name: String, severity: Severity, override val psiDiagnosticFactory: DiagnosticFactory2<P, A, B>
|
||||
) : AbstractFirDiagnosticFactory<E, FirDiagnosticWithParameters2<E, A, B>>(name, severity) {
|
||||
fun on(element: E, a: A, b: B): FirDiagnosticWithParameters2<E, A, B> {
|
||||
@@ -64,7 +64,7 @@ class FirDiagnosticFactory2<E : FirSourceElement, P : PsiElement, A, B>(
|
||||
}
|
||||
}
|
||||
|
||||
class FirDiagnosticFactory3<E : FirSourceElement, P : PsiElement, A, B, C>(
|
||||
class FirDiagnosticFactory3<E : FirSourceElement, P : PsiElement, A : Any, B : Any, C : Any>(
|
||||
name: String, severity: Severity, override val psiDiagnosticFactory: DiagnosticFactory3<P, A, B, C>
|
||||
) : AbstractFirDiagnosticFactory<E, FirDiagnosticWithParameters3<E, A, B, C>>(name, severity) {
|
||||
fun on(element: E, a: A, b: B, c: C): FirDiagnosticWithParameters3<E, A, B, C> {
|
||||
|
||||
+13
-13
@@ -15,15 +15,15 @@ fun <E : FirSourceElement, P : PsiElement> warning0(): DiagnosticFactory0Delegat
|
||||
return DiagnosticFactory0DelegateProvider(Severity.WARNING, null)
|
||||
}
|
||||
|
||||
fun <E : FirSourceElement, P : PsiElement, A> warning1(): DiagnosticFactory1DelegateProvider<E, P, A> {
|
||||
fun <E : FirSourceElement, P : PsiElement, A : Any> warning1(): DiagnosticFactory1DelegateProvider<E, P, A> {
|
||||
return DiagnosticFactory1DelegateProvider(Severity.WARNING, null)
|
||||
}
|
||||
|
||||
fun <E : FirSourceElement, P : PsiElement, A, B> warning2(): DiagnosticFactory2DelegateProvider<E, P, A, B> {
|
||||
fun <E : FirSourceElement, P : PsiElement, A : Any, B : Any> warning2(): DiagnosticFactory2DelegateProvider<E, P, A, B> {
|
||||
return DiagnosticFactory2DelegateProvider(Severity.WARNING, null)
|
||||
}
|
||||
|
||||
fun <E : FirSourceElement, P : PsiElement, A, B, C> warning3(): DiagnosticFactory3DelegateProvider<E, P, A, B, C> {
|
||||
fun <E : FirSourceElement, P : PsiElement, A : Any, B : Any, C : Any> warning3(): DiagnosticFactory3DelegateProvider<E, P, A, B, C> {
|
||||
return DiagnosticFactory3DelegateProvider(Severity.WARNING, null)
|
||||
}
|
||||
|
||||
@@ -31,15 +31,15 @@ fun <E : FirSourceElement, P : PsiElement> error0(): DiagnosticFactory0DelegateP
|
||||
return DiagnosticFactory0DelegateProvider(Severity.ERROR, null)
|
||||
}
|
||||
|
||||
fun <E : FirSourceElement, P : PsiElement, A> error1(): DiagnosticFactory1DelegateProvider<E, P, A> {
|
||||
fun <E : FirSourceElement, P : PsiElement, A : Any> error1(): DiagnosticFactory1DelegateProvider<E, P, A> {
|
||||
return DiagnosticFactory1DelegateProvider(Severity.ERROR, null)
|
||||
}
|
||||
|
||||
fun <E : FirSourceElement, P : PsiElement, A, B> error2(): DiagnosticFactory2DelegateProvider<E, P, A, B> {
|
||||
fun <E : FirSourceElement, P : PsiElement, A : Any, B : Any> error2(): DiagnosticFactory2DelegateProvider<E, P, A, B> {
|
||||
return DiagnosticFactory2DelegateProvider(Severity.ERROR, null)
|
||||
}
|
||||
|
||||
fun <E : FirSourceElement, P : PsiElement, A, B, C> error3(): DiagnosticFactory3DelegateProvider<E, P, A, B, C> {
|
||||
fun <E : FirSourceElement, P : PsiElement, A : Any, B : Any, C : Any> error3(): DiagnosticFactory3DelegateProvider<E, P, A, B, C> {
|
||||
return DiagnosticFactory3DelegateProvider(Severity.ERROR, null)
|
||||
}
|
||||
|
||||
@@ -53,19 +53,19 @@ fun <E : FirSourceElement, P : PsiElement> existing(
|
||||
return DiagnosticFactory0DelegateProvider(Severity.ERROR, psiDiagnosticFactory)
|
||||
}
|
||||
|
||||
fun <E : FirSourceElement, P : PsiElement, A> existing(
|
||||
fun <E : FirSourceElement, P : PsiElement, A : Any> existing(
|
||||
psiDiagnosticFactory: DiagnosticFactory1<P, A>
|
||||
): DiagnosticFactory1DelegateProvider<E, P, A> {
|
||||
return DiagnosticFactory1DelegateProvider(Severity.ERROR, psiDiagnosticFactory)
|
||||
}
|
||||
|
||||
fun <E : FirSourceElement, P : PsiElement, A, B> existing(
|
||||
fun <E : FirSourceElement, P : PsiElement, A : Any, B : Any> existing(
|
||||
psiDiagnosticFactory: DiagnosticFactory2<P, A, B>
|
||||
): DiagnosticFactory2DelegateProvider<E, P, A, B> {
|
||||
return DiagnosticFactory2DelegateProvider(Severity.ERROR, psiDiagnosticFactory)
|
||||
}
|
||||
|
||||
fun <E : FirSourceElement, P : PsiElement, A, B, C> existing(
|
||||
fun <E : FirSourceElement, P : PsiElement, A : Any, B : Any, C : Any> existing(
|
||||
psiDiagnosticFactory: DiagnosticFactory3<P, A, B, C>
|
||||
): DiagnosticFactory3DelegateProvider<E, P, A, B, C> {
|
||||
return DiagnosticFactory3DelegateProvider(Severity.ERROR, psiDiagnosticFactory)
|
||||
@@ -85,7 +85,7 @@ class DiagnosticFactory0DelegateProvider<E : FirSourceElement, P : PsiElement>(
|
||||
}
|
||||
}
|
||||
|
||||
class DiagnosticFactory1DelegateProvider<E : FirSourceElement, P : PsiElement, A>(
|
||||
class DiagnosticFactory1DelegateProvider<E : FirSourceElement, P : PsiElement, A : Any>(
|
||||
private val severity: Severity,
|
||||
private val psiDiagnosticFactory: DiagnosticFactory1<P, A>?
|
||||
) {
|
||||
@@ -97,7 +97,7 @@ class DiagnosticFactory1DelegateProvider<E : FirSourceElement, P : PsiElement, A
|
||||
}
|
||||
}
|
||||
|
||||
class DiagnosticFactory2DelegateProvider<E : FirSourceElement, P : PsiElement, A, B>(
|
||||
class DiagnosticFactory2DelegateProvider<E : FirSourceElement, P : PsiElement, A : Any, B : Any>(
|
||||
private val severity: Severity,
|
||||
private val psiDiagnosticFactory: DiagnosticFactory2<P, A, B>?
|
||||
) {
|
||||
@@ -109,7 +109,7 @@ class DiagnosticFactory2DelegateProvider<E : FirSourceElement, P : PsiElement, A
|
||||
}
|
||||
}
|
||||
|
||||
class DiagnosticFactory3DelegateProvider<E : FirSourceElement, P : PsiElement, A, B, C>(
|
||||
class DiagnosticFactory3DelegateProvider<E : FirSourceElement, P : PsiElement, A : Any, B : Any, C : Any>(
|
||||
private val severity: Severity,
|
||||
private val psiDiagnosticFactory: DiagnosticFactory3<P, A, B, C>?
|
||||
) {
|
||||
@@ -125,4 +125,4 @@ private class DummyDelegate<T>(val value: T) : ReadOnlyProperty<Any?, T> {
|
||||
override fun getValue(thisRef: Any?, property: KProperty<*>): T {
|
||||
return value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -21,7 +21,7 @@ class FirDiagnosticFactoryToRendererMap(val name: String) {
|
||||
putToFirMap(factory)
|
||||
}
|
||||
|
||||
fun <A> put(
|
||||
fun <A : Any> put(
|
||||
factory: FirDiagnosticFactory1<*, *, A>,
|
||||
message: String,
|
||||
rendererA: DiagnosticParameterRenderer<A>?
|
||||
@@ -30,7 +30,7 @@ class FirDiagnosticFactoryToRendererMap(val name: String) {
|
||||
putToFirMap(factory)
|
||||
}
|
||||
|
||||
fun <A, B> put(
|
||||
fun <A : Any, B : Any> put(
|
||||
factory: FirDiagnosticFactory2<*, *, A, B>,
|
||||
message: String,
|
||||
rendererA: DiagnosticParameterRenderer<A>?,
|
||||
@@ -40,7 +40,7 @@ class FirDiagnosticFactoryToRendererMap(val name: String) {
|
||||
putToFirMap(factory)
|
||||
}
|
||||
|
||||
fun <A, B, C> put(
|
||||
fun <A : Any, B : Any, C : Any> put(
|
||||
factory: FirDiagnosticFactory3<*, *, A, B, C>,
|
||||
message: String,
|
||||
rendererA: DiagnosticParameterRenderer<A>?,
|
||||
@@ -56,4 +56,4 @@ class FirDiagnosticFactoryToRendererMap(val name: String) {
|
||||
diagnosticsMap[factory] = it
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ import org.jetbrains.kotlin.lexer.KtModifierKeywordToken
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
|
||||
object FirErrors {
|
||||
val UNRESOLVED_REFERENCE by error1<FirSourceElement, PsiElement, String?>()
|
||||
val UNRESOLVED_REFERENCE by error1<FirSourceElement, PsiElement, String>()
|
||||
val INAPPLICABLE_CANDIDATE by error1<FirSourceElement, PsiElement, Collection<AbstractFirBasedSymbol<*>>>()
|
||||
val AMBIGUITY by error1<FirSourceElement, PsiElement, Collection<AbstractFirBasedSymbol<*>>>()
|
||||
val ASSIGN_OPERATOR_AMBIGUITY by error1<FirSourceElement, PsiElement, Collection<AbstractFirBasedSymbol<*>>>()
|
||||
|
||||
+1
-1
@@ -310,7 +310,7 @@ class FirJvmSerializerExtension @JvmOverloads constructor(
|
||||
super.serializeErrorType(type, builder)
|
||||
}
|
||||
|
||||
private fun <K, V> getBinding(slice: JvmSerializationBindings.SerializationMappingSlice<K, V>, key: K): V? =
|
||||
private fun <K : Any, V : Any> getBinding(slice: JvmSerializationBindings.SerializationMappingSlice<K, V>, key: K): V? =
|
||||
bindings.get(slice, key) ?: globalBindings.get(slice, key)
|
||||
|
||||
private inner class SignatureSerializer {
|
||||
|
||||
@@ -62,16 +62,16 @@ class PsiErrorBuilder(
|
||||
diagnosticSink.report(diagnosticFactory.on(psiElement))
|
||||
}
|
||||
|
||||
fun <A> report(diagnosticFactory: DiagnosticFactory1<E, A>, a: A) {
|
||||
fun <A : Any> report(diagnosticFactory: DiagnosticFactory1<E, A>, a: A) {
|
||||
diagnosticSink.report(diagnosticFactory.on(psiElement, a))
|
||||
}
|
||||
|
||||
fun <A, B> report(diagnosticFactory: DiagnosticFactory2<E, A, B>, a: A, b: B) {
|
||||
fun <A : Any, B : Any> report(diagnosticFactory: DiagnosticFactory2<E, A, B>, a: A, b: B) {
|
||||
diagnosticSink.report(diagnosticFactory.on(psiElement, a, b))
|
||||
}
|
||||
|
||||
fun <A, B, C> report(diagnosticFactory: DiagnosticFactory3<E, A, B, C>, a: A, b: B, c: C) {
|
||||
fun <A : Any, B : Any, C : Any> report(diagnosticFactory: DiagnosticFactory3<E, A, B, C>, a: A, b: B, c: C) {
|
||||
diagnosticSink.report(diagnosticFactory.on(psiElement, a, b, c))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user