Fix SOE related exact annotation and completion

This commit is contained in:
Stanislav Erokhin
2016-05-16 13:08:37 +03:00
parent 2d185dc7cf
commit f376c418dc
6 changed files with 35 additions and 7 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
* Copyright 2010-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -114,7 +114,7 @@ class ConstraintSystemBuilderImpl(private val mode: Mode = ConstraintSystemBuild
type.getNestedTypeParameters().mapNotNull { getMyTypeVariable(it) }
override fun addSubtypeConstraint(constrainingType: KotlinType?, subjectType: KotlinType?, constraintPosition: ConstraintPosition) {
addConstraint(SUB_TYPE, constrainingType, subjectType, ConstraintContext(constraintPosition, initial = true))
addConstraint(SUB_TYPE, constrainingType, subjectType, ConstraintContext(constraintPosition, initial = true, initialReduction = true))
}
fun addConstraint(
@@ -126,7 +126,8 @@ class ConstraintSystemBuilderImpl(private val mode: Mode = ConstraintSystemBuild
val constraintPosition = constraintContext.position
// when processing nested constraints, `derivedFrom` information should be reset
val newConstraintContext = ConstraintContext(constraintContext.position, derivedFrom = null, initial = false)
val newConstraintContext = ConstraintContext(constraintContext.position, derivedFrom = null, initial = false,
initialReduction = constraintContext.initialReduction)
val typeCheckingProcedure = TypeCheckingProcedure(object : TypeCheckingProcedureCallbacks {
private var depth = 0
@@ -194,7 +195,7 @@ class ConstraintSystemBuilderImpl(private val mode: Mode = ConstraintSystemBuild
if (isErrorOrSpecialType(subType, constraintPosition) || isErrorOrSpecialType(superType, constraintPosition)) return
if (subType == null || superType == null) return
if ((subType.hasExactAnnotation() || superType.hasExactAnnotation()) && (constraintKind != EQUAL)) {
if (constraintContext.initialReduction && (subType.hasExactAnnotation() || superType.hasExactAnnotation()) && (constraintKind != EQUAL)) {
return doAddConstraint(EQUAL, subType, superType, constraintContext, typeCheckingProcedure)
}
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
* Copyright 2010-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,7 +35,8 @@ data class ConstraintContext(
val position: ConstraintPosition,
// see TypeBounds.Bound.derivedFrom
val derivedFrom: Set<TypeVariable>? = null,
val initial: Boolean = false)
val initial: Boolean = false,
val initialReduction: Boolean = false)
fun ConstraintSystemBuilderImpl.incorporateBound(newBound: Bound) {
val typeVariable = newBound.typeVariable
@@ -94,7 +94,7 @@ abstract class AbstractConstraintSystemTest : KotlinTestWithEnvironment() {
for (constraint in constraints) {
val firstType = getType(constraint.firstType)
val secondType = getType(constraint.secondType)
val context = ConstraintContext(SPECIAL.position(), initial = true)
val context = ConstraintContext(SPECIAL.position(), initial = true, initialReduction = true)
when (constraint.kind) {
MyConstraintKind.SUBTYPE -> builder.addSubtypeConstraint(firstType, secondType, context.position)
MyConstraintKind.SUPERTYPE -> builder.addSubtypeConstraint(secondType, firstType, context.position)
@@ -0,0 +1,14 @@
import kotlin.internal.Exact
interface Column<out V>
inline fun <reified V : Enum<V>> String.enumeration(name: String): Column<V> = TODO()
fun <T> foo(c: Column<@Exact T>) { }
fun test() {
foo("".enu<caret>)
}
// EXIST: enumeration
@@ -2393,6 +2393,12 @@ public class JSBasicCompletionTestGenerated extends AbstractJSBasicCompletionTes
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/substitutedSignature/SubstitutedSignature6.kt");
doTest(fileName);
}
@TestMetadata("SubstitutedSignatureSOE.kt")
public void testSubstitutedSignatureSOE() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/substitutedSignature/SubstitutedSignatureSOE.kt");
doTest(fileName);
}
}
@TestMetadata("idea/idea-completion/testData/basic/common/super")
@@ -2393,6 +2393,12 @@ public class JvmBasicCompletionTestGenerated extends AbstractJvmBasicCompletionT
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/substitutedSignature/SubstitutedSignature6.kt");
doTest(fileName);
}
@TestMetadata("SubstitutedSignatureSOE.kt")
public void testSubstitutedSignatureSOE() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/substitutedSignature/SubstitutedSignatureSOE.kt");
doTest(fileName);
}
}
@TestMetadata("idea/idea-completion/testData/basic/common/super")