Report type inference error

when inference failed with 'NoInfer' annotation
This commit is contained in:
Svetlana Isakova
2015-10-17 16:37:01 +03:00
parent 5ab3dd1716
commit 4c85b69c88
4 changed files with 13 additions and 10 deletions
@@ -18,16 +18,16 @@ package org.jetbrains.kotlin.resolve.descriptorUtil
import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
import org.jetbrains.kotlin.descriptors.annotations.Annotated
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.types.JetType
private val NO_INFER_ANNOTATION_FQ_NAME = FqName("kotlin.internal.NoInfer")
public fun Annotated.hasNoInferAnnotation(): Boolean = annotations.hasAnnotation(NO_INFER_ANNOTATION_FQ_NAME)
public fun JetType.hasNoInferAnnotation(): Boolean = annotations.hasAnnotation(NO_INFER_ANNOTATION_FQ_NAME)
private val EXACT_ANNOTATION_FQ_NAME = FqName("kotlin.internal.Exact")
public fun Annotated.hasExactAnnotation(): Boolean = annotations.hasAnnotation(EXACT_ANNOTATION_FQ_NAME)
public fun JetType.hasExactAnnotation(): Boolean = annotations.hasAnnotation(EXACT_ANNOTATION_FQ_NAME)
private val LOW_PRIORITY_IN_OVERLOAD_RESOLUTION_FQ_NAME = FqName("kotlin.internal.LowPriorityInOverloadResolution")
@@ -293,7 +293,6 @@ public class ConstraintSystemImpl : ConstraintSystem {
if (isErrorOrSpecialType(subType, constraintPosition) || isErrorOrSpecialType(superType, constraintPosition)) return
if (subType == null || superType == null) return
if (subType.hasNoInferAnnotation() || superType.hasNoInferAnnotation()) return
if ((subType.hasExactAnnotation() || superType.hasExactAnnotation()) && (constraintKind != EQUAL)) {
return doAddConstraint(EQUAL, subType, superType, constraintContext, typeCheckingProcedure)
}
@@ -340,6 +339,8 @@ public class ConstraintSystemImpl : ConstraintSystem {
if (constraintContext.initial) {
storeInitialConstraint(constraintKind, subType, superType, constraintPosition)
}
if (subType.hasNoInferAnnotation() || superType.hasNoInferAnnotation()) return
simplifyConstraint(newSubType, superType)
}