Search in sources :

Example 6 with VariableDescriptor

use of org.jetbrains.kotlin.descriptors.VariableDescriptor in project kotlin by JetBrains.

the class CompileTimeConstantUtils method checkConstructorParametersType.

public static void checkConstructorParametersType(@NotNull List<KtParameter> parameters, @NotNull BindingTrace trace) {
    for (KtParameter parameter : parameters) {
        VariableDescriptor parameterDescriptor = trace.getBindingContext().get(VALUE_PARAMETER, parameter);
        if (parameterDescriptor == null)
            continue;
        KotlinType parameterType = parameterDescriptor.getType();
        KtTypeReference typeReference = parameter.getTypeReference();
        if (typeReference != null) {
            if (parameterType.isMarkedNullable()) {
                trace.report(NULLABLE_TYPE_OF_ANNOTATION_MEMBER.on(typeReference));
            } else if (!isAcceptableTypeForAnnotationParameter(parameterType)) {
                trace.report(INVALID_TYPE_OF_ANNOTATION_MEMBER.on(typeReference));
            }
        }
    }
}
Also used : KotlinType(org.jetbrains.kotlin.types.KotlinType) KtParameter(org.jetbrains.kotlin.psi.KtParameter) KtTypeReference(org.jetbrains.kotlin.psi.KtTypeReference) VariableDescriptor(org.jetbrains.kotlin.descriptors.VariableDescriptor)

Aggregations

VariableDescriptor (org.jetbrains.kotlin.descriptors.VariableDescriptor)6 KotlinType (org.jetbrains.kotlin.types.KotlinType)3 ArrayList (java.util.ArrayList)2 DeclarationDescriptor (org.jetbrains.kotlin.descriptors.DeclarationDescriptor)2 PsiElement (com.intellij.psi.PsiElement)1 IElementType (com.intellij.psi.tree.IElementType)1 Collection (java.util.Collection)1 Map (java.util.Map)1 Unit (kotlin.Unit)1 NotNull (org.jetbrains.annotations.NotNull)1 JvmSerializerExtension (org.jetbrains.kotlin.codegen.serialization.JvmSerializerExtension)1 CallableDescriptor (org.jetbrains.kotlin.descriptors.CallableDescriptor)1 FunctionDescriptor (org.jetbrains.kotlin.descriptors.FunctionDescriptor)1 PropertyDescriptor (org.jetbrains.kotlin.descriptors.PropertyDescriptor)1 SimpleFunctionDescriptor (org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor)1 TypeAliasDescriptor (org.jetbrains.kotlin.descriptors.TypeAliasDescriptor)1 Diagnostic (org.jetbrains.kotlin.diagnostics.Diagnostic)1 DiagnosticFactory (org.jetbrains.kotlin.diagnostics.DiagnosticFactory)1 JsExpression (org.jetbrains.kotlin.js.backend.ast.JsExpression)1 JsName (org.jetbrains.kotlin.js.backend.ast.JsName)1