Report type inference error
when inference failed with 'NoInfer' annotation
This commit is contained in:
@@ -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")
|
||||
|
||||
|
||||
+2
-1
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user