From 90628112316706acddda9d88883ec272272bd0a2 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Mon, 11 Mar 2019 15:24:27 +0300 Subject: [PATCH] [NI] Support `@OnlyInputTypes` annotation. #KT-29307 fixed Also KT-26698 fixed in new inference --- .../DiagnosticReporterByTrackingStrategy.kt | 6 ++++ .../components/ResultTypeResolver.kt | 5 ++- .../model/MutableConstraintStorage.kt | 16 +++++++++- .../model/NewConstraintSystemImpl.kt | 22 ++++++++++++- .../calls/inference/model/TypeVariable.kt | 11 +++++-- .../calls/model/KotlinCallDiagnostics.kt | 7 +++++ .../javaAnnotationWithVarargArgument.kt | 2 +- .../kotlinAnnotationWithVarargArgument.kt | 2 +- .../testsWithStdLib/cast/AsInsideIn.kt | 2 +- .../testsWithStdLib/commonCollections.kt | 8 ++--- .../annotationsForResolve/kt26698.kt | 22 +++++++++++++ .../annotationsForResolve/kt26698.txt | 27 ++++++++++++++++ .../annotationsForResolve/kt29307.kt | 31 +++++++++++++++++++ .../annotationsForResolve/kt29307.txt | 22 +++++++++++++ .../onlyInputTypesAndLowPriority.kt | 4 +-- .../resolveWithOnlyInputTypesAnnotation.kt | 2 +- .../java/concurrentHashMapContains.kt | 16 +++++----- .../java/concurrentHashMapContainsError.kt | 16 +++++----- .../DiagnosticsTestWithStdLibGenerated.java | 10 ++++++ ...ticsTestWithStdLibUsingJavacGenerated.java | 10 ++++++ 20 files changed, 210 insertions(+), 31 deletions(-) create mode 100644 compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt26698.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt26698.txt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt29307.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt29307.txt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/DiagnosticReporterByTrackingStrategy.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/DiagnosticReporterByTrackingStrategy.kt index 5561999c986..b5898d1c315 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/DiagnosticReporterByTrackingStrategy.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/DiagnosticReporterByTrackingStrategy.kt @@ -49,6 +49,12 @@ class DiagnosticReporterByTrackingStrategy( ) InstantiationOfAbstractClass::class.java -> tracingStrategy.instantiationOfAbstractClass(trace) AbstractSuperCall::class.java -> tracingStrategy.abstractSuperCall(trace) + OnlyInputTypesDiagnostic::class.java -> { + val typeVariable = (diagnostic as OnlyInputTypesDiagnostic).typeVariable as? TypeVariableFromCallableDescriptor ?: return + psiKotlinCall.psiCall.calleeExpression?.let { + trace.report(TYPE_INFERENCE_ONLY_INPUT_TYPES.on(it, typeVariable.originalTypeParameter)) + } + } } } diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/ResultTypeResolver.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/ResultTypeResolver.kt index d0c5ba94164..3fcaad6774f 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/ResultTypeResolver.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/ResultTypeResolver.kt @@ -18,13 +18,17 @@ package org.jetbrains.kotlin.resolve.calls.inference.components import org.jetbrains.kotlin.resolve.calls.NewCommonSuperTypeCalculator import org.jetbrains.kotlin.resolve.calls.inference.components.TypeVariableDirectionCalculator.ResolveDirection +import org.jetbrains.kotlin.resolve.calls.inference.model.ArgumentConstraintPosition import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintKind import org.jetbrains.kotlin.resolve.calls.inference.model.VariableWithConstraints import org.jetbrains.kotlin.resolve.calls.inference.model.checkConstraint +import org.jetbrains.kotlin.resolve.calls.model.OnlyInputTypesDiagnostic import org.jetbrains.kotlin.resolve.constants.IntegerValueTypeConstructor import org.jetbrains.kotlin.types.* +import org.jetbrains.kotlin.types.checker.NewKotlinTypeChecker import org.jetbrains.kotlin.types.checker.intersectTypes import org.jetbrains.kotlin.types.typeUtil.isPrimitiveNumberType +import org.jetbrains.kotlin.utils.addToStdlib.safeAs class ResultTypeResolver( val typeApproximator: TypeApproximator, @@ -53,7 +57,6 @@ class ResultTypeResolver( } else { c.resultType(superType, subType, variableWithConstraints) } - return result } diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/model/MutableConstraintStorage.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/model/MutableConstraintStorage.kt index 5cd03be9182..68272720ad7 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/model/MutableConstraintStorage.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/model/MutableConstraintStorage.kt @@ -5,12 +5,12 @@ package org.jetbrains.kotlin.resolve.calls.inference.model -import org.jetbrains.kotlin.resolve.calls.inference.components.NewTypeSubstitutor import org.jetbrains.kotlin.resolve.calls.inference.trimToSize import org.jetbrains.kotlin.resolve.calls.model.KotlinCallDiagnostic import org.jetbrains.kotlin.resolve.calls.tower.isSuccess import org.jetbrains.kotlin.types.TypeConstructor import org.jetbrains.kotlin.types.UnwrappedType +import org.jetbrains.kotlin.types.checker.NewCapturedType import kotlin.collections.ArrayList import kotlin.collections.LinkedHashMap @@ -27,6 +27,20 @@ class MutableVariableWithConstraints( return simplifiedConstraints!! } + // see @OnlyInputTypes annotation + val projectedInputCallTypes: Collection + get() = + mutableConstraints.filter { + val position = it.position.from + position is ArgumentConstraintPosition || position is ReceiverConstraintPosition || position is ExpectedTypeConstraintPosition + }.map { + val type = it.type + if (type is NewCapturedType) + type.constructor.projection.type.unwrap() + else + type + } + private val mutableConstraints = ArrayList(constraints) private var simplifiedConstraints: List? = null diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/model/NewConstraintSystemImpl.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/model/NewConstraintSystemImpl.kt index e15748af0be..d404f1773b1 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/model/NewConstraintSystemImpl.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/model/NewConstraintSystemImpl.kt @@ -13,12 +13,16 @@ import org.jetbrains.kotlin.resolve.calls.inference.components.KotlinConstraintS import org.jetbrains.kotlin.resolve.calls.inference.components.NewTypeSubstitutor import org.jetbrains.kotlin.resolve.calls.inference.components.ResultTypeResolver import org.jetbrains.kotlin.resolve.calls.model.KotlinCallDiagnostic +import org.jetbrains.kotlin.resolve.calls.model.OnlyInputTypesDiagnostic +import org.jetbrains.kotlin.types.IntersectionTypeConstructor import org.jetbrains.kotlin.types.StubType import org.jetbrains.kotlin.types.TypeConstructor import org.jetbrains.kotlin.types.UnwrappedType +import org.jetbrains.kotlin.types.checker.NewKotlinTypeChecker import org.jetbrains.kotlin.types.typeUtil.contains import org.jetbrains.kotlin.types.typeUtil.isUnit import org.jetbrains.kotlin.utils.SmartList +import org.jetbrains.kotlin.utils.addToStdlib.safeAs class NewConstraintSystemImpl( private val constraintInjector: ConstraintInjector, @@ -242,7 +246,8 @@ class NewConstraintSystemImpl( checkState(State.BUILDING, State.COMPLETION) constraintInjector.addInitialEqualityConstraint(this, variable.defaultType, resultType, FixVariableConstraintPosition(variable)) - notFixedTypeVariables.remove(variable.freshTypeConstructor) + val variableWithConstraints = notFixedTypeVariables.remove(variable.freshTypeConstructor) + checkOnlyInputTypesAnnotation(variableWithConstraints, resultType) for (variableWithConstraint in notFixedTypeVariables.values) { variableWithConstraint.removeConstrains { @@ -253,6 +258,21 @@ class NewConstraintSystemImpl( storage.fixedTypeVariables[variable.freshTypeConstructor] = resultType } + private fun checkOnlyInputTypesAnnotation( + variableWithConstraints: MutableVariableWithConstraints?, + resultType: UnwrappedType + ) { + if (variableWithConstraints == null || !variableWithConstraints.typeVariable.hasOnlyInputTypesAnnotation()) return + val resultTypeIsInputType = variableWithConstraints.projectedInputCallTypes.any { inputType -> + inputType.constructor.safeAs()?.let { constructor -> + constructor.supertypes.any { NewKotlinTypeChecker.equalTypes(resultType, it) } + } ?: NewKotlinTypeChecker.equalTypes(resultType, inputType) + } + if (!resultTypeIsInputType) { + addError(OnlyInputTypesDiagnostic(variableWithConstraints.typeVariable)) + } + } + // KotlinConstraintSystemCompleter.Context, PostponedArgumentsAnalyzer.Context override fun canBeProper(type: UnwrappedType): Boolean { checkState(State.BUILDING, State.COMPLETION) diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/model/TypeVariable.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/model/TypeVariable.kt index 0bbec1d3613..e8191fd8d77 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/model/TypeVariable.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/model/TypeVariable.kt @@ -22,6 +22,7 @@ import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor import org.jetbrains.kotlin.descriptors.annotations.Annotations import org.jetbrains.kotlin.resolve.calls.model.LambdaKotlinCallArgument import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns +import org.jetbrains.kotlin.resolve.descriptorUtil.hasOnlyInputTypesAnnotation import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.KotlinTypeFactory import org.jetbrains.kotlin.types.SimpleType @@ -52,15 +53,21 @@ sealed class NewTypeVariable(builtIns: KotlinBuiltIns, name: String) { nullable = false, memberScope = builtIns.any.unsubstitutedMemberScope ) + abstract fun hasOnlyInputTypesAnnotation(): Boolean + override fun toString() = freshTypeConstructor.toString() } class TypeVariableFromCallableDescriptor( val originalTypeParameter: TypeParameterDescriptor -) : NewTypeVariable(originalTypeParameter.builtIns, originalTypeParameter.name.identifier) +) : NewTypeVariable(originalTypeParameter.builtIns, originalTypeParameter.name.identifier) { + override fun hasOnlyInputTypesAnnotation(): Boolean = originalTypeParameter.hasOnlyInputTypesAnnotation() +} class TypeVariableForLambdaReturnType( val lambdaArgument: LambdaKotlinCallArgument, builtIns: KotlinBuiltIns, name: String -) : NewTypeVariable(builtIns, name) +) : NewTypeVariable(builtIns, name) { + override fun hasOnlyInputTypesAnnotation(): Boolean = false +} diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/model/KotlinCallDiagnostics.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/model/KotlinCallDiagnostics.kt index 933fa0386f1..363cb3c7da6 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/model/KotlinCallDiagnostics.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/model/KotlinCallDiagnostics.kt @@ -20,6 +20,7 @@ import org.jetbrains.kotlin.descriptors.CallableDescriptor import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor import org.jetbrains.kotlin.resolve.calls.components.CallableReferenceCandidate +import org.jetbrains.kotlin.resolve.calls.inference.model.NewTypeVariable import org.jetbrains.kotlin.resolve.calls.tower.ResolutionCandidateApplicability.* import org.jetbrains.kotlin.types.TypeConstructor import org.jetbrains.kotlin.types.UnwrappedType @@ -179,4 +180,10 @@ class ManyCandidatesCallDiagnostic( override fun report(reporter: DiagnosticReporter) { reporter.onCall(this) } +} + +class OnlyInputTypesDiagnostic(val typeVariable: NewTypeVariable) : KotlinCallDiagnostic(INAPPLICABLE) { + override fun report(reporter: DiagnosticReporter) { + reporter.onCall(this) + } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/javaAnnotationWithVarargArgument.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/javaAnnotationWithVarargArgument.kt index fe5c333ca20..00348297f80 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/javaAnnotationWithVarargArgument.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/javaAnnotationWithVarargArgument.kt @@ -6,6 +6,6 @@ public @interface A { } // FILE: b.kt -@A(*", "IGNORE")!>arrayOf(1, "b")) +@A(*arrayOf(1, "b")) fun test() { } diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/kotlinAnnotationWithVarargArgument.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/kotlinAnnotationWithVarargArgument.kt index c6d1912c46e..87eb60ef350 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/kotlinAnnotationWithVarargArgument.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/kotlinAnnotationWithVarargArgument.kt @@ -2,6 +2,6 @@ annotation class B(vararg val args: String) -@B(*", "IGNORE")!>arrayOf(1, "b")) +@B(*arrayOf(1, "b")) fun test() { } diff --git a/compiler/testData/diagnostics/testsWithStdLib/cast/AsInsideIn.kt b/compiler/testData/diagnostics/testsWithStdLib/cast/AsInsideIn.kt index 503938a0425..5936a24c965 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/cast/AsInsideIn.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/cast/AsInsideIn.kt @@ -4,7 +4,7 @@ interface A class B : A fun foo1(list: List, arg: B?): Boolean { // Type mismatch - return arg in list // resolved to extension + return arg in list // resolved to extension } fun foo2(list: List, arg: B?): Boolean { // FAKE: no cast needed diff --git a/compiler/testData/diagnostics/testsWithStdLib/commonCollections.kt b/compiler/testData/diagnostics/testsWithStdLib/commonCollections.kt index 4741203490a..ae8b9739896 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/commonCollections.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/commonCollections.kt @@ -4,7 +4,7 @@ import java.util.* fun foo() { val al = ArrayList() al.size - al.contains(1) + al.contains(1) al.contains("") al.remove("") @@ -12,7 +12,7 @@ fun foo() { val hs = HashSet() hs.size - hs.contains(1) + hs.contains(1) hs.contains("") hs.remove("") @@ -20,10 +20,10 @@ fun foo() { val hm = HashMap() hm.size - hm.containsKey(1) + hm.containsKey(1) hm.containsKey("") - hm[1] + hm[1] hm[""] hm.remove("") diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt26698.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt26698.kt new file mode 100644 index 00000000000..397477fbefb --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt26698.kt @@ -0,0 +1,22 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE +// !WITH_NEW_INFERENCE + +open class Base() +class CX : Base() +class CY : Base() + +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +fun <@kotlin.internal.OnlyInputTypes T> foo(a: T, b: T) {} + +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +fun <@kotlin.internal.OnlyInputTypes T : Any> fooA(a: T, b: T) {} + +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +fun <@kotlin.internal.OnlyInputTypes T : Base> fooB(a: T, b: T) {} + + +fun usage(x: CX, y: CY) { + foo(x, y) // expected err, got err + fooA(x, y) // expected err, got ok + fooB(x, y) // expected err, got ok +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt26698.txt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt26698.txt new file mode 100644 index 00000000000..2e81c5092fe --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt26698.txt @@ -0,0 +1,27 @@ +package + +@kotlin.Suppress(names = {"INVISIBLE_MEMBER", "INVISIBLE_REFERENCE"}) public fun foo(/*0*/ a: T, /*1*/ b: T): kotlin.Unit +@kotlin.Suppress(names = {"INVISIBLE_MEMBER", "INVISIBLE_REFERENCE"}) public fun fooA(/*0*/ a: T, /*1*/ b: T): kotlin.Unit +@kotlin.Suppress(names = {"INVISIBLE_MEMBER", "INVISIBLE_REFERENCE"}) public fun fooB(/*0*/ a: T, /*1*/ b: T): kotlin.Unit +public fun usage(/*0*/ x: CX, /*1*/ y: CY): kotlin.Unit + +public open class Base { + public constructor Base() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public final class CX : Base { + public constructor CX() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public final class CY : Base { + public constructor CY() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt29307.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt29307.kt new file mode 100644 index 00000000000..76e65fabb92 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt29307.kt @@ -0,0 +1,31 @@ +// !DIAGNOSTICS: -UNUSED_VARIABLE +// !WITH_NEW_INFERENCE +// ISSUE: KT-29307 + +fun test_1(map: Map) { + val x = map[42] // OK +} + +open class A + +class B : A() + +fun test_2(map: Map) { + val x = map[42] +} + +fun test_3(m: Map<*, String>) { + val x = m[42] // should be ok +} + +fun test_4(m: Map) { + val x = m.get(42) // should be ok +} + +fun test_5(map: Map, a: A) { + map.get(a) +} + +fun test_6(map: Map, b: B) { + map.get(b) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt29307.txt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt29307.txt new file mode 100644 index 00000000000..92e81b66668 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt29307.txt @@ -0,0 +1,22 @@ +package + +public fun test_1(/*0*/ map: kotlin.collections.Map): kotlin.Unit +public fun test_2(/*0*/ map: kotlin.collections.Map): kotlin.Unit +public fun test_3(/*0*/ m: kotlin.collections.Map<*, kotlin.String>): kotlin.Unit +public fun test_4(/*0*/ m: kotlin.collections.Map): kotlin.Unit +public fun test_5(/*0*/ map: kotlin.collections.Map, /*1*/ a: A): kotlin.Unit +public fun test_6(/*0*/ map: kotlin.collections.Map, /*1*/ b: B): kotlin.Unit + +public open class A { + public constructor A() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public final class B : A { + public constructor B() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAndLowPriority.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAndLowPriority.kt index c020f073a25..7d9bdfa88db 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAndLowPriority.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAndLowPriority.kt @@ -18,9 +18,9 @@ public fun Map.get1(key: Any?): Int = null!! public fun <@kotlin.internal.OnlyInputTypes K, V> Map.get1(key: K): V? = null!! fun test(map: Map) { - val a: Int = listOf(1).contains1("") + val a: Int = listOf(1).contains1("") val b: Boolean = listOf(1).contains1(1) - val c: String? = map.get1("") + val c: String? = map.get1("") val d: String? = map.get1(1) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/resolveWithOnlyInputTypesAnnotation.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/resolveWithOnlyInputTypesAnnotation.kt index e2c6f5d99e7..2dae2ca5f70 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/resolveWithOnlyInputTypesAnnotation.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/resolveWithOnlyInputTypesAnnotation.kt @@ -11,7 +11,7 @@ class D fun test1(a: A, b: B, c: C) { assertEquals1(a, b) - assertEquals1(b, c) + assertEquals1(b, c) assertEquals1(3, 3) assertEquals1(1 or 2, 2 or 1) diff --git a/compiler/testData/diagnostics/testsWithStdLib/java/concurrentHashMapContains.kt b/compiler/testData/diagnostics/testsWithStdLib/java/concurrentHashMapContains.kt index 548ff81ca33..f674d777f27 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/java/concurrentHashMapContains.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/java/concurrentHashMapContains.kt @@ -28,8 +28,8 @@ fun main() { "" in (hm as Map) "" !in (hm as Map) - 1 in (hm as Map) - 1 !in (hm as Map) + 1 in (hm as Map) + 1 !in (hm as Map) val a = A() "" in a @@ -44,8 +44,8 @@ fun main() { "" in (a as Map) "" !in (a as Map) - 1 in (a as Map) - 1 !in (a as Map) + 1 in (a as Map) + 1 !in (a as Map) val b = B() "" in b @@ -58,8 +58,8 @@ fun main() { "" in (b as Map) "" !in (b as Map) - 1 in (b as Map) - 1 !in (b as Map) + 1 in (b as Map) + 1 !in (b as Map) // Actually, we could've allow calls here because the owner explicitly declared as operator, but semantics is still weird val c = C() @@ -73,7 +73,7 @@ fun main() { "" in (c as Map) "" !in (c as Map) - 1 in (c as Map) - 1 !in (c as Map) + 1 in (c as Map) + 1 !in (c as Map) } diff --git a/compiler/testData/diagnostics/testsWithStdLib/java/concurrentHashMapContainsError.kt b/compiler/testData/diagnostics/testsWithStdLib/java/concurrentHashMapContainsError.kt index 042d8af1725..3af29d824a1 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/java/concurrentHashMapContainsError.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/java/concurrentHashMapContainsError.kt @@ -29,8 +29,8 @@ fun main() { "" in (hm as Map) "" !in (hm as Map) - 1 in (hm as Map) - 1 !in (hm as Map) + 1 in (hm as Map) + 1 !in (hm as Map) val a = A() "" in a @@ -45,8 +45,8 @@ fun main() { "" in (a as Map) "" !in (a as Map) - 1 in (a as Map) - 1 !in (a as Map) + 1 in (a as Map) + 1 !in (a as Map) val b = B() "" in b @@ -59,8 +59,8 @@ fun main() { "" in (b as Map) "" !in (b as Map) - 1 in (b as Map) - 1 !in (b as Map) + 1 in (b as Map) + 1 !in (b as Map) // Actually, we could've allow calls here because the owner explicitly declared as operator, but semantics is still weird val c = C() @@ -74,7 +74,7 @@ fun main() { "" in (c as Map) "" !in (c as Map) - 1 in (c as Map) - 1 !in (c as Map) + 1 in (c as Map) + 1 !in (c as Map) } diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java index 6e58a2da659..77e1eef8cca 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java @@ -2693,6 +2693,16 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/internalAnnotationsOnTypes.kt"); } + @TestMetadata("kt26698.kt") + public void testKt26698() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt26698.kt"); + } + + @TestMetadata("kt29307.kt") + public void testKt29307() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt29307.kt"); + } + @TestMetadata("noInferAndLowPriority.kt") public void testNoInferAndLowPriority() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/noInferAndLowPriority.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java index a37a0c19656..e5f69cbe5a7 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java @@ -2693,6 +2693,16 @@ public class DiagnosticsTestWithStdLibUsingJavacGenerated extends AbstractDiagno runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/internalAnnotationsOnTypes.kt"); } + @TestMetadata("kt26698.kt") + public void testKt26698() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt26698.kt"); + } + + @TestMetadata("kt29307.kt") + public void testKt29307() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt29307.kt"); + } + @TestMetadata("noInferAndLowPriority.kt") public void testNoInferAndLowPriority() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/noInferAndLowPriority.kt");