[NI] Use alternative to intersection type in public declarations
The new inference uses inferred intersection types normally, unlike the old inference.
However, intersection types in public declarations are approximated to supertype, which
potentially may give a less presice type, then it would be with the OI.
For non-related T1, T2 the NI approximates {T1 & T2} to Any in public declarations,
and if the OI was inferring T1 instead of the intersection type, it may lead to
less precise declaration type and related errors.
The solution is to remember an alternative for an intersection type when present.
Before approximation the alternative replaces the intersection type.
^KT-36249 Fixed
This commit is contained in:
@@ -557,4 +557,11 @@ class ConeTypeCheckerContext(
|
||||
else
|
||||
ConeTypeCheckerContext(errorTypesEqualToAnything, stubTypesEqualToAnything, session)
|
||||
|
||||
override fun createTypeWithAlternativeForIntersectionResult(
|
||||
firstCandidate: KotlinTypeMarker,
|
||||
secondCandidate: KotlinTypeMarker
|
||||
): KotlinTypeMarker {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Generated
+83
@@ -10226,6 +10226,11 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
|
||||
runTest("compiler/testData/diagnostics/tests/inference/tooEagerSmartcast.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("topLevelIntersection.kt")
|
||||
public void testTopLevelIntersection() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/topLevelIntersection.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("tryNumberLowerBoundsBeforeUpperBounds.kt")
|
||||
public void testTryNumberLowerBoundsBeforeUpperBounds() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/tryNumberLowerBoundsBeforeUpperBounds.kt");
|
||||
@@ -11022,6 +11027,84 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/inference/publicApproximation")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class PublicApproximation extends AbstractFirOldFrontendDiagnosticsTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInPublicApproximation() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/inference/publicApproximation"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("approximatedIntersectionMorePreciseThanBound.kt")
|
||||
public void testApproximatedIntersectionMorePreciseThanBound() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/publicApproximation/approximatedIntersectionMorePreciseThanBound.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("chainedLambdas.kt")
|
||||
public void testChainedLambdas() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/publicApproximation/chainedLambdas.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("declarationTypes.kt")
|
||||
public void testDeclarationTypes() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/publicApproximation/declarationTypes.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("intersectionAfterSmartCastInLambdaReturn.kt")
|
||||
public void testIntersectionAfterSmartCastInLambdaReturn() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/publicApproximation/intersectionAfterSmartCastInLambdaReturn.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("intersectionAlternative.kt")
|
||||
public void testIntersectionAlternative() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/publicApproximation/intersectionAlternative.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("intersectionLocations.kt")
|
||||
public void testIntersectionLocations() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/publicApproximation/intersectionLocations.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lambdaReturnArgumentCall.kt")
|
||||
public void testLambdaReturnArgumentCall() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/publicApproximation/lambdaReturnArgumentCall.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lambdaReturnTypeApproximation.kt")
|
||||
public void testLambdaReturnTypeApproximation() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/publicApproximation/lambdaReturnTypeApproximation.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nonTrivialVariance.kt")
|
||||
public void testNonTrivialVariance() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/publicApproximation/nonTrivialVariance.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("parameterInBound.kt")
|
||||
public void testParameterInBound() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/publicApproximation/parameterInBound.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("projections.kt")
|
||||
public void testProjections() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/publicApproximation/projections.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("smartCastInLambdaReturnAfterIntersection.kt")
|
||||
public void testSmartCastInLambdaReturnAfterIntersection() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/publicApproximation/smartCastInLambdaReturnAfterIntersection.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("twoIntersections.kt")
|
||||
public void testTwoIntersections() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/publicApproximation/twoIntersections.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/inference/recursiveCalls")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
+5
@@ -1901,6 +1901,11 @@ public class FirOldFrontendDiagnosticsTestWithStdlibGenerated extends AbstractFi
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/inference/kt35847.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt36249.kt")
|
||||
public void testKt36249() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/inference/kt36249.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt4975.kt")
|
||||
public void testKt4975() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/inference/kt4975.kt");
|
||||
|
||||
@@ -113,15 +113,14 @@ fun getErasedReceiverType(receiverParameterDescriptor: ReceiverParameterDescript
|
||||
fakeTypeArguments.add(TypeProjectionImpl(typeProjection.projectionKind, DONT_CARE))
|
||||
}
|
||||
|
||||
val receiverTypeConstructor = if (receiverType.constructor is IntersectionTypeConstructor) {
|
||||
val superTypesWithFakeArguments = receiverType.constructor.supertypes.map { supertype ->
|
||||
val oldReceiverTypeConstructor = receiverType.constructor
|
||||
val receiverTypeConstructor = if (oldReceiverTypeConstructor is IntersectionTypeConstructor) {
|
||||
oldReceiverTypeConstructor.transformComponents { supertype ->
|
||||
val fakeArguments = supertype.arguments.map { TypeProjectionImpl(it.projectionKind, DONT_CARE) }
|
||||
supertype.replace(fakeArguments)
|
||||
}
|
||||
|
||||
IntersectionTypeConstructor(superTypesWithFakeArguments)
|
||||
} ?: oldReceiverTypeConstructor
|
||||
} else {
|
||||
receiverType.constructor
|
||||
oldReceiverTypeConstructor
|
||||
}
|
||||
|
||||
return KotlinTypeFactory.simpleTypeWithNonTrivialMemberScope(
|
||||
|
||||
-2
@@ -34,8 +34,6 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.ImplicitReceiver
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
import org.jetbrains.kotlin.types.checker.TypeIntersector
|
||||
import org.jetbrains.kotlin.types.checker.intersectTypes
|
||||
import org.jetbrains.kotlin.types.checker.intersectWrappedTypes
|
||||
import org.jetbrains.kotlin.types.typeUtil.expandIntersectionTypeIfNecessary
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
|
||||
+8
-4
@@ -106,12 +106,16 @@ interface NewTypeSubstitutor: TypeSubstitutorMarker {
|
||||
}
|
||||
|
||||
if (typeConstructor is IntersectionTypeConstructor) {
|
||||
var thereIsChanges = false
|
||||
fun updateNullability(substituted: UnwrappedType) =
|
||||
if (type.isMarkedNullable) substituted.makeNullableAsSpecified(true) else substituted
|
||||
|
||||
substituteNotNullTypeWithConstructor(typeConstructor)?.let { return updateNullability(it) }
|
||||
var thereAreChanges = false
|
||||
val newTypes = typeConstructor.supertypes.map {
|
||||
substitute(it.unwrap(), keepAnnotation, runCapturedChecks)?.apply { thereIsChanges = true } ?: it.unwrap()
|
||||
substitute(it.unwrap(), keepAnnotation, runCapturedChecks)?.apply { thereAreChanges = true } ?: it.unwrap()
|
||||
}
|
||||
if (!thereIsChanges) return null
|
||||
return intersectTypes(newTypes).let { if (type.isMarkedNullable) it.makeNullableAsSpecified(true) else it }
|
||||
if (!thereAreChanges) return null
|
||||
return updateNullability(intersectTypes(newTypes))
|
||||
}
|
||||
|
||||
// simple classifier type
|
||||
|
||||
+21
-2
@@ -19,8 +19,7 @@ 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.*
|
||||
import org.jetbrains.kotlin.types.AbstractTypeApproximator
|
||||
import org.jetbrains.kotlin.types.TypeApproximatorConfiguration
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.model.*
|
||||
|
||||
class ResultTypeResolver(
|
||||
@@ -65,6 +64,10 @@ class ResultTypeResolver(
|
||||
): KotlinTypeMarker? {
|
||||
if (firstCandidate == null || secondCandidate == null) return firstCandidate ?: secondCandidate
|
||||
|
||||
specialResultForIntersectionType(firstCandidate, secondCandidate)?.let { intersectionWithAlternative ->
|
||||
return intersectionWithAlternative
|
||||
}
|
||||
|
||||
if (isSuitableType(firstCandidate, variableWithConstraints)) return firstCandidate
|
||||
|
||||
return if (isSuitableType(secondCandidate, variableWithConstraints)) {
|
||||
@@ -74,6 +77,22 @@ class ResultTypeResolver(
|
||||
}
|
||||
}
|
||||
|
||||
private fun Context.specialResultForIntersectionType(
|
||||
firstCandidate: KotlinTypeMarker,
|
||||
secondCandidate: KotlinTypeMarker,
|
||||
): KotlinTypeMarker? {
|
||||
if (firstCandidate.typeConstructor() is IntersectionTypeConstructor) {
|
||||
if (!AbstractTypeChecker.isSubtypeOf(this, firstCandidate.toPublicType(), secondCandidate.toPublicType())) {
|
||||
return createTypeWithAlternativeForIntersectionResult(firstCandidate, secondCandidate)
|
||||
}
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
private fun KotlinTypeMarker.toPublicType(): KotlinTypeMarker =
|
||||
typeApproximator.approximateToSuperType(this, TypeApproximatorConfiguration.PublicDeclaration) ?: this
|
||||
|
||||
private fun Context.isSuitableType(resultType: KotlinTypeMarker, variableWithConstraints: VariableWithConstraints): Boolean {
|
||||
val filteredConstraints = variableWithConstraints.constraints.filter { isProperType(it.type) }
|
||||
for (constraint in filteredConstraints) {
|
||||
|
||||
+1
-3
@@ -13,9 +13,7 @@ import org.jetbrains.kotlin.resolve.calls.inference.components.ResultTypeResolve
|
||||
import org.jetbrains.kotlin.resolve.calls.model.KotlinCallDiagnostic
|
||||
import org.jetbrains.kotlin.resolve.calls.model.OnlyInputTypesDiagnostic
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedAtom
|
||||
import org.jetbrains.kotlin.types.AbstractTypeChecker
|
||||
import org.jetbrains.kotlin.types.IntersectionTypeConstructor
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.checker.NewKotlinTypeChecker
|
||||
import org.jetbrains.kotlin.types.model.*
|
||||
import org.jetbrains.kotlin.utils.SmartList
|
||||
|
||||
@@ -115,7 +115,8 @@ class TypeApproximator(builtIns: KotlinBuiltIns) : AbstractTypeApproximator(Clas
|
||||
if (!languageVersionSettings.supportsFeature(LanguageFeature.NewInference)) return baseType.unwrap()
|
||||
|
||||
val configuration = if (local) TypeApproximatorConfiguration.LocalDeclaration else TypeApproximatorConfiguration.PublicDeclaration
|
||||
return approximateToSuperType(baseType.unwrap(), configuration) ?: baseType.unwrap()
|
||||
val preparedType = if (local) baseType.unwrap() else substituteAlternativesInPublicType(baseType)
|
||||
return approximateToSuperType(preparedType, configuration) ?: preparedType
|
||||
}
|
||||
|
||||
// null means that this input type is the result, i.e. input type not contains not-allowed kind of types
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.types
|
||||
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.components.NewTypeSubstitutor
|
||||
import org.jetbrains.kotlin.types.typeUtil.contains
|
||||
|
||||
fun substituteAlternativesInPublicType(type: KotlinType): UnwrappedType {
|
||||
val substitutor = object : NewTypeSubstitutor {
|
||||
override fun substituteNotNullTypeWithConstructor(constructor: TypeConstructor): UnwrappedType? {
|
||||
if (constructor is IntersectionTypeConstructor) {
|
||||
constructor.getAlternativeType()?.let { alternative ->
|
||||
return safeSubstitute(alternative.unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
override val isEmpty: Boolean by lazy {
|
||||
!type.contains { it.constructor is IntersectionTypeConstructor }
|
||||
}
|
||||
}
|
||||
|
||||
return substitutor.safeSubstitute(type.unwrap())
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// !LANGUAGE: +NewInference
|
||||
|
||||
interface Bound {
|
||||
fun foo() {}
|
||||
}
|
||||
interface Bound1 : Bound
|
||||
interface Bound2 : Bound
|
||||
object First : Bound1, Bound2
|
||||
object Second : Bound1, Bound2
|
||||
|
||||
class Out<out O>(val param: O)
|
||||
|
||||
fun <S : Any> anyBound(vararg elements: S): Out<S> = TODO()
|
||||
fun topLevel() = anyBound(First, Second)
|
||||
|
||||
fun test() {
|
||||
topLevel().param.foo()
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ S : kotlin.Any> anyBound(/*0*/ vararg elements: S /*kotlin.Array<out S>*/): Out<S>
|
||||
public fun test(): kotlin.Unit
|
||||
public fun topLevel(): Out<Bound>
|
||||
|
||||
public interface Bound {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open fun foo(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface Bound1 : Bound {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun foo(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface Bound2 : Bound {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun foo(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public object First : Bound1, Bound2 {
|
||||
private constructor First()
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun foo(): kotlin.Unit
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class Out</*0*/ out O> {
|
||||
public constructor Out</*0*/ out O>(/*0*/ param: O)
|
||||
public final val param: O
|
||||
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 object Second : Bound1, Bound2 {
|
||||
private constructor Second()
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun foo(): kotlin.Unit
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// !WITH_NEW_INFERENCE
|
||||
// NI_EXPECTED_FILE
|
||||
|
||||
interface First {
|
||||
fun first() {}
|
||||
}
|
||||
interface Second
|
||||
interface Third
|
||||
interface Fourth
|
||||
|
||||
fun chained1(arg: First) = run {
|
||||
if (arg !is Second) throw Exception()
|
||||
arg
|
||||
}.let { third ->
|
||||
if (third !is Third) throw Exception()
|
||||
third
|
||||
}
|
||||
|
||||
fun chained2(arg: First) = run {
|
||||
if (arg !is Second) throw Exception()
|
||||
arg
|
||||
}.let { third ->
|
||||
if (third !is Third) throw Exception()
|
||||
third
|
||||
}.let { fourth ->
|
||||
if (fourth !is Fourth) throw Exception()
|
||||
fourth
|
||||
}
|
||||
|
||||
fun test(arg: First) {
|
||||
chained1(arg).first()
|
||||
chained2(arg).first()
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// !WITH_NEW_INFERENCE
|
||||
// NI_EXPECTED_FILE
|
||||
|
||||
interface First {
|
||||
fun first() {}
|
||||
}
|
||||
interface Second
|
||||
interface Third
|
||||
interface Fourth
|
||||
|
||||
fun chained1(arg: First) = run {
|
||||
if (arg !is Second) throw Exception()
|
||||
arg
|
||||
}.let { third ->
|
||||
if (third !is Third) throw Exception()
|
||||
third
|
||||
}
|
||||
|
||||
fun chained2(arg: First) = run {
|
||||
if (arg !is Second) throw Exception()
|
||||
arg
|
||||
}.let { third ->
|
||||
if (third !is Third) throw Exception()
|
||||
third
|
||||
}.let { fourth ->
|
||||
if (fourth !is Fourth) throw Exception()
|
||||
fourth
|
||||
}
|
||||
|
||||
fun test(arg: First) {
|
||||
chained1(arg).<!NI;UNRESOLVED_REFERENCE!>first<!>()
|
||||
chained2(arg).<!NI;UNRESOLVED_REFERENCE!>first<!>()
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package
|
||||
|
||||
public fun chained1(/*0*/ arg: First): kotlin.Any
|
||||
public fun chained2(/*0*/ arg: First): kotlin.Any
|
||||
public fun test(/*0*/ arg: First): kotlin.Unit
|
||||
|
||||
public interface First {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open fun first(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface Fourth {
|
||||
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 interface Second {
|
||||
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 interface Third {
|
||||
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
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package
|
||||
|
||||
public fun chained1(/*0*/ arg: First): First
|
||||
public fun chained2(/*0*/ arg: First): First
|
||||
public fun test(/*0*/ arg: First): kotlin.Unit
|
||||
|
||||
public interface First {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open fun first(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface Fourth {
|
||||
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 interface Second {
|
||||
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 interface Third {
|
||||
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
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_EXPRESSION
|
||||
// !LANGUAGE: +NewInference
|
||||
|
||||
interface Bound1
|
||||
interface Bound2
|
||||
object First : Bound1, Bound2
|
||||
object Second : Bound1, Bound2
|
||||
|
||||
fun <S : Bound1> intersect(vararg elements: S): S = TODO()
|
||||
|
||||
fun topLevelFunction() = intersect(First, Second)
|
||||
val Any.extensionProperty
|
||||
get() = intersect(First, Second)
|
||||
|
||||
fun Any.extensionFunction() = intersect(First, Second)
|
||||
|
||||
class Cls {
|
||||
val publicProperty = intersect(First, Second)
|
||||
private val privateProperty = intersect(First, Second)
|
||||
|
||||
fun publicMemberFunction() = intersect(First, Second)
|
||||
private fun privateMemberFunction() = intersect(First, Second)
|
||||
|
||||
fun testLocalDeclarations() {
|
||||
val localVariable = intersect(First, Second)
|
||||
fun localFunction() = intersect(First, Second)
|
||||
localVariable
|
||||
privateProperty
|
||||
localFunction()
|
||||
privateMemberFunction()
|
||||
}
|
||||
}
|
||||
|
||||
object Obj {
|
||||
val publicProperty = intersect(First, Second)
|
||||
private val privateProperty = intersect(First, Second)
|
||||
|
||||
fun publicMemberFunction() = intersect(First, Second)
|
||||
private fun privateMemberFunction() = intersect(First, Second)
|
||||
|
||||
fun testLocalDeclarations() {
|
||||
val localVariable = intersect(First, Second)
|
||||
fun localFunction() = intersect(First, Second)
|
||||
localVariable
|
||||
localFunction()
|
||||
privateProperty
|
||||
privateMemberFunction()
|
||||
}
|
||||
}
|
||||
|
||||
fun test(cls: Cls, obj: Obj) {
|
||||
topLevelFunction()
|
||||
Unit.extensionProperty
|
||||
Unit.extensionFunction()
|
||||
cls.publicProperty
|
||||
cls.publicMemberFunction()
|
||||
obj.publicProperty
|
||||
obj.publicMemberFunction()
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_EXPRESSION
|
||||
// !LANGUAGE: +NewInference
|
||||
|
||||
interface Bound1
|
||||
interface Bound2
|
||||
object First : Bound1, Bound2
|
||||
object Second : Bound1, Bound2
|
||||
|
||||
fun <S : Bound1> intersect(vararg elements: S): S = TODO()
|
||||
|
||||
fun topLevelFunction() = intersect(First, Second)
|
||||
val Any.extensionProperty
|
||||
get() = intersect(First, Second)
|
||||
|
||||
fun Any.extensionFunction() = intersect(First, Second)
|
||||
|
||||
class Cls {
|
||||
val publicProperty = intersect(First, Second)
|
||||
private val privateProperty = intersect(First, Second)
|
||||
|
||||
fun publicMemberFunction() = intersect(First, Second)
|
||||
private fun privateMemberFunction() = intersect(First, Second)
|
||||
|
||||
fun testLocalDeclarations() {
|
||||
val localVariable = intersect(First, Second)
|
||||
fun localFunction() = intersect(First, Second)
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("{Bound1 & Bound2}")!>localVariable<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Bound1")!>privateProperty<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Bound1")!>localFunction()<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Bound1")!>privateMemberFunction()<!>
|
||||
}
|
||||
}
|
||||
|
||||
object Obj {
|
||||
val publicProperty = intersect(First, Second)
|
||||
private val privateProperty = intersect(First, Second)
|
||||
|
||||
fun publicMemberFunction() = intersect(First, Second)
|
||||
private fun privateMemberFunction() = intersect(First, Second)
|
||||
|
||||
fun testLocalDeclarations() {
|
||||
val localVariable = intersect(First, Second)
|
||||
fun localFunction() = intersect(First, Second)
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("{Bound1 & Bound2}")!>localVariable<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Bound1")!>localFunction()<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Bound1")!>privateProperty<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Bound1")!>privateMemberFunction()<!>
|
||||
}
|
||||
}
|
||||
|
||||
fun test(cls: Cls, obj: Obj) {
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Bound1")!>topLevelFunction()<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Bound1")!>Unit.extensionProperty<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Bound1")!>Unit.extensionFunction()<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Bound1")!>cls.publicProperty<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Bound1")!>cls.publicMemberFunction()<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Bound1")!>obj.publicProperty<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Bound1")!>obj.publicMemberFunction()<!>
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
package
|
||||
|
||||
public val kotlin.Any.extensionProperty: Bound1
|
||||
public fun </*0*/ S : Bound1> intersect(/*0*/ vararg elements: S /*kotlin.Array<out S>*/): S
|
||||
public fun test(/*0*/ cls: Cls, /*1*/ obj: Obj): kotlin.Unit
|
||||
public fun topLevelFunction(): Bound1
|
||||
public fun kotlin.Any.extensionFunction(): Bound1
|
||||
|
||||
public interface Bound1 {
|
||||
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 interface Bound2 {
|
||||
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 Cls {
|
||||
public constructor Cls()
|
||||
private final val privateProperty: Bound1
|
||||
public final val publicProperty: Bound1
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
private final fun privateMemberFunction(): Bound1
|
||||
public final fun publicMemberFunction(): Bound1
|
||||
public final fun testLocalDeclarations(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public object First : Bound1, Bound2 {
|
||||
private constructor First()
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public object Obj {
|
||||
private constructor Obj()
|
||||
private final val privateProperty: Bound1
|
||||
public final val publicProperty: Bound1
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
private final fun privateMemberFunction(): Bound1
|
||||
public final fun publicMemberFunction(): Bound1
|
||||
public final fun testLocalDeclarations(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public object Second : Bound1, Bound2 {
|
||||
private constructor Second()
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// !WITH_NEW_INFERENCE
|
||||
// NI_EXPECTED_FILE
|
||||
|
||||
interface Base {
|
||||
fun base() {}
|
||||
}
|
||||
interface Base2
|
||||
interface One : Base, Base2
|
||||
interface Two : Base, Base2
|
||||
|
||||
object O1 : One
|
||||
object O2 : Two
|
||||
|
||||
fun <S> intersect(vararg elements: S): S = TODO()
|
||||
|
||||
fun intersectAfterSmartCast(arg: Base, arg2: Base) = intersect(
|
||||
run {
|
||||
if (arg !is One) throw Exception()
|
||||
arg
|
||||
},
|
||||
run {
|
||||
if (arg2 !is Two) throw Exception()
|
||||
arg2
|
||||
}
|
||||
)
|
||||
|
||||
fun <S> argOrFn(arg: S, fn: () -> S): S = TODO()
|
||||
|
||||
fun intersectArgWithSmartCastFromLambda(arg: One, arg2: Base) = argOrFn(arg) {
|
||||
if (arg2 !is Two) throw Exception()
|
||||
arg2
|
||||
}
|
||||
|
||||
fun test() {
|
||||
intersectAfterSmartCast(O1, O2).base()
|
||||
intersectArgWithSmartCastFromLambda(O1, O2).base()
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// !WITH_NEW_INFERENCE
|
||||
// NI_EXPECTED_FILE
|
||||
|
||||
interface Base {
|
||||
fun base() {}
|
||||
}
|
||||
interface Base2
|
||||
interface One : Base, Base2
|
||||
interface Two : Base, Base2
|
||||
|
||||
object O1 : One
|
||||
object O2 : Two
|
||||
|
||||
fun <S> intersect(vararg elements: S): S = TODO()
|
||||
|
||||
fun intersectAfterSmartCast(arg: Base, arg2: Base) = intersect(
|
||||
run {
|
||||
if (arg !is One) throw Exception()
|
||||
<!NI;DEBUG_INFO_SMARTCAST!>arg<!>
|
||||
},
|
||||
run {
|
||||
if (arg2 !is Two) throw Exception()
|
||||
<!NI;DEBUG_INFO_SMARTCAST!>arg2<!>
|
||||
}
|
||||
)
|
||||
|
||||
fun <S> argOrFn(arg: S, fn: () -> S): S = TODO()
|
||||
|
||||
fun intersectArgWithSmartCastFromLambda(arg: One, arg2: Base) = argOrFn(arg) {
|
||||
if (arg2 !is Two) throw Exception()
|
||||
arg2
|
||||
}
|
||||
|
||||
fun test() {
|
||||
intersectAfterSmartCast(O1, O2).<!NI;UNRESOLVED_REFERENCE!>base<!>()
|
||||
intersectArgWithSmartCastFromLambda(O1, O2).<!NI;UNRESOLVED_REFERENCE!>base<!>()
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ S> argOrFn(/*0*/ arg: S, /*1*/ fn: () -> S): S
|
||||
public fun </*0*/ S> intersect(/*0*/ vararg elements: S /*kotlin.Array<out S>*/): S
|
||||
public fun intersectAfterSmartCast(/*0*/ arg: Base, /*1*/ arg2: Base): kotlin.Any
|
||||
public fun intersectArgWithSmartCastFromLambda(/*0*/ arg: One, /*1*/ arg2: Base): kotlin.Any
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
public interface Base {
|
||||
public open fun base(): kotlin.Unit
|
||||
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 interface Base2 {
|
||||
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 object O1 : One {
|
||||
private constructor O1()
|
||||
public open override /*1*/ /*fake_override*/ fun base(): kotlin.Unit
|
||||
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 object O2 : Two {
|
||||
private constructor O2()
|
||||
public open override /*1*/ /*fake_override*/ fun base(): kotlin.Unit
|
||||
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 interface One : Base, Base2 {
|
||||
public open override /*1*/ /*fake_override*/ fun base(): kotlin.Unit
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface Two : Base, Base2 {
|
||||
public open override /*1*/ /*fake_override*/ fun base(): kotlin.Unit
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ S> argOrFn(/*0*/ arg: S, /*1*/ fn: () -> S): S
|
||||
public fun </*0*/ S> intersect(/*0*/ vararg elements: S /*kotlin.Array<out S>*/): S
|
||||
public fun intersectAfterSmartCast(/*0*/ arg: Base, /*1*/ arg2: Base): Base
|
||||
public fun intersectArgWithSmartCastFromLambda(/*0*/ arg: One, /*1*/ arg2: Base): Base
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
public interface Base {
|
||||
public open fun base(): kotlin.Unit
|
||||
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 interface Base2 {
|
||||
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 object O1 : One {
|
||||
private constructor O1()
|
||||
public open override /*1*/ /*fake_override*/ fun base(): kotlin.Unit
|
||||
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 object O2 : Two {
|
||||
private constructor O2()
|
||||
public open override /*1*/ /*fake_override*/ fun base(): kotlin.Unit
|
||||
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 interface One : Base, Base2 {
|
||||
public open override /*1*/ /*fake_override*/ fun base(): kotlin.Unit
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface Two : Base, Base2 {
|
||||
public open override /*1*/ /*fake_override*/ fun base(): kotlin.Unit
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
interface Bound
|
||||
interface Bound1 : Bound
|
||||
interface Bound2 : Bound
|
||||
interface Bound3
|
||||
object First : Bound1, Bound2, Bound3
|
||||
object Second : Bound1, Bound2, Bound3
|
||||
|
||||
fun <S> intersect(vararg elements: S): S where S : Bound1, S : Bound2 = TODO()
|
||||
|
||||
fun testIntersectionAlternative() = intersect(First, Second)
|
||||
|
||||
fun test() {
|
||||
testIntersectionAlternative()
|
||||
}
|
||||
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
interface Bound
|
||||
interface Bound1 : Bound
|
||||
interface Bound2 : Bound
|
||||
interface Bound3
|
||||
object First : Bound1, Bound2, Bound3
|
||||
object Second : Bound1, Bound2, Bound3
|
||||
|
||||
fun <S> intersect(vararg elements: S): S where S : Bound1, S : Bound2 = TODO()
|
||||
|
||||
fun testIntersectionAlternative() = intersect(First, Second)
|
||||
|
||||
fun test() {
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Bound")!>testIntersectionAlternative()<!>
|
||||
}
|
||||
Vendored
+43
@@ -0,0 +1,43 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ S : Bound1> intersect(/*0*/ vararg elements: S /*kotlin.Array<out S>*/): S where S : Bound2
|
||||
public fun test(): kotlin.Unit
|
||||
public fun testIntersectionAlternative(): Bound
|
||||
|
||||
public interface Bound {
|
||||
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 interface Bound1 : Bound {
|
||||
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 interface Bound2 : Bound {
|
||||
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 interface Bound3 {
|
||||
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 object First : Bound1, Bound2, Bound3 {
|
||||
private constructor First()
|
||||
public open override /*3*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*3*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*3*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public object Second : Bound1, Bound2, Bound3 {
|
||||
private constructor Second()
|
||||
public open override /*3*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*3*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*3*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
Vendored
+44
@@ -0,0 +1,44 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun test() {
|
||||
testInv()
|
||||
testIn()
|
||||
testOut()
|
||||
testStarProjection()
|
||||
testErrorType()
|
||||
testInProjection()
|
||||
testOutProjection()
|
||||
testDeeplyNested()
|
||||
}
|
||||
|
||||
interface Bound1
|
||||
interface Bound2
|
||||
object First : Bound1, Bound2
|
||||
object Second : Bound1, Bound2
|
||||
|
||||
class Inv<T>(val prop: T)
|
||||
class Out<out O>(val prop: O)
|
||||
class In<in I>(arg: I)
|
||||
class BiParam<F, S>(first: F, second: S)
|
||||
|
||||
fun <S : Bound1> intersect(vararg elements: S): S = TODO()
|
||||
|
||||
fun makeStarProjection(): Inv<*> = TODO()
|
||||
fun <I> makeInProjection(arg: I): Inv<in I> = TODO()
|
||||
fun <O> makeOutProjection(arg: O): Inv<out O> = TODO()
|
||||
fun testInv() = Inv(intersect(First, Second))
|
||||
fun testOut() = Out(intersect(First, Second))
|
||||
fun testIn() = In(intersect(First, Second))
|
||||
fun testInProjection() = makeInProjection(intersect(First, Second))
|
||||
fun testOutProjection() = makeOutProjection(intersect(First, Second))
|
||||
fun testDeeplyNested() = Inv(Inv(Inv(intersect(First, Second))))
|
||||
|
||||
fun testStarProjection() = BiParam(
|
||||
intersect(First, Second),
|
||||
makeStarProjection()
|
||||
)
|
||||
fun testErrorType() = <!INAPPLICABLE_CANDIDATE!>BiParam<!>(
|
||||
intersect(First, Second),
|
||||
<!UNRESOLVED_REFERENCE!>unresolved<!>
|
||||
)
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun test() {
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<Bound1>")!>testInv()<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("In<Bound1>")!>testIn()<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Out<Bound1>")!>testOut()<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("BiParam<Bound1, Inv<*>>")!>testStarProjection()<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("[ERROR : Error function type]")!>testErrorType()<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<in Bound1>")!>testInProjection()<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<out Bound1>")!>testOutProjection()<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<Inv<Inv<Bound1>>>")!>testDeeplyNested()<!>
|
||||
}
|
||||
|
||||
interface Bound1
|
||||
interface Bound2
|
||||
object First : Bound1, Bound2
|
||||
object Second : Bound1, Bound2
|
||||
|
||||
class Inv<T>(val prop: T)
|
||||
class Out<out O>(val prop: O)
|
||||
class In<in I>(arg: I)
|
||||
class BiParam<F, S>(first: F, second: S)
|
||||
|
||||
fun <S : Bound1> intersect(vararg elements: S): S = TODO()
|
||||
|
||||
fun makeStarProjection(): Inv<*> = TODO()
|
||||
fun <I> makeInProjection(arg: I): Inv<in I> = TODO()
|
||||
fun <O> makeOutProjection(arg: O): Inv<out O> = TODO()
|
||||
fun testInv() = Inv(intersect(First, Second))
|
||||
fun testOut() = Out(intersect(First, Second))
|
||||
fun testIn() = In(intersect(First, Second))
|
||||
fun testInProjection() = makeInProjection(intersect(First, Second))
|
||||
fun testOutProjection() = makeOutProjection(intersect(First, Second))
|
||||
fun testDeeplyNested() = Inv(Inv(Inv(intersect(First, Second))))
|
||||
|
||||
fun testStarProjection() = BiParam(
|
||||
intersect(First, Second),
|
||||
makeStarProjection()
|
||||
)
|
||||
fun testErrorType() = BiParam(
|
||||
intersect(First, Second),
|
||||
<!UNRESOLVED_REFERENCE!>unresolved<!>
|
||||
)
|
||||
Vendored
+71
@@ -0,0 +1,71 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ S : Bound1> intersect(/*0*/ vararg elements: S /*kotlin.Array<out S>*/): S
|
||||
public fun </*0*/ I> makeInProjection(/*0*/ arg: I): Inv<in I>
|
||||
public fun </*0*/ O> makeOutProjection(/*0*/ arg: O): Inv<out O>
|
||||
public fun makeStarProjection(): Inv<*>
|
||||
public fun test(): kotlin.Unit
|
||||
public fun testDeeplyNested(): Inv<Inv<Inv<Bound1>>>
|
||||
public fun testErrorType(): [ERROR : Error function type]
|
||||
public fun testIn(): In<Bound1>
|
||||
public fun testInProjection(): Inv<in Bound1>
|
||||
public fun testInv(): Inv<Bound1>
|
||||
public fun testOut(): Out<Bound1>
|
||||
public fun testOutProjection(): Inv<out Bound1>
|
||||
public fun testStarProjection(): BiParam<Bound1, Inv<*>>
|
||||
|
||||
public final class BiParam</*0*/ F, /*1*/ S> {
|
||||
public constructor BiParam</*0*/ F, /*1*/ S>(/*0*/ first: F, /*1*/ second: S)
|
||||
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 interface Bound1 {
|
||||
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 interface Bound2 {
|
||||
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 object First : Bound1, Bound2 {
|
||||
private constructor First()
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class In</*0*/ in I> {
|
||||
public constructor In</*0*/ in I>(/*0*/ arg: I)
|
||||
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 Inv</*0*/ T> {
|
||||
public constructor Inv</*0*/ T>(/*0*/ prop: T)
|
||||
public final val prop: T
|
||||
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 Out</*0*/ out O> {
|
||||
public constructor Out</*0*/ out O>(/*0*/ prop: O)
|
||||
public final val prop: O
|
||||
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 object Second : Bound1, Bound2 {
|
||||
private constructor Second()
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
interface First
|
||||
interface Second
|
||||
|
||||
interface A : First, Second
|
||||
interface B : First, Second
|
||||
|
||||
fun <S> intersect(vararg elements: S): S = TODO()
|
||||
|
||||
fun runIntersect(arg: A, arg2: A) = run {
|
||||
if (arg !is B) throw Exception()
|
||||
if (arg2 !is B) throw Exception()
|
||||
intersect(arg, arg2)
|
||||
}
|
||||
|
||||
fun test(arg: A) {
|
||||
runIntersect(arg, arg)
|
||||
}
|
||||
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
interface First
|
||||
interface Second
|
||||
|
||||
interface A : First, Second
|
||||
interface B : First, Second
|
||||
|
||||
fun <S> intersect(vararg elements: S): S = TODO()
|
||||
|
||||
fun runIntersect(arg: A, arg2: A) = run {
|
||||
if (arg !is B) throw Exception()
|
||||
if (arg2 !is B) throw Exception()
|
||||
intersect(arg, arg2)
|
||||
}
|
||||
|
||||
fun test(arg: A) {
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any")!>runIntersect(arg, arg)<!>
|
||||
}
|
||||
Vendored
+29
@@ -0,0 +1,29 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ S> intersect(/*0*/ vararg elements: S /*kotlin.Array<out S>*/): S
|
||||
public fun runIntersect(/*0*/ arg: A, /*1*/ arg2: A): kotlin.Any
|
||||
public fun test(/*0*/ arg: A): kotlin.Unit
|
||||
|
||||
public interface A : First, Second {
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface B : First, Second {
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface First {
|
||||
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 interface Second {
|
||||
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
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
interface Bound1
|
||||
interface Bound2
|
||||
object First : Bound1, Bound2
|
||||
object Second : Bound1, Bound2
|
||||
|
||||
fun <S : Bound1> intersect(vararg elements: S): S = TODO()
|
||||
|
||||
fun <R> run(fn: () -> R): R = TODO()
|
||||
|
||||
fun topLevel() = run {
|
||||
val local = intersect(First, Second)
|
||||
local
|
||||
}
|
||||
|
||||
fun test() {
|
||||
topLevel()
|
||||
}
|
||||
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
interface Bound1
|
||||
interface Bound2
|
||||
object First : Bound1, Bound2
|
||||
object Second : Bound1, Bound2
|
||||
|
||||
fun <S : Bound1> intersect(vararg elements: S): S = TODO()
|
||||
|
||||
fun <R> run(fn: () -> R): R = TODO()
|
||||
|
||||
fun topLevel() = run {
|
||||
val local = intersect(First, Second)
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("{Bound1 & Bound2}")!>local<!>
|
||||
}
|
||||
|
||||
fun test() {
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Bound1")!>topLevel()<!>
|
||||
}
|
||||
Vendored
+32
@@ -0,0 +1,32 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ S : Bound1> intersect(/*0*/ vararg elements: S /*kotlin.Array<out S>*/): S
|
||||
public fun </*0*/ R> run(/*0*/ fn: () -> R): R
|
||||
public fun test(): kotlin.Unit
|
||||
public fun topLevel(): Bound1
|
||||
|
||||
public interface Bound1 {
|
||||
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 interface Bound2 {
|
||||
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 object First : Bound1, Bound2 {
|
||||
private constructor First()
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public object Second : Bound1, Bound2 {
|
||||
private constructor Second()
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
Vendored
+54
@@ -0,0 +1,54 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun test(first: First, second: Second) {
|
||||
test1(first, second)
|
||||
test2(first, second)
|
||||
test3(first, second)
|
||||
test4(first, second)
|
||||
test5(first, second)
|
||||
test6(first, second)
|
||||
test7(first, second)
|
||||
test8(first, second)
|
||||
test9(first, second)
|
||||
|
||||
test10(first, second)
|
||||
test11(first, second)
|
||||
test12(first, second)
|
||||
test13(first, second)
|
||||
test14(first, second)
|
||||
test15(first, second)
|
||||
test16(first, second)
|
||||
test17(first, second)
|
||||
test18(first, second)
|
||||
}
|
||||
|
||||
interface Bound1
|
||||
interface Bound2
|
||||
object First : Bound1, Bound2
|
||||
object Second : Bound1, Bound2
|
||||
|
||||
fun <S : Bound1> intersect(vararg elements: S): S = TODO()
|
||||
|
||||
class Inv<T>(val prop: T)
|
||||
class In<in I>(arg: I)
|
||||
class Out<out O>(val arg: O)
|
||||
|
||||
fun test1(first: First, second: Second) = Inv(Inv(intersect(first, second)))
|
||||
fun test2(first: First, second: Second) = Inv(In(intersect(first, second)))
|
||||
fun test3(first: First, second: Second) = Inv(Out(intersect(first, second)))
|
||||
fun test4(first: First, second: Second) = In(Inv(intersect(first, second)))
|
||||
fun test5(first: First, second: Second) = In(In(intersect(first, second)))
|
||||
fun test6(first: First, second: Second) = In(Out(intersect(first, second)))
|
||||
fun test7(first: First, second: Second) = Out(Inv(intersect(first, second)))
|
||||
fun test8(first: First, second: Second) = Out(In(intersect(first, second)))
|
||||
fun test9(first: First, second: Second) = Out(Out(intersect(first, second)))
|
||||
|
||||
fun test10(first: First, second: Second) = Out(Out(Out(intersect(first, second))))
|
||||
fun test11(first: First, second: Second) = Inv(Out(Out(intersect(first, second))))
|
||||
fun test12(first: First, second: Second) = Inv(Out(In(intersect(first, second))))
|
||||
fun test13(first: First, second: Second) = Inv(In(Out(intersect(first, second))))
|
||||
fun test14(first: First, second: Second) = Inv(In(In(intersect(first, second))))
|
||||
fun test15(first: First, second: Second) = Out(Inv(Out(intersect(first, second))))
|
||||
fun test16(first: First, second: Second) = Out(Out(In(intersect(first, second))))
|
||||
fun test17(first: First, second: Second) = Out(In(Out(intersect(first, second))))
|
||||
fun test18(first: First, second: Second) = In(Out(Out(intersect(first, second))))
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun test(first: First, second: Second) {
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<Inv<Bound1>>")!>test1(first, second)<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<In<Bound1>>")!>test2(first, second)<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<Out<Bound1>>")!>test3(first, second)<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("In<Inv<Bound1>>")!>test4(first, second)<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("In<In<Bound1>>")!>test5(first, second)<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("In<Out<Bound1>>")!>test6(first, second)<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Out<Inv<Bound1>>")!>test7(first, second)<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Out<In<Bound1>>")!>test8(first, second)<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Out<Out<Bound1>>")!>test9(first, second)<!>
|
||||
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Out<Out<Out<Bound1>>>")!>test10(first, second)<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<Out<Out<Bound1>>>")!>test11(first, second)<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<Out<In<Bound1>>>")!>test12(first, second)<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<In<Out<Bound1>>>")!>test13(first, second)<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<In<In<Bound1>>>")!>test14(first, second)<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Out<Inv<Out<Bound1>>>")!>test15(first, second)<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Out<Out<In<Bound1>>>")!>test16(first, second)<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Out<In<Out<Bound1>>>")!>test17(first, second)<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("In<Out<Out<Bound1>>>")!>test18(first, second)<!>
|
||||
}
|
||||
|
||||
interface Bound1
|
||||
interface Bound2
|
||||
object First : Bound1, Bound2
|
||||
object Second : Bound1, Bound2
|
||||
|
||||
fun <S : Bound1> intersect(vararg elements: S): S = TODO()
|
||||
|
||||
class Inv<T>(val prop: T)
|
||||
class In<in I>(arg: I)
|
||||
class Out<out O>(val arg: O)
|
||||
|
||||
fun test1(first: First, second: Second) = Inv(Inv(intersect(first, second)))
|
||||
fun test2(first: First, second: Second) = Inv(In(intersect(first, second)))
|
||||
fun test3(first: First, second: Second) = Inv(Out(intersect(first, second)))
|
||||
fun test4(first: First, second: Second) = In(Inv(intersect(first, second)))
|
||||
fun test5(first: First, second: Second) = In(In(intersect(first, second)))
|
||||
fun test6(first: First, second: Second) = In(Out(intersect(first, second)))
|
||||
fun test7(first: First, second: Second) = Out(Inv(intersect(first, second)))
|
||||
fun test8(first: First, second: Second) = Out(In(intersect(first, second)))
|
||||
fun test9(first: First, second: Second) = Out(Out(intersect(first, second)))
|
||||
|
||||
fun test10(first: First, second: Second) = Out(Out(Out(intersect(first, second))))
|
||||
fun test11(first: First, second: Second) = Inv(Out(Out(intersect(first, second))))
|
||||
fun test12(first: First, second: Second) = Inv(Out(In(intersect(first, second))))
|
||||
fun test13(first: First, second: Second) = Inv(In(Out(intersect(first, second))))
|
||||
fun test14(first: First, second: Second) = Inv(In(In(intersect(first, second))))
|
||||
fun test15(first: First, second: Second) = Out(Inv(Out(intersect(first, second))))
|
||||
fun test16(first: First, second: Second) = Out(Out(In(intersect(first, second))))
|
||||
fun test17(first: First, second: Second) = Out(In(Out(intersect(first, second))))
|
||||
fun test18(first: First, second: Second) = In(Out(Out(intersect(first, second))))
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ S : Bound1> intersect(/*0*/ vararg elements: S /*kotlin.Array<out S>*/): S
|
||||
public fun test(/*0*/ first: First, /*1*/ second: Second): kotlin.Unit
|
||||
public fun test1(/*0*/ first: First, /*1*/ second: Second): Inv<Inv<Bound1>>
|
||||
public fun test10(/*0*/ first: First, /*1*/ second: Second): Out<Out<Out<Bound1>>>
|
||||
public fun test11(/*0*/ first: First, /*1*/ second: Second): Inv<Out<Out<Bound1>>>
|
||||
public fun test12(/*0*/ first: First, /*1*/ second: Second): Inv<Out<In<Bound1>>>
|
||||
public fun test13(/*0*/ first: First, /*1*/ second: Second): Inv<In<Out<Bound1>>>
|
||||
public fun test14(/*0*/ first: First, /*1*/ second: Second): Inv<In<In<Bound1>>>
|
||||
public fun test15(/*0*/ first: First, /*1*/ second: Second): Out<Inv<Out<Bound1>>>
|
||||
public fun test16(/*0*/ first: First, /*1*/ second: Second): Out<Out<In<Bound1>>>
|
||||
public fun test17(/*0*/ first: First, /*1*/ second: Second): Out<In<Out<Bound1>>>
|
||||
public fun test18(/*0*/ first: First, /*1*/ second: Second): In<Out<Out<Bound1>>>
|
||||
public fun test2(/*0*/ first: First, /*1*/ second: Second): Inv<In<Bound1>>
|
||||
public fun test3(/*0*/ first: First, /*1*/ second: Second): Inv<Out<Bound1>>
|
||||
public fun test4(/*0*/ first: First, /*1*/ second: Second): In<Inv<Bound1>>
|
||||
public fun test5(/*0*/ first: First, /*1*/ second: Second): In<In<Bound1>>
|
||||
public fun test6(/*0*/ first: First, /*1*/ second: Second): In<Out<Bound1>>
|
||||
public fun test7(/*0*/ first: First, /*1*/ second: Second): Out<Inv<Bound1>>
|
||||
public fun test8(/*0*/ first: First, /*1*/ second: Second): Out<In<Bound1>>
|
||||
public fun test9(/*0*/ first: First, /*1*/ second: Second): Out<Out<Bound1>>
|
||||
|
||||
public interface Bound1 {
|
||||
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 interface Bound2 {
|
||||
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 object First : Bound1, Bound2 {
|
||||
private constructor First()
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class In</*0*/ in I> {
|
||||
public constructor In</*0*/ in I>(/*0*/ arg: I)
|
||||
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 Inv</*0*/ T> {
|
||||
public constructor Inv</*0*/ T>(/*0*/ prop: T)
|
||||
public final val prop: T
|
||||
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 Out</*0*/ out O> {
|
||||
public constructor Out</*0*/ out O>(/*0*/ arg: O)
|
||||
public final val arg: O
|
||||
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 object Second : Bound1, Bound2 {
|
||||
private constructor Second()
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
interface Bound1
|
||||
interface Bound2
|
||||
object First : Bound1, Bound2
|
||||
object Second : Bound1, Bound2
|
||||
|
||||
interface WithParam1<out T>
|
||||
interface WithParam2<out T>
|
||||
class ClsWithParam1<out T> : WithParam1<T>, WithParam2<T>
|
||||
class ClsWithParam2<out T> : WithParam1<T>, WithParam2<T>
|
||||
|
||||
fun <S : Bound1> intersect(vararg elements: S): S = TODO()
|
||||
fun <T: Bound1, P : WithParam1<T>> combineParams(first: T, vararg args: P): P = TODO()
|
||||
|
||||
fun topLevel() = combineParams(
|
||||
intersect(First, Second),
|
||||
ClsWithParam1<First>(),
|
||||
ClsWithParam2<Second>()
|
||||
)
|
||||
|
||||
fun test() {
|
||||
topLevel()
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
interface Bound1
|
||||
interface Bound2
|
||||
object First : Bound1, Bound2
|
||||
object Second : Bound1, Bound2
|
||||
|
||||
interface WithParam1<out T>
|
||||
interface WithParam2<out T>
|
||||
class ClsWithParam1<out T> : WithParam1<T>, WithParam2<T>
|
||||
class ClsWithParam2<out T> : WithParam1<T>, WithParam2<T>
|
||||
|
||||
fun <S : Bound1> intersect(vararg elements: S): S = TODO()
|
||||
fun <T: Bound1, P : WithParam1<T>> combineParams(first: T, vararg args: P): P = TODO()
|
||||
|
||||
fun topLevel() = <!DEBUG_INFO_EXPRESSION_TYPE("{WithParam1<{Bound1 & Bound2}> & WithParam2<{Bound1 & Bound2}>}")!>combineParams(
|
||||
intersect(First, Second),
|
||||
ClsWithParam1<First>(),
|
||||
ClsWithParam2<Second>()
|
||||
)<!>
|
||||
|
||||
fun test() {
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("WithParam1<Bound1>")!>topLevel()<!>
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ T : Bound1, /*1*/ P : WithParam1<T>> combineParams(/*0*/ first: T, /*1*/ vararg args: P /*kotlin.Array<out P>*/): P
|
||||
public fun </*0*/ S : Bound1> intersect(/*0*/ vararg elements: S /*kotlin.Array<out S>*/): S
|
||||
public fun test(): kotlin.Unit
|
||||
public fun topLevel(): WithParam1<Bound1>
|
||||
|
||||
public interface Bound1 {
|
||||
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 interface Bound2 {
|
||||
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 ClsWithParam1</*0*/ out T> : WithParam1<T>, WithParam2<T> {
|
||||
public constructor ClsWithParam1</*0*/ out T>()
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class ClsWithParam2</*0*/ out T> : WithParam1<T>, WithParam2<T> {
|
||||
public constructor ClsWithParam2</*0*/ out T>()
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public object First : Bound1, Bound2 {
|
||||
private constructor First()
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public object Second : Bound1, Bound2 {
|
||||
private constructor Second()
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface WithParam1</*0*/ out T> {
|
||||
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 interface WithParam2</*0*/ out T> {
|
||||
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
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
interface Bound1
|
||||
interface Bound2
|
||||
object First : Bound1, Bound2
|
||||
object Second : Bound1, Bound2
|
||||
|
||||
class Inv<T>
|
||||
|
||||
fun <O: Bound1> makeOut(vararg args: O): Inv<out O> = TODO()
|
||||
fun <I: Bound1> makeIn(vararg args: I): Inv<in I> = TODO()
|
||||
|
||||
fun testOut() = makeOut(First, Second)
|
||||
fun testIn() = makeIn(First, Second)
|
||||
|
||||
fun test() {
|
||||
testOut()
|
||||
testIn()
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
interface Bound1
|
||||
interface Bound2
|
||||
object First : Bound1, Bound2
|
||||
object Second : Bound1, Bound2
|
||||
|
||||
class Inv<T>
|
||||
|
||||
fun <O: Bound1> makeOut(vararg args: O): Inv<out O> = TODO()
|
||||
fun <I: Bound1> makeIn(vararg args: I): Inv<in I> = TODO()
|
||||
|
||||
fun testOut() = makeOut(First, Second)
|
||||
fun testIn() = makeIn(First, Second)
|
||||
|
||||
fun test() {
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<out Bound1>")!>testOut()<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<in Bound1>")!>testIn()<!>
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ I : Bound1> makeIn(/*0*/ vararg args: I /*kotlin.Array<out I>*/): Inv<in I>
|
||||
public fun </*0*/ O : Bound1> makeOut(/*0*/ vararg args: O /*kotlin.Array<out O>*/): Inv<out O>
|
||||
public fun test(): kotlin.Unit
|
||||
public fun testIn(): Inv<in Bound1>
|
||||
public fun testOut(): Inv<out Bound1>
|
||||
|
||||
public interface Bound1 {
|
||||
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 interface Bound2 {
|
||||
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 object First : Bound1, Bound2 {
|
||||
private constructor First()
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class Inv</*0*/ T> {
|
||||
public constructor Inv</*0*/ T>()
|
||||
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 object Second : Bound1, Bound2 {
|
||||
private constructor Second()
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// !WITH_NEW_INFERENCE
|
||||
// NI_EXPECTED_FILE
|
||||
|
||||
interface Base {
|
||||
fun base() {}
|
||||
}
|
||||
interface Base2
|
||||
interface One : Base, Base2
|
||||
interface Two : Base, Base2
|
||||
|
||||
fun <S: Base> intersectNullable(vararg elements: S): S? = TODO()
|
||||
|
||||
fun smartCastAfterIntersection(a: One, b: Two) = run {
|
||||
val v = intersectNullable(a, b)
|
||||
if (v == null) throw Exception()
|
||||
v
|
||||
}
|
||||
|
||||
fun test(one: One, two: Two) {
|
||||
smartCastAfterIntersection(one, two)?.base()
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// !WITH_NEW_INFERENCE
|
||||
// NI_EXPECTED_FILE
|
||||
|
||||
interface Base {
|
||||
fun base() {}
|
||||
}
|
||||
interface Base2
|
||||
interface One : Base, Base2
|
||||
interface Two : Base, Base2
|
||||
|
||||
fun <S: Base> intersectNullable(vararg elements: S): S? = TODO()
|
||||
|
||||
fun smartCastAfterIntersection(a: One, b: Two) = run {
|
||||
val v = intersectNullable(a, b)
|
||||
if (v == null) throw Exception()
|
||||
v
|
||||
}
|
||||
|
||||
fun test(one: One, two: Two) {
|
||||
smartCastAfterIntersection(one, two)<!NI;UNNECESSARY_SAFE_CALL!>?.<!><!NI;UNRESOLVED_REFERENCE!>base<!>()
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ S : Base> intersectNullable(/*0*/ vararg elements: S /*kotlin.Array<out S>*/): S?
|
||||
public fun smartCastAfterIntersection(/*0*/ a: One, /*1*/ b: Two): kotlin.Any
|
||||
public fun test(/*0*/ one: One, /*1*/ two: Two): kotlin.Unit
|
||||
|
||||
public interface Base {
|
||||
public open fun base(): kotlin.Unit
|
||||
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 interface Base2 {
|
||||
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 interface One : Base, Base2 {
|
||||
public open override /*1*/ /*fake_override*/ fun base(): kotlin.Unit
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface Two : Base, Base2 {
|
||||
public open override /*1*/ /*fake_override*/ fun base(): kotlin.Unit
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ S : Base> intersectNullable(/*0*/ vararg elements: S /*kotlin.Array<out S>*/): S?
|
||||
public fun smartCastAfterIntersection(/*0*/ a: One, /*1*/ b: Two): Base?
|
||||
public fun test(/*0*/ one: One, /*1*/ two: Two): kotlin.Unit
|
||||
|
||||
public interface Base {
|
||||
public open fun base(): kotlin.Unit
|
||||
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 interface Base2 {
|
||||
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 interface One : Base, Base2 {
|
||||
public open override /*1*/ /*fake_override*/ fun base(): kotlin.Unit
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface Two : Base, Base2 {
|
||||
public open override /*1*/ /*fake_override*/ fun base(): kotlin.Unit
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// !WITH_NEW_INFERENCE
|
||||
// NI_EXPECTED_FILE
|
||||
|
||||
interface Base {
|
||||
fun base() {}
|
||||
}
|
||||
interface Base2 : Base3
|
||||
interface Base3
|
||||
interface One : Base, Base2
|
||||
interface Two : Base, Base2
|
||||
interface Three : Base, Base3
|
||||
|
||||
object O1 : One
|
||||
object O2 : Two
|
||||
object O3 : Three
|
||||
|
||||
fun <S: Base> intersect(vararg elements: S): S = TODO()
|
||||
fun <S> intersectNoBound(vararg elements: S): S = TODO()
|
||||
|
||||
fun some(a: One, b: Two, c: Three) = intersectNoBound(intersect(a, b), c)
|
||||
|
||||
fun test(arg: Base, arg2: Base) {
|
||||
some(O1, O2, O3).base()
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// !WITH_NEW_INFERENCE
|
||||
// NI_EXPECTED_FILE
|
||||
|
||||
interface Base {
|
||||
fun base() {}
|
||||
}
|
||||
interface Base2 : Base3
|
||||
interface Base3
|
||||
interface One : Base, Base2
|
||||
interface Two : Base, Base2
|
||||
interface Three : Base, Base3
|
||||
|
||||
object O1 : One
|
||||
object O2 : Two
|
||||
object O3 : Three
|
||||
|
||||
fun <S: Base> intersect(vararg elements: S): S = TODO()
|
||||
fun <S> intersectNoBound(vararg elements: S): S = TODO()
|
||||
|
||||
fun some(a: One, b: Two, c: Three) = intersectNoBound(intersect(a, b), c)
|
||||
|
||||
fun test(arg: Base, arg2: Base) {
|
||||
some(O1, O2, O3).<!NI;UNRESOLVED_REFERENCE!>base<!>()
|
||||
}
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ S : Base> intersect(/*0*/ vararg elements: S /*kotlin.Array<out S>*/): S
|
||||
public fun </*0*/ S> intersectNoBound(/*0*/ vararg elements: S /*kotlin.Array<out S>*/): S
|
||||
public fun some(/*0*/ a: One, /*1*/ b: Two, /*2*/ c: Three): kotlin.Any
|
||||
public fun test(/*0*/ arg: Base, /*1*/ arg2: Base): kotlin.Unit
|
||||
|
||||
public interface Base {
|
||||
public open fun base(): kotlin.Unit
|
||||
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 interface Base2 : Base3 {
|
||||
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 interface Base3 {
|
||||
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 object O1 : One {
|
||||
private constructor O1()
|
||||
public open override /*1*/ /*fake_override*/ fun base(): kotlin.Unit
|
||||
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 object O2 : Two {
|
||||
private constructor O2()
|
||||
public open override /*1*/ /*fake_override*/ fun base(): kotlin.Unit
|
||||
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 object O3 : Three {
|
||||
private constructor O3()
|
||||
public open override /*1*/ /*fake_override*/ fun base(): kotlin.Unit
|
||||
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 interface One : Base, Base2 {
|
||||
public open override /*1*/ /*fake_override*/ fun base(): kotlin.Unit
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface Three : Base, Base3 {
|
||||
public open override /*1*/ /*fake_override*/ fun base(): kotlin.Unit
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface Two : Base, Base2 {
|
||||
public open override /*1*/ /*fake_override*/ fun base(): kotlin.Unit
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ S : Base> intersect(/*0*/ vararg elements: S /*kotlin.Array<out S>*/): S
|
||||
public fun </*0*/ S> intersectNoBound(/*0*/ vararg elements: S /*kotlin.Array<out S>*/): S
|
||||
public fun some(/*0*/ a: One, /*1*/ b: Two, /*2*/ c: Three): Base
|
||||
public fun test(/*0*/ arg: Base, /*1*/ arg2: Base): kotlin.Unit
|
||||
|
||||
public interface Base {
|
||||
public open fun base(): kotlin.Unit
|
||||
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 interface Base2 : Base3 {
|
||||
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 interface Base3 {
|
||||
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 object O1 : One {
|
||||
private constructor O1()
|
||||
public open override /*1*/ /*fake_override*/ fun base(): kotlin.Unit
|
||||
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 object O2 : Two {
|
||||
private constructor O2()
|
||||
public open override /*1*/ /*fake_override*/ fun base(): kotlin.Unit
|
||||
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 object O3 : Three {
|
||||
private constructor O3()
|
||||
public open override /*1*/ /*fake_override*/ fun base(): kotlin.Unit
|
||||
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 interface One : Base, Base2 {
|
||||
public open override /*1*/ /*fake_override*/ fun base(): kotlin.Unit
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface Three : Base, Base3 {
|
||||
public open override /*1*/ /*fake_override*/ fun base(): kotlin.Unit
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface Two : Base, Base2 {
|
||||
public open override /*1*/ /*fake_override*/ fun base(): kotlin.Unit
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_EXPRESSION
|
||||
|
||||
interface Bound1
|
||||
interface Bound2
|
||||
object First : Bound1, Bound2
|
||||
object Second : Bound1, Bound2
|
||||
|
||||
fun <S : Bound1> select(vararg args: S): S = TODO()
|
||||
|
||||
class Cls {
|
||||
val property = select(First, Second)
|
||||
}
|
||||
|
||||
fun test() {
|
||||
val v = Cls().property
|
||||
v
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_EXPRESSION
|
||||
|
||||
interface Bound1
|
||||
interface Bound2
|
||||
object First : Bound1, Bound2
|
||||
object Second : Bound1, Bound2
|
||||
|
||||
fun <S : Bound1> select(vararg args: S): S = TODO()
|
||||
|
||||
class Cls {
|
||||
val property = select(First, Second)
|
||||
}
|
||||
|
||||
fun test() {
|
||||
val v = Cls().property
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Bound1")!>v<!>
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ S : Bound1> select(/*0*/ vararg args: S /*kotlin.Array<out S>*/): S
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
public interface Bound1 {
|
||||
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 interface Bound2 {
|
||||
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 Cls {
|
||||
public constructor Cls()
|
||||
public final val property: Bound1
|
||||
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 object First : Bound1, Bound2 {
|
||||
private constructor First()
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public object Second : Bound1, Bound2 {
|
||||
private constructor Second()
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
package
|
||||
|
||||
public val test1: C<kotlin.Int> /* = Cons<kotlin.Int> */
|
||||
public val test2: Cons<out kotlin.Any>
|
||||
public val test2: C<kotlin.Number> /* = Cons<kotlin.Number> */
|
||||
|
||||
public final class Cons</*0*/ T : kotlin.Number> {
|
||||
public constructor Cons</*0*/ T : kotlin.Number>(/*0*/ head: T, /*1*/ tail: Cons<T>?)
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER UNUSED_VARIABLE -UNUSED_EXPRESSION
|
||||
|
||||
import kotlin.reflect.KClass
|
||||
fun <T : PsiElement> select(vararg classes: KClass<out T>): T? {
|
||||
return null
|
||||
}
|
||||
interface PomRenameableTarget
|
||||
interface PsiElement
|
||||
interface PsiMethod : PsiElement, PomRenameableTarget
|
||||
interface PsiClass : PsiElement, PomRenameableTarget
|
||||
|
||||
class A {
|
||||
val inv get() = select(PsiMethod::class, PsiClass::class)
|
||||
}
|
||||
|
||||
fun main() {
|
||||
A().inv
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER UNUSED_VARIABLE -UNUSED_EXPRESSION
|
||||
|
||||
import kotlin.reflect.KClass
|
||||
fun <T : PsiElement> select(vararg classes: KClass<out T>): T? {
|
||||
return null
|
||||
}
|
||||
interface PomRenameableTarget
|
||||
interface PsiElement
|
||||
interface PsiMethod : PsiElement, PomRenameableTarget
|
||||
interface PsiClass : PsiElement, PomRenameableTarget
|
||||
|
||||
class A {
|
||||
val inv get() = select(PsiMethod::class, PsiClass::class)
|
||||
}
|
||||
|
||||
fun main() {
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("PsiElement?")!>A().inv<!>
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package
|
||||
|
||||
public fun main(): kotlin.Unit
|
||||
public fun </*0*/ T : PsiElement> select(/*0*/ vararg classes: kotlin.reflect.KClass<out T> /*kotlin.Array<out kotlin.reflect.KClass<out T>>*/): T?
|
||||
|
||||
public final class A {
|
||||
public constructor A()
|
||||
public final val inv: PsiElement?
|
||||
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 interface PomRenameableTarget {
|
||||
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 interface PsiClass : PsiElement, PomRenameableTarget {
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface PsiElement {
|
||||
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 interface PsiMethod : PsiElement, PomRenameableTarget {
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
@@ -36,15 +36,15 @@ FILE fqName:<root> fileName:/implicitCastToTypeParameter.kt
|
||||
$receiver: VALUE_PARAMETER name:<this> type:<root>.Foo<T of <root>.<get-asT>>
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-asT> <T> (): T of <root>.<get-asT>? [inline] declared in <root>'
|
||||
TYPE_OP type=T of <root>.<get-asT>? origin=IMPLICIT_CAST typeOperand=T of <root>.<get-asT>?
|
||||
WHEN type=kotlin.Any? origin=IF
|
||||
BRANCH
|
||||
if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=T of <root>.<get-asT>
|
||||
GET_VAR '<this>: <root>.Foo<T of <root>.<get-asT>> declared in <root>.<get-asT>' type=<root>.Foo<T of <root>.<get-asT>> origin=null
|
||||
then: GET_VAR '<this>: <root>.Foo<T of <root>.<get-asT>> declared in <root>.<get-asT>' type=<root>.Foo<T of <root>.<get-asT>> origin=null
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: CONST Null type=kotlin.Nothing? value=null
|
||||
WHEN type=T of <root>.<get-asT>? origin=IF
|
||||
BRANCH
|
||||
if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=T of <root>.<get-asT>
|
||||
GET_VAR '<this>: <root>.Foo<T of <root>.<get-asT>> declared in <root>.<get-asT>' type=<root>.Foo<T of <root>.<get-asT>> origin=null
|
||||
then: TYPE_OP type=T of <root>.<get-asT> origin=IMPLICIT_CAST typeOperand=T of <root>.<get-asT>
|
||||
GET_VAR '<this>: <root>.Foo<T of <root>.<get-asT>> declared in <root>.<get-asT>' type=<root>.Foo<T of <root>.<get-asT>> origin=null
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: CONST Null type=kotlin.Nothing? value=null
|
||||
CLASS CLASS name:Bar modality:FINAL visibility:public superTypes:[kotlin.Any]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Bar<T of <root>.Bar>
|
||||
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?]
|
||||
|
||||
@@ -10233,6 +10233,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTestWithFirVali
|
||||
runTest("compiler/testData/diagnostics/tests/inference/tooEagerSmartcast.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("topLevelIntersection.kt")
|
||||
public void testTopLevelIntersection() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/topLevelIntersection.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("tryNumberLowerBoundsBeforeUpperBounds.kt")
|
||||
public void testTryNumberLowerBoundsBeforeUpperBounds() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/tryNumberLowerBoundsBeforeUpperBounds.kt");
|
||||
@@ -11029,6 +11034,84 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTestWithFirVali
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/inference/publicApproximation")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class PublicApproximation extends AbstractDiagnosticsTestWithFirValidation {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInPublicApproximation() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/inference/publicApproximation"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("approximatedIntersectionMorePreciseThanBound.kt")
|
||||
public void testApproximatedIntersectionMorePreciseThanBound() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/publicApproximation/approximatedIntersectionMorePreciseThanBound.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("chainedLambdas.kt")
|
||||
public void testChainedLambdas() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/publicApproximation/chainedLambdas.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("declarationTypes.kt")
|
||||
public void testDeclarationTypes() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/publicApproximation/declarationTypes.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("intersectionAfterSmartCastInLambdaReturn.kt")
|
||||
public void testIntersectionAfterSmartCastInLambdaReturn() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/publicApproximation/intersectionAfterSmartCastInLambdaReturn.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("intersectionAlternative.kt")
|
||||
public void testIntersectionAlternative() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/publicApproximation/intersectionAlternative.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("intersectionLocations.kt")
|
||||
public void testIntersectionLocations() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/publicApproximation/intersectionLocations.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lambdaReturnArgumentCall.kt")
|
||||
public void testLambdaReturnArgumentCall() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/publicApproximation/lambdaReturnArgumentCall.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lambdaReturnTypeApproximation.kt")
|
||||
public void testLambdaReturnTypeApproximation() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/publicApproximation/lambdaReturnTypeApproximation.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nonTrivialVariance.kt")
|
||||
public void testNonTrivialVariance() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/publicApproximation/nonTrivialVariance.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("parameterInBound.kt")
|
||||
public void testParameterInBound() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/publicApproximation/parameterInBound.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("projections.kt")
|
||||
public void testProjections() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/publicApproximation/projections.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("smartCastInLambdaReturnAfterIntersection.kt")
|
||||
public void testSmartCastInLambdaReturnAfterIntersection() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/publicApproximation/smartCastInLambdaReturnAfterIntersection.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("twoIntersections.kt")
|
||||
public void testTwoIntersections() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/publicApproximation/twoIntersections.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/inference/recursiveCalls")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
+5
@@ -2881,6 +2881,11 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/inference/kt35847.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt36249.kt")
|
||||
public void testKt36249() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/inference/kt36249.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt4975.kt")
|
||||
public void testKt4975() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/inference/kt4975.kt");
|
||||
|
||||
compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java
Generated
+5
@@ -2881,6 +2881,11 @@ public class DiagnosticsTestWithStdLibUsingJavacGenerated extends AbstractDiagno
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/inference/kt35847.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt36249.kt")
|
||||
public void testKt36249() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/inference/kt36249.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt4975.kt")
|
||||
public void testKt4975() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/inference/kt4975.kt");
|
||||
|
||||
Generated
+83
@@ -10228,6 +10228,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
|
||||
runTest("compiler/testData/diagnostics/tests/inference/tooEagerSmartcast.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("topLevelIntersection.kt")
|
||||
public void testTopLevelIntersection() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/topLevelIntersection.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("tryNumberLowerBoundsBeforeUpperBounds.kt")
|
||||
public void testTryNumberLowerBoundsBeforeUpperBounds() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/tryNumberLowerBoundsBeforeUpperBounds.kt");
|
||||
@@ -11024,6 +11029,84 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/inference/publicApproximation")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class PublicApproximation extends AbstractDiagnosticsUsingJavacTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInPublicApproximation() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/inference/publicApproximation"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("approximatedIntersectionMorePreciseThanBound.kt")
|
||||
public void testApproximatedIntersectionMorePreciseThanBound() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/publicApproximation/approximatedIntersectionMorePreciseThanBound.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("chainedLambdas.kt")
|
||||
public void testChainedLambdas() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/publicApproximation/chainedLambdas.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("declarationTypes.kt")
|
||||
public void testDeclarationTypes() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/publicApproximation/declarationTypes.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("intersectionAfterSmartCastInLambdaReturn.kt")
|
||||
public void testIntersectionAfterSmartCastInLambdaReturn() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/publicApproximation/intersectionAfterSmartCastInLambdaReturn.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("intersectionAlternative.kt")
|
||||
public void testIntersectionAlternative() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/publicApproximation/intersectionAlternative.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("intersectionLocations.kt")
|
||||
public void testIntersectionLocations() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/publicApproximation/intersectionLocations.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lambdaReturnArgumentCall.kt")
|
||||
public void testLambdaReturnArgumentCall() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/publicApproximation/lambdaReturnArgumentCall.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lambdaReturnTypeApproximation.kt")
|
||||
public void testLambdaReturnTypeApproximation() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/publicApproximation/lambdaReturnTypeApproximation.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nonTrivialVariance.kt")
|
||||
public void testNonTrivialVariance() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/publicApproximation/nonTrivialVariance.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("parameterInBound.kt")
|
||||
public void testParameterInBound() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/publicApproximation/parameterInBound.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("projections.kt")
|
||||
public void testProjections() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/publicApproximation/projections.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("smartCastInLambdaReturnAfterIntersection.kt")
|
||||
public void testSmartCastInLambdaReturnAfterIntersection() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/publicApproximation/smartCastInLambdaReturnAfterIntersection.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("twoIntersections.kt")
|
||||
public void testTwoIntersections() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/publicApproximation/twoIntersections.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/inference/recursiveCalls")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
@@ -27,6 +27,15 @@ import org.jetbrains.kotlin.types.refinement.TypeRefinement
|
||||
import java.util.*
|
||||
|
||||
class IntersectionTypeConstructor(typesToIntersect: Collection<KotlinType>) : TypeConstructor {
|
||||
private var alternative: KotlinType? = null
|
||||
|
||||
private constructor(
|
||||
typesToIntersect: Collection<KotlinType>,
|
||||
alternative: KotlinType?,
|
||||
) : this(typesToIntersect) {
|
||||
this.alternative = alternative
|
||||
}
|
||||
|
||||
init {
|
||||
assert(!typesToIntersect.isEmpty()) { "Attempt to create an empty intersection" }
|
||||
}
|
||||
@@ -75,7 +84,13 @@ class IntersectionTypeConstructor(typesToIntersect: Collection<KotlinType>) : Ty
|
||||
|
||||
@TypeRefinement
|
||||
override fun refine(kotlinTypeRefiner: KotlinTypeRefiner) =
|
||||
IntersectionTypeConstructor(intersectedTypes.map { it.refine(kotlinTypeRefiner) })
|
||||
transformComponents { it.refine(kotlinTypeRefiner) } ?: this
|
||||
|
||||
fun setAlternative(alternative: KotlinType?): IntersectionTypeConstructor {
|
||||
return IntersectionTypeConstructor(intersectedTypes, alternative)
|
||||
}
|
||||
|
||||
fun getAlternativeType(): KotlinType? = alternative
|
||||
}
|
||||
|
||||
inline fun IntersectionTypeConstructor.transformComponents(
|
||||
@@ -94,5 +109,9 @@ inline fun IntersectionTypeConstructor.transformComponents(
|
||||
|
||||
if (!changed) return null
|
||||
|
||||
return IntersectionTypeConstructor(newSupertypes)
|
||||
val updatedAlternative = getAlternativeType()?.let { alternative ->
|
||||
if (predicate(alternative)) transform(alternative) else alternative
|
||||
}
|
||||
|
||||
return IntersectionTypeConstructor(newSupertypes).setAlternative(updatedAlternative)
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.jetbrains.kotlin.types.model.*
|
||||
import org.jetbrains.kotlin.types.typeUtil.asTypeProjection
|
||||
import org.jetbrains.kotlin.types.typeUtil.contains
|
||||
import org.jetbrains.kotlin.types.typeUtil.representativeUpperBound
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||
import kotlin.contracts.ExperimentalContracts
|
||||
import kotlin.contracts.contract
|
||||
|
||||
@@ -606,6 +607,21 @@ interface ClassicTypeSystemContext : TypeSystemInferenceExtensionContext, TypeSy
|
||||
val descriptor = constructor.declarationDescriptor
|
||||
return descriptor is ClassDescriptor && (descriptor.kind == ClassKind.INTERFACE || descriptor.kind == ClassKind.ANNOTATION_CLASS)
|
||||
}
|
||||
|
||||
override fun createTypeWithAlternativeForIntersectionResult(
|
||||
firstCandidate: KotlinTypeMarker,
|
||||
secondCandidate: KotlinTypeMarker,
|
||||
): KotlinTypeMarker {
|
||||
require(firstCandidate is KotlinType, this::errorMessage)
|
||||
require(secondCandidate is KotlinType, this::errorMessage)
|
||||
|
||||
firstCandidate.constructor.safeAs<IntersectionTypeConstructor>()?.let { intersectionConstructor ->
|
||||
val intersectionTypeWithAlternative = intersectionConstructor.setAlternative(secondCandidate).createType()
|
||||
return if (firstCandidate.isMarkedNullable) intersectionTypeWithAlternative.makeNullableAsSpecified(true)
|
||||
else intersectionTypeWithAlternative
|
||||
|
||||
} ?: error("Expected intersection type, found $firstCandidate")
|
||||
}
|
||||
}
|
||||
|
||||
fun TypeVariance.convertVariance(): Variance {
|
||||
|
||||
@@ -164,6 +164,11 @@ interface TypeSystemInferenceExtensionContext : TypeSystemContext, TypeSystemBui
|
||||
|
||||
|
||||
fun TypeVariableMarker.defaultType(): SimpleTypeMarker
|
||||
|
||||
fun createTypeWithAlternativeForIntersectionResult(
|
||||
firstCandidate: KotlinTypeMarker,
|
||||
secondCandidate: KotlinTypeMarker
|
||||
): KotlinTypeMarker
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user