Correct diagnostics and quick-fix for T::class with non-reified type parameter #KT-9590 fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
998399bcd8
commit
2b63bcaa19
+1
-1
@@ -50,7 +50,7 @@ public class ReifiedTypeParameterSubstitutionChecker implements CallChecker {
|
||||
|
||||
if (argumentDeclarationDescriptor instanceof TypeParameterDescriptor &&
|
||||
!((TypeParameterDescriptor) argumentDeclarationDescriptor).isReified()) {
|
||||
context.getTrace().report(Errors.TYPE_PARAMETER_AS_REIFIED.on(reportErrorOn, parameter));
|
||||
context.getTrace().report(Errors.TYPE_PARAMETER_AS_REIFIED.on(reportErrorOn, (TypeParameterDescriptor) argumentDeclarationDescriptor));
|
||||
}
|
||||
else if (TypeUtilsKt.cannotBeReified(argument)) {
|
||||
context.getTrace().report(Errors.REIFIED_TYPE_FORBIDDEN_SUBSTITUTION.on(reportErrorOn, argument));
|
||||
|
||||
+9
-5
@@ -48,12 +48,11 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.Receiver
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.TransientReceiver
|
||||
import org.jetbrains.kotlin.resolve.source.toSourceElement
|
||||
import org.jetbrains.kotlin.types.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.KotlinTypeFactory
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.TypeUtils.NO_EXPECTED_TYPE
|
||||
import org.jetbrains.kotlin.types.expressions.typeInfoFactory.createTypeInfo
|
||||
import org.jetbrains.kotlin.types.typeUtil.isTypeParameter
|
||||
import java.lang.UnsupportedOperationException
|
||||
import javax.inject.Inject
|
||||
|
||||
sealed class DoubleColonLHS(val type: KotlinType) {
|
||||
@@ -119,7 +118,12 @@ class DoubleColonExpressionResolver(
|
||||
reportError = !isAllowedInClassLiteral(type)
|
||||
}
|
||||
|
||||
if (type.isMarkedNullable || reportError) {
|
||||
|
||||
val typeParameterDescriptor = TypeUtils.getTypeParameterDescriptorOrNull(type)
|
||||
if (type is SimpleType && !type.isMarkedNullable && typeParameterDescriptor != null && !typeParameterDescriptor.isReified) {
|
||||
c.trace.report(TYPE_PARAMETER_AS_REIFIED.on(expression, typeParameterDescriptor))
|
||||
}
|
||||
else if (type.isMarkedNullable || reportError) {
|
||||
c.trace.report(CLASS_LITERAL_LHS_NOT_A_CLASS.on(expression))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user