[FE 1.0] Introduce deprecation of inferred type variable into a declared upper bound within a builder inference call
This commit is contained in:
committed by
teamcity
parent
848075192c
commit
b472ccd358
+15
-3
@@ -14220,9 +14220,21 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("kt47986.kt")
|
@TestMetadata("kt47986Default.kt")
|
||||||
public void testKt47986() throws Exception {
|
public void testKt47986Default() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt47986.kt");
|
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt47986Default.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt47986Disabled.kt")
|
||||||
|
public void testKt47986Disabled() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt47986Disabled.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt47986Enabled.kt")
|
||||||
|
public void testKt47986Enabled() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt47986Enabled.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
+15
-3
@@ -14220,9 +14220,21 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("kt47986.kt")
|
@TestMetadata("kt47986Default.kt")
|
||||||
public void testKt47986() throws Exception {
|
public void testKt47986Default() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt47986.kt");
|
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt47986Default.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt47986Disabled.kt")
|
||||||
|
public void testKt47986Disabled() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt47986Disabled.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt47986Enabled.kt")
|
||||||
|
public void testKt47986Enabled() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt47986Enabled.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
+15
-3
@@ -14220,9 +14220,21 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("kt47986.kt")
|
@TestMetadata("kt47986Default.kt")
|
||||||
public void testKt47986() throws Exception {
|
public void testKt47986Default() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt47986.kt");
|
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt47986Default.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt47986Disabled.kt")
|
||||||
|
public void testKt47986Disabled() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt47986Disabled.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt47986Enabled.kt")
|
||||||
|
public void testKt47986Enabled() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt47986Enabled.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -890,6 +890,7 @@ public interface Errors {
|
|||||||
|
|
||||||
DiagnosticFactory1<PsiElement, InferenceErrorData> TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER = DiagnosticFactory1.create(ERROR);
|
DiagnosticFactory1<PsiElement, InferenceErrorData> TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER = DiagnosticFactory1.create(ERROR);
|
||||||
DiagnosticFactory1<PsiElement, String> NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER = DiagnosticFactory1.create(ERROR);
|
DiagnosticFactory1<PsiElement, String> NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER = DiagnosticFactory1.create(ERROR);
|
||||||
|
DiagnosticFactory1<PsiElement, String> INFERRED_INTO_DECLARED_UPPER_BOUNDS = DiagnosticFactory1.create(WARNING);
|
||||||
DiagnosticFactory1<PsiElement, String> COULD_BE_INFERRED_ONLY_WITH_UNRESTRICTED_BUILDER_INFERENCE = DiagnosticFactory1.create(ERROR);
|
DiagnosticFactory1<PsiElement, String> COULD_BE_INFERRED_ONLY_WITH_UNRESTRICTED_BUILDER_INFERENCE = DiagnosticFactory1.create(ERROR);
|
||||||
|
|
||||||
DiagnosticFactory1<PsiElement, InferenceErrorData> TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS = DiagnosticFactory1.create(ERROR);
|
DiagnosticFactory1<PsiElement, InferenceErrorData> TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS = DiagnosticFactory1.create(ERROR);
|
||||||
|
|||||||
+2
@@ -959,6 +959,8 @@ public class DefaultErrorMessages {
|
|||||||
MAP.put(TYPE_INFERENCE_CANNOT_CAPTURE_TYPES, "Type inference failed: {0}", TYPE_INFERENCE_CANNOT_CAPTURE_TYPES_RENDERER);
|
MAP.put(TYPE_INFERENCE_CANNOT_CAPTURE_TYPES, "Type inference failed: {0}", TYPE_INFERENCE_CANNOT_CAPTURE_TYPES_RENDERER);
|
||||||
MAP.put(TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER, "Type inference failed: {0}", TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER_RENDERER);
|
MAP.put(TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER, "Type inference failed: {0}", TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER_RENDERER);
|
||||||
MAP.put(NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER, "Not enough information to infer type variable {0}", STRING);
|
MAP.put(NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER, "Not enough information to infer type variable {0}", STRING);
|
||||||
|
MAP.put(INFERRED_INTO_DECLARED_UPPER_BOUNDS, "Type parameter for a type argument {0} can''t be inferred into declared upper bounds. " +
|
||||||
|
"Please provide any use-site type information. It will become an error in future releases.", STRING);
|
||||||
MAP.put(COULD_BE_INFERRED_ONLY_WITH_UNRESTRICTED_BUILDER_INFERENCE, "Builder inference lambda contains inapplicable calls so {0} can''t be inferred. It could be resolved only with unrestricted builder inference. Please use -Xunrestricted-builder-inference compiler flag to enable it.", STRING);
|
MAP.put(COULD_BE_INFERRED_ONLY_WITH_UNRESTRICTED_BUILDER_INFERENCE, "Builder inference lambda contains inapplicable calls so {0} can''t be inferred. It could be resolved only with unrestricted builder inference. Please use -Xunrestricted-builder-inference compiler flag to enable it.", STRING);
|
||||||
|
|
||||||
MAP.put(TYPE_INFERENCE_PARAMETER_CONSTRAINT_ERROR, "Type inference failed: {0}", TYPE_INFERENCE_PARAMETER_CONSTRAINT_ERROR_RENDERER);
|
MAP.put(TYPE_INFERENCE_PARAMETER_CONSTRAINT_ERROR, "Type inference failed: {0}", TYPE_INFERENCE_PARAMETER_CONSTRAINT_ERROR_RENDERER);
|
||||||
|
|||||||
+16
@@ -541,6 +541,22 @@ class DiagnosticReporterByTrackingStrategy(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
InferredIntoDeclaredUpperBounds::class.java -> {
|
||||||
|
error as InferredIntoDeclaredUpperBounds
|
||||||
|
|
||||||
|
val psiCall = psiKotlinCall.psiCall
|
||||||
|
val expression = if (psiCall is CallTransformer.CallForImplicitInvoke) {
|
||||||
|
psiCall.outerCall.calleeExpression
|
||||||
|
} else {
|
||||||
|
psiCall.calleeExpression
|
||||||
|
} ?: return
|
||||||
|
val typeVariable = error.typeVariable as? TypeVariableFromCallableDescriptor ?: return
|
||||||
|
|
||||||
|
trace.reportDiagnosticOnce(
|
||||||
|
INFERRED_INTO_DECLARED_UPPER_BOUNDS.on(expression, typeVariable.originalTypeParameter.name.asString())
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
NotEnoughInformationForTypeParameterImpl::class.java -> {
|
NotEnoughInformationForTypeParameterImpl::class.java -> {
|
||||||
error as NotEnoughInformationForTypeParameterImpl
|
error as NotEnoughInformationForTypeParameterImpl
|
||||||
|
|
||||||
|
|||||||
+8
-3
@@ -6,6 +6,7 @@
|
|||||||
package org.jetbrains.kotlin.resolve.calls.inference
|
package org.jetbrains.kotlin.resolve.calls.inference
|
||||||
|
|
||||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||||
|
import org.jetbrains.kotlin.config.LanguageFeature
|
||||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.impl.AnonymousFunctionDescriptor
|
import org.jetbrains.kotlin.descriptors.impl.AnonymousFunctionDescriptor
|
||||||
@@ -34,7 +35,6 @@ import org.jetbrains.kotlin.types.*
|
|||||||
import org.jetbrains.kotlin.types.checker.NewCapturedType
|
import org.jetbrains.kotlin.types.checker.NewCapturedType
|
||||||
import org.jetbrains.kotlin.types.expressions.DoubleColonExpressionResolver
|
import org.jetbrains.kotlin.types.expressions.DoubleColonExpressionResolver
|
||||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices
|
import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices
|
||||||
import org.jetbrains.kotlin.types.model.freshTypeConstructor
|
|
||||||
import org.jetbrains.kotlin.types.model.safeSubstitute
|
import org.jetbrains.kotlin.types.model.safeSubstitute
|
||||||
import org.jetbrains.kotlin.types.typeUtil.asTypeProjection
|
import org.jetbrains.kotlin.types.typeUtil.asTypeProjection
|
||||||
import org.jetbrains.kotlin.types.typeUtil.contains
|
import org.jetbrains.kotlin.types.typeUtil.contains
|
||||||
@@ -589,10 +589,15 @@ class BuilderInferenceSession(
|
|||||||
|
|
||||||
if (lowerSubstituted == a && upperSubstituted == b) return this
|
if (lowerSubstituted == a && upperSubstituted == b) return this
|
||||||
|
|
||||||
val resultingPosition = if (upperSubstituted == b && position is DeclaredUpperBoundConstraintPosition<*>) {
|
val isInferringIntoUpperBoundsForbidden = expressionTypingServices.languageVersionSettings.supportsFeature(
|
||||||
|
LanguageFeature.ForbidInferringPostponedTypeVariableIntoDeclaredUpperBound
|
||||||
|
)
|
||||||
|
val isFromNotSubstitutedDeclaredUpperBound = upperSubstituted == b && position is DeclaredUpperBoundConstraintPosition<*>
|
||||||
|
|
||||||
|
val resultingPosition = if (isFromNotSubstitutedDeclaredUpperBound && isInferringIntoUpperBoundsForbidden) {
|
||||||
position
|
position
|
||||||
} else {
|
} else {
|
||||||
BuilderInferenceSubstitutionConstraintPositionImpl(lambdaArgument, this)
|
BuilderInferenceSubstitutionConstraintPositionImpl(lambdaArgument, this, isFromNotSubstitutedDeclaredUpperBound)
|
||||||
}
|
}
|
||||||
|
|
||||||
return InitialConstraint(
|
return InitialConstraint(
|
||||||
|
|||||||
+7
-2
@@ -24,8 +24,11 @@ abstract class InjectedAnotherStubTypeConstraintPosition<T>(private val builderI
|
|||||||
override fun toString(): String = "Injected from $builderInferenceLambdaOfInjectedStubType builder inference call"
|
override fun toString(): String = "Injected from $builderInferenceLambdaOfInjectedStubType builder inference call"
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class BuilderInferenceSubstitutionConstraintPosition<L, I>(private val builderInferenceLambda: L, val initialConstraint: I) :
|
abstract class BuilderInferenceSubstitutionConstraintPosition<L, I>(
|
||||||
ConstraintPosition(), OnlyInputTypeConstraintPosition {
|
private val builderInferenceLambda: L,
|
||||||
|
val initialConstraint: I,
|
||||||
|
val isFromNotSubstitutedDeclaredUpperBound: Boolean = false
|
||||||
|
) : ConstraintPosition(), OnlyInputTypeConstraintPosition {
|
||||||
override fun toString(): String = "Incorporated builder inference constraint $initialConstraint " +
|
override fun toString(): String = "Incorporated builder inference constraint $initialConstraint " +
|
||||||
"into $builderInferenceLambda call"
|
"into $builderInferenceLambda call"
|
||||||
}
|
}
|
||||||
@@ -128,6 +131,8 @@ open class NotEnoughInformationForTypeParameter<T>(
|
|||||||
val couldBeResolvedWithUnrestrictedBuilderInference: Boolean
|
val couldBeResolvedWithUnrestrictedBuilderInference: Boolean
|
||||||
) : ConstraintSystemError(INAPPLICABLE)
|
) : ConstraintSystemError(INAPPLICABLE)
|
||||||
|
|
||||||
|
class InferredIntoDeclaredUpperBounds(val typeVariable: TypeVariableMarker) : ConstraintSystemError(RESOLVED)
|
||||||
|
|
||||||
class ConstrainingTypeIsError(
|
class ConstrainingTypeIsError(
|
||||||
val typeVariable: TypeVariableMarker,
|
val typeVariable: TypeVariableMarker,
|
||||||
val constraintType: KotlinTypeMarker,
|
val constraintType: KotlinTypeMarker,
|
||||||
|
|||||||
+31
-6
@@ -150,8 +150,11 @@ class KotlinConstraintSystemCompleter(
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
// Stage 6: fix next ready type variable with proper constraints
|
// Stage 6: fix next ready type variable with proper constraints
|
||||||
if (fixNextReadyVariable(completionMode, topLevelAtoms, topLevelType, collectVariablesFromContext, postponedArguments))
|
if (
|
||||||
continue
|
fixNextReadyVariable(
|
||||||
|
completionMode, topLevelAtoms, topLevelType, collectVariablesFromContext, postponedArguments, diagnosticsHolder
|
||||||
|
)
|
||||||
|
) continue
|
||||||
|
|
||||||
// Stage 7: try to complete call with the builder inference if there are uninferred type variables
|
// Stage 7: try to complete call with the builder inference if there are uninferred type variables
|
||||||
val areThereAppearedProperConstraintsForSomeVariable = tryToCompleteWithBuilderInference(
|
val areThereAppearedProperConstraintsForSomeVariable = tryToCompleteWithBuilderInference(
|
||||||
@@ -272,6 +275,7 @@ class KotlinConstraintSystemCompleter(
|
|||||||
topLevelType: UnwrappedType,
|
topLevelType: UnwrappedType,
|
||||||
collectVariablesFromContext: Boolean,
|
collectVariablesFromContext: Boolean,
|
||||||
postponedArguments: List<PostponedResolvedAtom>,
|
postponedArguments: List<PostponedResolvedAtom>,
|
||||||
|
diagnosticsHolder: KotlinDiagnosticsHolder
|
||||||
): Boolean {
|
): Boolean {
|
||||||
val variableForFixation = variableFixationFinder.findFirstVariableForFixation(
|
val variableForFixation = variableFixationFinder.findFirstVariableForFixation(
|
||||||
this,
|
this,
|
||||||
@@ -283,7 +287,7 @@ class KotlinConstraintSystemCompleter(
|
|||||||
|
|
||||||
if (!variableForFixation.hasProperConstraint) return false
|
if (!variableForFixation.hasProperConstraint) return false
|
||||||
|
|
||||||
fixVariable(this, notFixedTypeVariables.getValue(variableForFixation.variable), topLevelAtoms)
|
fixVariable(this, notFixedTypeVariables.getValue(variableForFixation.variable), topLevelAtoms, diagnosticsHolder)
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@@ -405,20 +409,41 @@ class KotlinConstraintSystemCompleter(
|
|||||||
private fun fixVariable(
|
private fun fixVariable(
|
||||||
c: ConstraintSystemCompletionContext,
|
c: ConstraintSystemCompletionContext,
|
||||||
variableWithConstraints: VariableWithConstraints,
|
variableWithConstraints: VariableWithConstraints,
|
||||||
topLevelAtoms: List<ResolvedAtom>
|
topLevelAtoms: List<ResolvedAtom>,
|
||||||
|
diagnosticsHolder: KotlinDiagnosticsHolder
|
||||||
) {
|
) {
|
||||||
fixVariable(c, variableWithConstraints, TypeVariableDirectionCalculator.ResolveDirection.UNKNOWN, topLevelAtoms)
|
fixVariable(c, variableWithConstraints, TypeVariableDirectionCalculator.ResolveDirection.UNKNOWN, topLevelAtoms, diagnosticsHolder)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun reportWarningIfFixedIntoDeclaredUpperBounds(
|
||||||
|
diagnosticsHolder: KotlinDiagnosticsHolder,
|
||||||
|
variableWithConstraints: VariableWithConstraints
|
||||||
|
) {
|
||||||
|
val areAllConstraintFromDeclaredUpperBounds = variableWithConstraints.constraints.all {
|
||||||
|
val position = it.position.from
|
||||||
|
position is BuilderInferenceSubstitutionConstraintPosition<*, *> && position.isFromNotSubstitutedDeclaredUpperBound
|
||||||
|
}
|
||||||
|
|
||||||
|
if (areAllConstraintFromDeclaredUpperBounds) {
|
||||||
|
diagnosticsHolder.addDiagnostic(
|
||||||
|
KotlinConstraintSystemDiagnostic(InferredIntoDeclaredUpperBounds(variableWithConstraints.typeVariable))
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun fixVariable(
|
private fun fixVariable(
|
||||||
c: ConstraintSystemCompletionContext,
|
c: ConstraintSystemCompletionContext,
|
||||||
variableWithConstraints: VariableWithConstraints,
|
variableWithConstraints: VariableWithConstraints,
|
||||||
direction: TypeVariableDirectionCalculator.ResolveDirection,
|
direction: TypeVariableDirectionCalculator.ResolveDirection,
|
||||||
topLevelAtoms: List<ResolvedAtom>
|
topLevelAtoms: List<ResolvedAtom>,
|
||||||
|
diagnosticsHolder: KotlinDiagnosticsHolder
|
||||||
) {
|
) {
|
||||||
val resultType = resultTypeResolver.findResultType(c, variableWithConstraints, direction)
|
val resultType = resultTypeResolver.findResultType(c, variableWithConstraints, direction)
|
||||||
val variable = variableWithConstraints.typeVariable
|
val variable = variableWithConstraints.typeVariable
|
||||||
val resolvedAtom = findResolvedAtomBy(variable, topLevelAtoms) ?: topLevelAtoms.firstOrNull()
|
val resolvedAtom = findResolvedAtomBy(variable, topLevelAtoms) ?: topLevelAtoms.firstOrNull()
|
||||||
|
|
||||||
|
reportWarningIfFixedIntoDeclaredUpperBounds(diagnosticsHolder, variableWithConstraints)
|
||||||
|
|
||||||
c.fixVariable(variable, resultType, FixVariableConstraintPositionImpl(variable, resolvedAtom))
|
c.fixVariable(variable, resultType, FixVariableConstraintPositionImpl(variable, resolvedAtom))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-3
@@ -7,7 +7,6 @@ package org.jetbrains.kotlin.resolve.calls.inference.model
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||||
import org.jetbrains.kotlin.resolve.calls.model.*
|
import org.jetbrains.kotlin.resolve.calls.model.*
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.DetailedReceiver
|
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
import org.jetbrains.kotlin.types.model.TypeVariableMarker
|
import org.jetbrains.kotlin.types.model.TypeVariableMarker
|
||||||
|
|
||||||
@@ -19,9 +18,11 @@ class InjectedAnotherStubTypeConstraintPositionImpl(builderInferenceLambdaOfInje
|
|||||||
InjectedAnotherStubTypeConstraintPosition<LambdaKotlinCallArgument>(builderInferenceLambdaOfInjectedStubType)
|
InjectedAnotherStubTypeConstraintPosition<LambdaKotlinCallArgument>(builderInferenceLambdaOfInjectedStubType)
|
||||||
|
|
||||||
class BuilderInferenceSubstitutionConstraintPositionImpl(
|
class BuilderInferenceSubstitutionConstraintPositionImpl(
|
||||||
builderInferenceLambda: LambdaKotlinCallArgument, initialConstraint: InitialConstraint
|
builderInferenceLambda: LambdaKotlinCallArgument,
|
||||||
|
initialConstraint: InitialConstraint,
|
||||||
|
isFromNotSubstitutedDeclaredUpperBound: Boolean = false
|
||||||
) : BuilderInferenceSubstitutionConstraintPosition<LambdaKotlinCallArgument, InitialConstraint>(
|
) : BuilderInferenceSubstitutionConstraintPosition<LambdaKotlinCallArgument, InitialConstraint>(
|
||||||
builderInferenceLambda, initialConstraint
|
builderInferenceLambda, initialConstraint, isFromNotSubstitutedDeclaredUpperBound
|
||||||
)
|
)
|
||||||
|
|
||||||
class ExpectedTypeConstraintPositionImpl(topLevelCall: KotlinCall) : ExpectedTypeConstraintPosition<KotlinCall>(topLevelCall)
|
class ExpectedTypeConstraintPositionImpl(topLevelCall: KotlinCall) : ExpectedTypeConstraintPosition<KotlinCall>(topLevelCall)
|
||||||
|
|||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
/kt47986Default.kt:4:18: warning: parameter 'builderAction' is never used
|
||||||
|
fun <K> buildFoo(builderAction: Foo<K>.() -> Unit): Foo<K> = Foo()
|
||||||
|
^
|
||||||
|
/kt47986Default.kt:6:20: warning: parameter 'x' is never used
|
||||||
|
fun <K> Foo<K>.bar(x: Int = 1) {}
|
||||||
|
^
|
||||||
|
/kt47986Default.kt:9:9: warning: variable 'x' is never used
|
||||||
|
val x = buildFoo {
|
||||||
|
^
|
||||||
|
/kt47986Default.kt:9:13: warning: type parameter for a type argument K can't be inferred into declared upper bounds. Please provide any use-site type information. It will become an error in future releases.
|
||||||
|
val x = buildFoo {
|
||||||
|
^
|
||||||
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
// FIR_IDENTICAL
|
// !RENDER_DIAGNOSTICS_FULL_TEXT
|
||||||
class Foo<K>
|
class Foo<K>
|
||||||
|
|
||||||
fun <K> buildFoo(builderAction: Foo<K>.() -> Unit): Foo<K> = Foo()
|
fun <K> buildFoo(builderAction: Foo<K>.() -> Unit): Foo<K> = Foo()
|
||||||
@@ -9,4 +9,4 @@ fun main() {
|
|||||||
val x = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>buildFoo<!> {
|
val x = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>buildFoo<!> {
|
||||||
bar()
|
bar()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
// !RENDER_DIAGNOSTICS_FULL_TEXT
|
||||||
|
class Foo<K>
|
||||||
|
|
||||||
|
fun <K> buildFoo(builderAction: Foo<K>.() -> Unit): Foo<K> = Foo()
|
||||||
|
|
||||||
|
fun <K> Foo<K>.bar(x: Int = 1) {}
|
||||||
|
|
||||||
|
fun main() {
|
||||||
|
val x = <!INFERRED_INTO_DECLARED_UPPER_BOUNDS!>buildFoo<!> {
|
||||||
|
bar()
|
||||||
|
}
|
||||||
|
}
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
/kt47986Disabled.kt:5:18: warning: parameter 'builderAction' is never used
|
||||||
|
fun <K> buildFoo(builderAction: Foo<K>.() -> Unit): Foo<K> = Foo()
|
||||||
|
^
|
||||||
|
/kt47986Disabled.kt:7:20: warning: parameter 'x' is never used
|
||||||
|
fun <K> Foo<K>.bar(x: Int = 1) {}
|
||||||
|
^
|
||||||
|
/kt47986Disabled.kt:10:9: warning: variable 'x' is never used
|
||||||
|
val x = buildFoo {
|
||||||
|
^
|
||||||
|
/kt47986Disabled.kt:10:13: warning: type parameter for a type argument K can't be inferred into declared upper bounds. Please provide any use-site type information. It will become an error in future releases.
|
||||||
|
val x = buildFoo {
|
||||||
|
^
|
||||||
+13
@@ -0,0 +1,13 @@
|
|||||||
|
// !RENDER_DIAGNOSTICS_FULL_TEXT
|
||||||
|
// !LANGUAGE: -ForbidInferringPostponedTypeVariableIntoDeclaredUpperBound
|
||||||
|
class Foo<K>
|
||||||
|
|
||||||
|
fun <K> buildFoo(builderAction: Foo<K>.() -> Unit): Foo<K> = Foo()
|
||||||
|
|
||||||
|
fun <K> Foo<K>.bar(x: Int = 1) {}
|
||||||
|
|
||||||
|
fun main() {
|
||||||
|
val x = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>buildFoo<!> {
|
||||||
|
bar()
|
||||||
|
}
|
||||||
|
}
|
||||||
+13
@@ -0,0 +1,13 @@
|
|||||||
|
// !RENDER_DIAGNOSTICS_FULL_TEXT
|
||||||
|
// !LANGUAGE: -ForbidInferringPostponedTypeVariableIntoDeclaredUpperBound
|
||||||
|
class Foo<K>
|
||||||
|
|
||||||
|
fun <K> buildFoo(builderAction: Foo<K>.() -> Unit): Foo<K> = Foo()
|
||||||
|
|
||||||
|
fun <K> Foo<K>.bar(x: Int = 1) {}
|
||||||
|
|
||||||
|
fun main() {
|
||||||
|
val x = <!INFERRED_INTO_DECLARED_UPPER_BOUNDS!>buildFoo<!> {
|
||||||
|
bar()
|
||||||
|
}
|
||||||
|
}
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public fun </*0*/ K> buildFoo(/*0*/ builderAction: Foo<K>.() -> kotlin.Unit): Foo<K>
|
||||||
|
public fun main(): kotlin.Unit
|
||||||
|
public fun </*0*/ K> Foo<K>.bar(/*0*/ x: kotlin.Int = ...): kotlin.Unit
|
||||||
|
|
||||||
|
public final class Foo</*0*/ K> {
|
||||||
|
public constructor Foo</*0*/ K>()
|
||||||
|
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
|
||||||
|
}
|
||||||
+13
@@ -0,0 +1,13 @@
|
|||||||
|
// FIR_IDENTICAL
|
||||||
|
// !LANGUAGE: +ForbidInferringPostponedTypeVariableIntoDeclaredUpperBound
|
||||||
|
class Foo<K>
|
||||||
|
|
||||||
|
fun <K> buildFoo(builderAction: Foo<K>.() -> Unit): Foo<K> = Foo()
|
||||||
|
|
||||||
|
fun <K> Foo<K>.bar(x: Int = 1) {}
|
||||||
|
|
||||||
|
fun main() {
|
||||||
|
val x = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>buildFoo<!> {
|
||||||
|
bar()
|
||||||
|
}
|
||||||
|
}
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public fun </*0*/ K> buildFoo(/*0*/ builderAction: Foo<K>.() -> kotlin.Unit): Foo<K>
|
||||||
|
public fun main(): kotlin.Unit
|
||||||
|
public fun </*0*/ K> Foo<K>.bar(/*0*/ x: kotlin.Int = ...): kotlin.Unit
|
||||||
|
|
||||||
|
public final class Foo</*0*/ K> {
|
||||||
|
public constructor Foo</*0*/ K>()
|
||||||
|
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
|
||||||
|
}
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
/kt47986_2.kt:4:18: warning: parameter 'builderAction' is never used
|
||||||
|
fun <K> buildFoo(builderAction: Foo<K>.() -> Unit): Foo<K> = Foo()
|
||||||
|
^
|
||||||
|
/kt47986_2.kt:11:9: warning: variable 'x' is never used
|
||||||
|
val x = buildFoo { // can't infer
|
||||||
|
^
|
||||||
|
/kt47986_2.kt:11:13: warning: type parameter for a type argument K can't be inferred into declared upper bounds. Please provide any use-site type information. It will become an error in future releases.
|
||||||
|
val x = buildFoo { // can't infer
|
||||||
|
^
|
||||||
|
/kt47986_2.kt:12:13: warning: variable 'y' is never used
|
||||||
|
val y = id(::bar)
|
||||||
|
^
|
||||||
+14
@@ -0,0 +1,14 @@
|
|||||||
|
// !RENDER_DIAGNOSTICS_FULL_TEXT
|
||||||
|
class Foo<K>
|
||||||
|
|
||||||
|
fun <K> buildFoo(builderAction: Foo<K>.() -> Unit): Foo<K> = Foo()
|
||||||
|
|
||||||
|
fun <L> Foo<L>.bar() {}
|
||||||
|
|
||||||
|
fun <K> id(x: K) = x
|
||||||
|
|
||||||
|
fun main() {
|
||||||
|
val x = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>buildFoo<!> { // can't infer
|
||||||
|
val y = id(::bar)
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
// FIR_IDENTICAL
|
// !RENDER_DIAGNOSTICS_FULL_TEXT
|
||||||
class Foo<K>
|
class Foo<K>
|
||||||
|
|
||||||
fun <K> buildFoo(builderAction: Foo<K>.() -> Unit): Foo<K> = Foo()
|
fun <K> buildFoo(builderAction: Foo<K>.() -> Unit): Foo<K> = Foo()
|
||||||
@@ -8,7 +8,7 @@ fun <L> Foo<L>.bar() {}
|
|||||||
fun <K> id(x: K) = x
|
fun <K> id(x: K) = x
|
||||||
|
|
||||||
fun main() {
|
fun main() {
|
||||||
val x = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>buildFoo<!> { // can't infer
|
val x = <!INFERRED_INTO_DECLARED_UPPER_BOUNDS!>buildFoo<!> { // can't infer
|
||||||
val y = id(::bar)
|
val y = id(::bar)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
/kt47986_3.kt:4:18: warning: parameter 'builderAction' is never used
|
||||||
|
fun <K> buildFoo(builderAction: Foo<K>.() -> Unit): Foo<K> = Foo()
|
||||||
|
^
|
||||||
|
/kt47986_3.kt:6:26: warning: parameter 'x' is never used
|
||||||
|
fun <K: N, N> Foo<K>.bar(x: Int = 1) {}
|
||||||
|
^
|
||||||
|
/kt47986_3.kt:9:9: warning: variable 'x' is never used
|
||||||
|
val x = buildFoo {
|
||||||
|
^
|
||||||
|
/kt47986_3.kt:9:13: warning: type parameter for a type argument K can't be inferred into declared upper bounds. Please provide any use-site type information. It will become an error in future releases.
|
||||||
|
val x = buildFoo {
|
||||||
|
^
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
// !RENDER_DIAGNOSTICS_FULL_TEXT
|
||||||
|
class Foo<K>
|
||||||
|
|
||||||
|
fun <K> buildFoo(builderAction: Foo<K>.() -> Unit): Foo<K> = Foo()
|
||||||
|
|
||||||
|
fun <K: N, N> Foo<K>.bar(x: Int = 1) {}
|
||||||
|
|
||||||
|
fun main() {
|
||||||
|
val x = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>buildFoo<!> {
|
||||||
|
bar()
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
// FIR_IDENTICAL
|
// !RENDER_DIAGNOSTICS_FULL_TEXT
|
||||||
class Foo<K>
|
class Foo<K>
|
||||||
|
|
||||||
fun <K> buildFoo(builderAction: Foo<K>.() -> Unit): Foo<K> = Foo()
|
fun <K> buildFoo(builderAction: Foo<K>.() -> Unit): Foo<K> = Foo()
|
||||||
@@ -6,7 +6,7 @@ fun <K> buildFoo(builderAction: Foo<K>.() -> Unit): Foo<K> = Foo()
|
|||||||
fun <K: N, N> Foo<K>.bar(x: Int = 1) {}
|
fun <K: N, N> Foo<K>.bar(x: Int = 1) {}
|
||||||
|
|
||||||
fun main() {
|
fun main() {
|
||||||
val x = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>buildFoo<!> {
|
val x = <!INFERRED_INTO_DECLARED_UPPER_BOUNDS!>buildFoo<!> {
|
||||||
bar()
|
bar()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
/kt51464.kt:2:16: warning: parameter 'value' is never used
|
||||||
|
fun <T> flowOf(value: T): Flow<T> = TODO()
|
||||||
|
^
|
||||||
|
/kt51464.kt:8:30: warning: parameter 'transform' is never used
|
||||||
|
fun <T, R> Flow<T>.transform(transform: FlowCollector<R>.(T) -> Unit): Flow<R> = TODO()
|
||||||
|
^
|
||||||
|
/kt51464.kt:11:20: warning: parameter 'collector' is never used
|
||||||
|
fun <T> doEmit(collector: FlowCollector<T>) {}
|
||||||
|
^
|
||||||
|
/kt51464.kt:12:15: warning: type parameter for a type argument R can't be inferred into declared upper bounds. Please provide any use-site type information. It will become an error in future releases.
|
||||||
|
flowOf(1).transform { doEmit(this) }
|
||||||
|
^
|
||||||
+1
-2
@@ -1,5 +1,4 @@
|
|||||||
import kotlinx.coroutines.flow.transform
|
// !RENDER_DIAGNOSTICS_FULL_TEXT
|
||||||
|
|
||||||
fun <T> flowOf(value: T): Flow<T> = TODO()
|
fun <T> flowOf(value: T): Flow<T> = TODO()
|
||||||
|
|
||||||
interface FlowCollector<in T> {}
|
interface FlowCollector<in T> {}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// !RENDER_DIAGNOSTICS_FULL_TEXT
|
||||||
fun <T> flowOf(value: T): Flow<T> = TODO()
|
fun <T> flowOf(value: T): Flow<T> = TODO()
|
||||||
|
|
||||||
interface FlowCollector<in T> {}
|
interface FlowCollector<in T> {}
|
||||||
@@ -8,5 +9,5 @@ fun <T, R> Flow<T>.transform(transform: FlowCollector<R>.(T) -> Unit): Flow<R> =
|
|||||||
|
|
||||||
fun f() {
|
fun f() {
|
||||||
fun <T> doEmit(collector: FlowCollector<T>) {}
|
fun <T> doEmit(collector: FlowCollector<T>) {}
|
||||||
flowOf(1).<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>transform<!> { doEmit(this) }
|
flowOf(1).<!INFERRED_INTO_DECLARED_UPPER_BOUNDS!>transform<!> { doEmit(this) }
|
||||||
}
|
}
|
||||||
Generated
+15
-3
@@ -14226,9 +14226,21 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("kt47986.kt")
|
@TestMetadata("kt47986Default.kt")
|
||||||
public void testKt47986() throws Exception {
|
public void testKt47986Default() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt47986.kt");
|
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt47986Default.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt47986Disabled.kt")
|
||||||
|
public void testKt47986Disabled() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt47986Disabled.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt47986Enabled.kt")
|
||||||
|
public void testKt47986Enabled() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/inference/builderInference/kt47986Enabled.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -278,6 +278,7 @@ enum class LanguageFeature(
|
|||||||
ReportErrorsOnRecursiveTypeInsidePlusAssignment(KOTLIN_1_9, kind = BUG_FIX), // KT-48546
|
ReportErrorsOnRecursiveTypeInsidePlusAssignment(KOTLIN_1_9, kind = BUG_FIX), // KT-48546
|
||||||
ForbidInferringTypeVariablesIntoEmptyIntersection(KOTLIN_1_9, kind = BUG_FIX), // KT-51221
|
ForbidInferringTypeVariablesIntoEmptyIntersection(KOTLIN_1_9, kind = BUG_FIX), // KT-51221
|
||||||
ForbidExtensionCallsOnInlineFunctionalParameters(KOTLIN_1_9, kind = BUG_FIX), // KT-52502
|
ForbidExtensionCallsOnInlineFunctionalParameters(KOTLIN_1_9, kind = BUG_FIX), // KT-52502
|
||||||
|
ForbidInferringPostponedTypeVariableIntoDeclaredUpperBound(KOTLIN_1_9, kind = BUG_FIX), // KT-47986
|
||||||
|
|
||||||
// Disabled for indefinite time. See KT-48535 and related discussion
|
// Disabled for indefinite time. See KT-48535 and related discussion
|
||||||
ApproximateIntegerLiteralTypesInReceiverPosition(sinceVersion = null),
|
ApproximateIntegerLiteralTypesInReceiverPosition(sinceVersion = null),
|
||||||
|
|||||||
Reference in New Issue
Block a user