Revert "[NI] Disable capturing/approximation type in TypeSubstitutor with enabled NI"
This reverts commit f20ec3e0a6.
This commit is contained in:
-2
@@ -45,7 +45,6 @@ import org.jetbrains.kotlin.resolve.lazy.declarations.DeclarationProviderFactory
|
|||||||
import org.jetbrains.kotlin.resolve.lazy.declarations.DeclarationProviderFactoryService
|
import org.jetbrains.kotlin.resolve.lazy.declarations.DeclarationProviderFactoryService
|
||||||
import org.jetbrains.kotlin.serialization.deserialization.MetadataPackageFragmentProvider
|
import org.jetbrains.kotlin.serialization.deserialization.MetadataPackageFragmentProvider
|
||||||
import org.jetbrains.kotlin.serialization.deserialization.MetadataPartProvider
|
import org.jetbrains.kotlin.serialization.deserialization.MetadataPartProvider
|
||||||
import org.jetbrains.kotlin.types.SubstitutingScopeProviderImpl
|
|
||||||
|
|
||||||
class CommonAnalysisParameters(
|
class CommonAnalysisParameters(
|
||||||
val metadataPartProviderFactory: (ModuleContent<*>) -> MetadataPartProvider
|
val metadataPartProviderFactory: (ModuleContent<*>) -> MetadataPartProvider
|
||||||
@@ -171,7 +170,6 @@ private fun createContainerToResolveCommonCode(
|
|||||||
|
|
||||||
configureCommonSpecificComponents()
|
configureCommonSpecificComponents()
|
||||||
useInstance(metadataPartProvider)
|
useInstance(metadataPartProvider)
|
||||||
useImpl<SubstitutingScopeProviderImpl>()
|
|
||||||
|
|
||||||
val metadataFinderFactory = ServiceManager.getService(
|
val metadataFinderFactory = ServiceManager.getService(
|
||||||
moduleContext.project,
|
moduleContext.project,
|
||||||
|
|||||||
-20
@@ -8086,11 +8086,6 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok
|
|||||||
runTest("compiler/testData/diagnostics/tests/generics/argumentsForT.kt");
|
runTest("compiler/testData/diagnostics/tests/generics/argumentsForT.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("capturedTypeInInputPosition.kt")
|
|
||||||
public void testCapturedTypeInInputPosition() throws Exception {
|
|
||||||
runTest("compiler/testData/diagnostics/tests/generics/capturedTypeInInputPosition.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("commonSupertypeContravariant.kt")
|
@TestMetadata("commonSupertypeContravariant.kt")
|
||||||
public void testCommonSupertypeContravariant() throws Exception {
|
public void testCommonSupertypeContravariant() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/generics/commonSupertypeContravariant.kt");
|
runTest("compiler/testData/diagnostics/tests/generics/commonSupertypeContravariant.kt");
|
||||||
@@ -8930,11 +8925,6 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok
|
|||||||
runTest("compiler/testData/diagnostics/tests/generics/varProjection/setterProjectedOutAssign.kt");
|
runTest("compiler/testData/diagnostics/tests/generics/varProjection/setterProjectedOutAssign.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("setterProjectedOutAssignFromJava.kt")
|
|
||||||
public void testSetterProjectedOutAssignFromJava() throws Exception {
|
|
||||||
runTest("compiler/testData/diagnostics/tests/generics/varProjection/setterProjectedOutAssignFromJava.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("setterProjectedOutNoPlusAssign.kt")
|
@TestMetadata("setterProjectedOutNoPlusAssign.kt")
|
||||||
public void testSetterProjectedOutNoPlusAssign() throws Exception {
|
public void testSetterProjectedOutNoPlusAssign() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/generics/varProjection/setterProjectedOutNoPlusAssign.kt");
|
runTest("compiler/testData/diagnostics/tests/generics/varProjection/setterProjectedOutNoPlusAssign.kt");
|
||||||
@@ -17373,11 +17363,6 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok
|
|||||||
runTest("compiler/testData/diagnostics/tests/resolve/HiddenDeclarations.kt");
|
runTest("compiler/testData/diagnostics/tests/resolve/HiddenDeclarations.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("implicitAndExplicitThis.kt")
|
|
||||||
public void testImplicitAndExplicitThis() throws Exception {
|
|
||||||
runTest("compiler/testData/diagnostics/tests/resolve/implicitAndExplicitThis.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("implicitReceiverProperty.kt")
|
@TestMetadata("implicitReceiverProperty.kt")
|
||||||
public void testImplicitReceiverProperty() throws Exception {
|
public void testImplicitReceiverProperty() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/resolve/implicitReceiverProperty.kt");
|
runTest("compiler/testData/diagnostics/tests/resolve/implicitReceiverProperty.kt");
|
||||||
@@ -18095,11 +18080,6 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok
|
|||||||
runTest("compiler/testData/diagnostics/tests/samConversions/GenericSubstitutionKT.kt");
|
runTest("compiler/testData/diagnostics/tests/samConversions/GenericSubstitutionKT.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("kt25290.kt")
|
|
||||||
public void testKt25290() throws Exception {
|
|
||||||
runTest("compiler/testData/diagnostics/tests/samConversions/kt25290.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("OverloadPriority.kt")
|
@TestMetadata("OverloadPriority.kt")
|
||||||
public void testOverloadPriority() throws Exception {
|
public void testOverloadPriority() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/samConversions/OverloadPriority.kt");
|
runTest("compiler/testData/diagnostics/tests/samConversions/OverloadPriority.kt");
|
||||||
|
|||||||
@@ -46,7 +46,6 @@ import org.jetbrains.kotlin.resolve.jvm.JavaDescriptorResolver
|
|||||||
import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatformAnalyzerServices
|
import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatformAnalyzerServices
|
||||||
import org.jetbrains.kotlin.resolve.lazy.KotlinCodeAnalyzer
|
import org.jetbrains.kotlin.resolve.lazy.KotlinCodeAnalyzer
|
||||||
import org.jetbrains.kotlin.resolve.lazy.declarations.DeclarationProviderFactory
|
import org.jetbrains.kotlin.resolve.lazy.declarations.DeclarationProviderFactory
|
||||||
import org.jetbrains.kotlin.types.SubstitutingScopeProviderImpl
|
|
||||||
|
|
||||||
fun createContainerForLazyResolveWithJava(
|
fun createContainerForLazyResolveWithJava(
|
||||||
jvmPlatform: TargetPlatform,
|
jvmPlatform: TargetPlatform,
|
||||||
@@ -128,7 +127,6 @@ fun StorageComponentContainer.configureJavaSpecificComponents(
|
|||||||
)
|
)
|
||||||
|
|
||||||
useImpl<FilesByFacadeFqNameIndexer>()
|
useImpl<FilesByFacadeFqNameIndexer>()
|
||||||
useImpl<SubstitutingScopeProviderImpl>()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun ComponentProvider.initJvmBuiltInsForTopDownAnalysis() {
|
fun ComponentProvider.initJvmBuiltInsForTopDownAnalysis() {
|
||||||
|
|||||||
+2
-1
@@ -81,7 +81,8 @@ public class LocalVariableDescriptor extends VariableDescriptorWithInitializerIm
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public LocalVariableDescriptor substitute(@NotNull TypeSubstitutor substitutor) {
|
public LocalVariableDescriptor substitute(@NotNull TypeSubstitutor substitutor) {
|
||||||
return this;
|
if (substitutor.isEmpty()) return this;
|
||||||
|
throw new UnsupportedOperationException(); // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ import org.jetbrains.kotlin.resolve.calls.inference.wrapWithCapturingSubstitutio
|
|||||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||||
import org.jetbrains.kotlin.resolve.calls.model.VariableAsFunctionResolvedCall
|
import org.jetbrains.kotlin.resolve.calls.model.VariableAsFunctionResolvedCall
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
import org.jetbrains.kotlin.types.SubstitutingScopeProvider
|
|
||||||
import org.jetbrains.kotlin.types.TypeConstructorSubstitution
|
import org.jetbrains.kotlin.types.TypeConstructorSubstitution
|
||||||
import org.jetbrains.kotlin.types.TypeUtils
|
import org.jetbrains.kotlin.types.TypeUtils
|
||||||
import org.jetbrains.kotlin.types.typeUtil.isAnyOrNullableAny
|
import org.jetbrains.kotlin.types.typeUtil.isAnyOrNullableAny
|
||||||
@@ -78,9 +77,7 @@ fun ResolutionContext<*>.reportTypeMismatchDueToTypeProjection(
|
|||||||
TypeConstructorSubstitution
|
TypeConstructorSubstitution
|
||||||
.create(receiverType)
|
.create(receiverType)
|
||||||
.wrapWithCapturingSubstitution(needApproximation = false)
|
.wrapWithCapturingSubstitution(needApproximation = false)
|
||||||
.buildSubstitutor().apply {
|
.buildSubstitutor().let { callableDescriptor.substitute(it) } ?: return false
|
||||||
setSubstitutingScopeProvider(SubstitutingScopeProvider.DEFAULT)
|
|
||||||
}.let { callableDescriptor.substitute(it) } ?: return false
|
|
||||||
|
|
||||||
val nonApproximatedExpectedType = correspondingNotApproximatedTypeByDescriptor(substitutedDescriptor) ?: return false
|
val nonApproximatedExpectedType = correspondingNotApproximatedTypeByDescriptor(substitutedDescriptor) ?: return false
|
||||||
if (!TypeUtils.contains(nonApproximatedExpectedType) { it.isCaptured() }) return false
|
if (!TypeUtils.contains(nonApproximatedExpectedType) { it.isCaptured() }) return false
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ import org.jetbrains.kotlin.resolve.calls.tower.KotlinResolutionStatelessCallbac
|
|||||||
import org.jetbrains.kotlin.resolve.checkers.ExperimentalUsageChecker
|
import org.jetbrains.kotlin.resolve.checkers.ExperimentalUsageChecker
|
||||||
import org.jetbrains.kotlin.resolve.lazy.*
|
import org.jetbrains.kotlin.resolve.lazy.*
|
||||||
import org.jetbrains.kotlin.resolve.lazy.declarations.DeclarationProviderFactory
|
import org.jetbrains.kotlin.resolve.lazy.declarations.DeclarationProviderFactory
|
||||||
import org.jetbrains.kotlin.types.SubstitutingScopeProviderImpl
|
|
||||||
import org.jetbrains.kotlin.types.expressions.DeclarationScopeProviderForLocalClassifierAnalyzer
|
import org.jetbrains.kotlin.types.expressions.DeclarationScopeProviderForLocalClassifierAnalyzer
|
||||||
import org.jetbrains.kotlin.types.expressions.LocalClassDescriptorHolder
|
import org.jetbrains.kotlin.types.expressions.LocalClassDescriptorHolder
|
||||||
import org.jetbrains.kotlin.types.expressions.LocalLazyDeclarationResolver
|
import org.jetbrains.kotlin.types.expressions.LocalLazyDeclarationResolver
|
||||||
@@ -118,7 +117,6 @@ fun createContainerForBodyResolve(
|
|||||||
useImpl<AnnotationResolverImpl>()
|
useImpl<AnnotationResolverImpl>()
|
||||||
|
|
||||||
useImpl<BodyResolver>()
|
useImpl<BodyResolver>()
|
||||||
useImpl<SubstitutingScopeProviderImpl>()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun createContainerForLazyBodyResolve(
|
fun createContainerForLazyBodyResolve(
|
||||||
@@ -138,7 +136,6 @@ fun createContainerForLazyBodyResolve(
|
|||||||
useImpl<AnnotationResolverImpl>()
|
useImpl<AnnotationResolverImpl>()
|
||||||
useImpl<LazyTopDownAnalyzer>()
|
useImpl<LazyTopDownAnalyzer>()
|
||||||
useImpl<BasicAbsentDescriptorHandler>()
|
useImpl<BasicAbsentDescriptorHandler>()
|
||||||
useImpl<SubstitutingScopeProviderImpl>()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun createContainerForLazyLocalClassifierAnalyzer(
|
fun createContainerForLazyLocalClassifierAnalyzer(
|
||||||
@@ -169,7 +166,6 @@ fun createContainerForLazyLocalClassifierAnalyzer(
|
|||||||
useImpl<DeclarationScopeProviderForLocalClassifierAnalyzer>()
|
useImpl<DeclarationScopeProviderForLocalClassifierAnalyzer>()
|
||||||
useImpl<LocalLazyDeclarationResolver>()
|
useImpl<LocalLazyDeclarationResolver>()
|
||||||
|
|
||||||
useImpl<SubstitutingScopeProviderImpl>()
|
|
||||||
useInstance(statementFilter)
|
useInstance(statementFilter)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,7 +183,6 @@ fun createContainerForLazyResolve(
|
|||||||
configureStandardResolveComponents()
|
configureStandardResolveComponents()
|
||||||
|
|
||||||
useInstance(declarationProviderFactory)
|
useInstance(declarationProviderFactory)
|
||||||
useImpl<SubstitutingScopeProviderImpl>()
|
|
||||||
|
|
||||||
targetEnvironment.configure(this)
|
targetEnvironment.configure(this)
|
||||||
|
|
||||||
|
|||||||
@@ -911,8 +911,7 @@ public class DescriptorResolver {
|
|||||||
container instanceof ClassDescriptor && ((ClassDescriptor) container).isExpect(),
|
container instanceof ClassDescriptor && ((ClassDescriptor) container).isExpect(),
|
||||||
modifierList != null && PsiUtilsKt.hasActualModifier(modifierList),
|
modifierList != null && PsiUtilsKt.hasActualModifier(modifierList),
|
||||||
modifierList != null && modifierList.hasModifier(KtTokens.EXTERNAL_KEYWORD),
|
modifierList != null && modifierList.hasModifier(KtTokens.EXTERNAL_KEYWORD),
|
||||||
propertyInfo.getHasDelegate(),
|
propertyInfo.getHasDelegate()
|
||||||
new SubstitutingScopeProviderImpl(languageVersionSettings)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
List<TypeParameterDescriptorImpl> typeParameterDescriptors;
|
List<TypeParameterDescriptorImpl> typeParameterDescriptors;
|
||||||
|
|||||||
+21
-68
@@ -8,8 +8,6 @@ package org.jetbrains.kotlin.resolve.calls.tower
|
|||||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||||
import org.jetbrains.kotlin.descriptors.*
|
import org.jetbrains.kotlin.descriptors.*
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||||
import org.jetbrains.kotlin.descriptors.impl.PropertyDescriptorImpl
|
|
||||||
import org.jetbrains.kotlin.descriptors.impl.PropertySetterDescriptorImpl
|
|
||||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||||
import org.jetbrains.kotlin.diagnostics.Errors
|
import org.jetbrains.kotlin.diagnostics.Errors
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
@@ -25,13 +23,12 @@ import org.jetbrains.kotlin.resolve.calls.components.AdditionalDiagnosticReporte
|
|||||||
import org.jetbrains.kotlin.resolve.calls.components.isVararg
|
import org.jetbrains.kotlin.resolve.calls.components.isVararg
|
||||||
import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext
|
import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext
|
||||||
import org.jetbrains.kotlin.resolve.calls.context.CallPosition
|
import org.jetbrains.kotlin.resolve.calls.context.CallPosition
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.approximateCapturedTypes
|
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.buildResultingSubstitutor
|
import org.jetbrains.kotlin.resolve.calls.inference.buildResultingSubstitutor
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.components.FreshVariableNewTypeSubstitutor
|
import org.jetbrains.kotlin.resolve.calls.inference.components.FreshVariableNewTypeSubstitutor
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.components.NewTypeSubstitutor
|
import org.jetbrains.kotlin.resolve.calls.inference.components.NewTypeSubstitutor
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.model.*
|
import org.jetbrains.kotlin.resolve.calls.inference.model.*
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.substitute
|
import org.jetbrains.kotlin.resolve.calls.inference.substitute
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.substituteAndApproximateIntegerLiteralTypes
|
import org.jetbrains.kotlin.resolve.calls.inference.substituteAndApproximateCapturedTypes
|
||||||
import org.jetbrains.kotlin.resolve.calls.model.*
|
import org.jetbrains.kotlin.resolve.calls.model.*
|
||||||
import org.jetbrains.kotlin.resolve.calls.resolvedCallUtil.makeNullableTypeIfSafeReceiver
|
import org.jetbrains.kotlin.resolve.calls.resolvedCallUtil.makeNullableTypeIfSafeReceiver
|
||||||
import org.jetbrains.kotlin.resolve.calls.results.ResolutionStatus
|
import org.jetbrains.kotlin.resolve.calls.results.ResolutionStatus
|
||||||
@@ -41,13 +38,14 @@ import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind
|
|||||||
import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategy
|
import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategy
|
||||||
import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant
|
import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant
|
||||||
import org.jetbrains.kotlin.resolve.constants.IntegerLiteralTypeConstructor
|
import org.jetbrains.kotlin.resolve.constants.IntegerLiteralTypeConstructor
|
||||||
|
import org.jetbrains.kotlin.resolve.constants.IntegerValueTypeConstant
|
||||||
import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluator
|
import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluator
|
||||||
import org.jetbrains.kotlin.resolve.deprecation.DeprecationResolver
|
import org.jetbrains.kotlin.resolve.deprecation.DeprecationResolver
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
|
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.CastImplicitClassReceiver
|
import org.jetbrains.kotlin.resolve.scopes.receivers.CastImplicitClassReceiver
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ImplicitClassReceiver
|
import org.jetbrains.kotlin.resolve.scopes.receivers.ImplicitClassReceiver
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||||
import org.jetbrains.kotlin.types.*
|
import org.jetbrains.kotlin.types.*
|
||||||
|
import org.jetbrains.kotlin.types.checker.NewCapturedType
|
||||||
import org.jetbrains.kotlin.types.expressions.DataFlowAnalyzer
|
import org.jetbrains.kotlin.types.expressions.DataFlowAnalyzer
|
||||||
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
|
||||||
@@ -295,14 +293,15 @@ class KotlinToResolvedCallTransformer(
|
|||||||
// todo external argument
|
// todo external argument
|
||||||
|
|
||||||
val argumentExpression = valueArgument.getArgumentExpression() ?: continue
|
val argumentExpression = valueArgument.getArgumentExpression() ?: continue
|
||||||
updateRecordedType(argumentExpression, parameter, newContext)
|
updateRecordedType(argumentExpression, parameter, newContext, resolvedCall.isReallySuccess())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateRecordedType(
|
fun updateRecordedType(
|
||||||
expression: KtExpression,
|
expression: KtExpression,
|
||||||
parameter: ValueParameterDescriptor?,
|
parameter: ValueParameterDescriptor?,
|
||||||
context: BasicCallResolutionContext
|
context: BasicCallResolutionContext,
|
||||||
|
reportErrorForTypeMismatch: Boolean
|
||||||
): KotlinType? {
|
): KotlinType? {
|
||||||
val deparenthesized = expression.let {
|
val deparenthesized = expression.let {
|
||||||
KtPsiUtil.getLastElementDeparenthesized(it, context.statementFilter)
|
KtPsiUtil.getLastElementDeparenthesized(it, context.statementFilter)
|
||||||
@@ -319,6 +318,9 @@ class KotlinToResolvedCallTransformer(
|
|||||||
updatedType = argumentTypeResolver.updateResultArgumentTypeIfNotDenotable(context, deparenthesized) ?: updatedType
|
updatedType = argumentTypeResolver.updateResultArgumentTypeIfNotDenotable(context, deparenthesized) ?: updatedType
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var reportErrorDuringTypeCheck = reportErrorForTypeMismatch
|
||||||
|
|
||||||
if (parameter != null && ImplicitIntegerCoercion.isEnabledForParameter(parameter)) {
|
if (parameter != null && ImplicitIntegerCoercion.isEnabledForParameter(parameter)) {
|
||||||
val argumentCompileTimeValue = context.trace[BindingContext.COMPILE_TIME_VALUE, deparenthesized]
|
val argumentCompileTimeValue = context.trace[BindingContext.COMPILE_TIME_VALUE, deparenthesized]
|
||||||
if (argumentCompileTimeValue != null && argumentCompileTimeValue.parameters.isConvertableConstVal) {
|
if (argumentCompileTimeValue != null && argumentCompileTimeValue.parameters.isConvertableConstVal) {
|
||||||
@@ -327,6 +329,7 @@ class KotlinToResolvedCallTransformer(
|
|||||||
updatedType = argumentTypeResolver.updateResultArgumentTypeIfNotDenotable(
|
updatedType = argumentTypeResolver.updateResultArgumentTypeIfNotDenotable(
|
||||||
context.trace, context.statementFilter, context.expectedType, generalNumberType, expression
|
context.trace, context.statementFilter, context.expectedType, generalNumberType, expression
|
||||||
)
|
)
|
||||||
|
reportErrorDuringTypeCheck = true
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -334,7 +337,7 @@ class KotlinToResolvedCallTransformer(
|
|||||||
|
|
||||||
updatedType = updateRecordedTypeForArgument(updatedType, recordedType, expression, context)
|
updatedType = updateRecordedTypeForArgument(updatedType, recordedType, expression, context)
|
||||||
|
|
||||||
dataFlowAnalyzer.checkType(updatedType, deparenthesized, context, false)
|
dataFlowAnalyzer.checkType(updatedType, deparenthesized, context, reportErrorDuringTypeCheck)
|
||||||
|
|
||||||
return updatedType
|
return updatedType
|
||||||
}
|
}
|
||||||
@@ -687,44 +690,32 @@ class NewResolvedCallImpl<D : CallableDescriptor>(
|
|||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
resultingDescriptor = run {
|
resultingDescriptor = run {
|
||||||
val candidateDescriptor = resolvedCallAtom.candidateDescriptor
|
val candidateDescriptor = resolvedCallAtom.candidateDescriptor
|
||||||
val containsIntegerLiteralTypes = resolvedCallAtom.candidateDescriptor.returnType?.contains {
|
val containsCapturedTypes = resolvedCallAtom.candidateDescriptor.returnType?.contains { it is NewCapturedType } ?: false
|
||||||
it.constructor is IntegerLiteralTypeConstructor
|
val containsIntegerLiteralTypes = resolvedCallAtom.candidateDescriptor.returnType?.contains { it.constructor is IntegerLiteralTypeConstructor } ?: false
|
||||||
} ?: false
|
|
||||||
|
|
||||||
when {
|
when {
|
||||||
candidateDescriptor is FunctionDescriptor ||
|
candidateDescriptor is FunctionDescriptor ||
|
||||||
(candidateDescriptor is PropertyDescriptor && candidateDescriptor.typeParameters.isNotEmpty() || containsIntegerLiteralTypes) ->
|
(candidateDescriptor is PropertyDescriptor && (candidateDescriptor.typeParameters.isNotEmpty() || containsCapturedTypes || containsIntegerLiteralTypes)) ->
|
||||||
// this code is very suspicious. Now it is very useful for BE, because they cannot do nothing with captured types,
|
// this code is very suspicious. Now it is very useful for BE, because they cannot do nothing with captured types,
|
||||||
// but it seems like temporary solution.
|
// but it seems like temporary solution.
|
||||||
candidateDescriptor.substituteAndApproximateIntegerLiteralTypes(resolvedCallAtom.substitutor).let {
|
candidateDescriptor.substitute(resolvedCallAtom.substitutor).substituteAndApproximateCapturedTypes(
|
||||||
if (substitutor != null) {
|
substitutor ?: FreshVariableNewTypeSubstitutor.Empty
|
||||||
it.substitute(substitutor)
|
)
|
||||||
} else {
|
|
||||||
it
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
else ->
|
else ->
|
||||||
candidateDescriptor
|
candidateDescriptor
|
||||||
}
|
}
|
||||||
} as D
|
} as D
|
||||||
|
|
||||||
typeArguments = resolvedCallAtom.substitutor.freshVariables.map {
|
typeArguments = resolvedCallAtom.substitutor.freshVariables.map {
|
||||||
(substitutor ?: FreshVariableNewTypeSubstitutor.Empty).safeSubstitute(it.defaultType)
|
val substituted = (substitutor ?: FreshVariableNewTypeSubstitutor.Empty).safeSubstitute(it.defaultType)
|
||||||
|
TypeApproximator(substituted.constructor.builtIns)
|
||||||
|
.approximateToSuperType(substituted, TypeApproximatorConfiguration.IntegerLiteralsTypesApproximation)
|
||||||
|
?: substituted
|
||||||
}
|
}
|
||||||
|
|
||||||
calculateExpectedTypeForSamConvertedArgumentMap(substitutor)
|
calculateExpectedTypeForSamConvertedArgumentMap(substitutor)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun approximateCapturedTypesAndHackSetters() {
|
|
||||||
val approximator = TypeApproximator(resultingDescriptor.builtIns)
|
|
||||||
resultingDescriptor = resultingDescriptor.hackSettersAccordingToCapturedOutTypes()
|
|
||||||
resultingDescriptor = resultingDescriptor.approximateCapturedTypes()
|
|
||||||
typeArguments = typeArguments.map {
|
|
||||||
approximator.approximateToSuperType(it, TypeApproximatorConfiguration.CapturedAndIntegerLiteralsTypesApproximation) ?: it
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getExpectedTypeForSamConvertedArgument(valueArgument: ValueArgument): UnwrappedType? =
|
fun getExpectedTypeForSamConvertedArgument(valueArgument: ValueArgument): UnwrappedType? =
|
||||||
expedtedTypeForSamConvertedArgumentMap?.get(valueArgument)
|
expedtedTypeForSamConvertedArgumentMap?.get(valueArgument)
|
||||||
|
|
||||||
@@ -817,41 +808,3 @@ fun NewResolvedCallImpl<*>.hasInferredReturnType(): Boolean {
|
|||||||
val returnType = this.resultingDescriptor.returnType ?: return false
|
val returnType = this.resultingDescriptor.returnType ?: return false
|
||||||
return !returnType.contains { ErrorUtils.isUninferredParameter(it) }
|
return !returnType.contains { ErrorUtils.isUninferredParameter(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun ResolvedCall<*>.approximateCapturedTypesAndHackSetters() {
|
|
||||||
when (this) {
|
|
||||||
is NewResolvedCallImpl<*> -> approximateCapturedTypesAndHackSetters()
|
|
||||||
is NewVariableAsFunctionResolvedCallImpl -> {
|
|
||||||
functionCall.approximateCapturedTypesAndHackSetters()
|
|
||||||
variableCall.approximateCapturedTypesAndHackSetters()
|
|
||||||
}
|
|
||||||
else -> throw UnsupportedOperationException("Illegal resolved call: $this")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun <D : CallableDescriptor> D.hackSettersAccordingToCapturedOutTypes(): D {
|
|
||||||
return when (this) {
|
|
||||||
is PropertyDescriptorImpl -> hackSettersAccordingToCapturedOutTypes() as D
|
|
||||||
else -> this
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun PropertyDescriptorImpl.hackSettersAccordingToCapturedOutTypes(): PropertyDescriptor {
|
|
||||||
val setter = setter ?: return this
|
|
||||||
val valueParameter = setter.valueParameters.first()
|
|
||||||
val inputType = valueParameter.type
|
|
||||||
val approximatedType = TypeApproximator(builtIns).approximateToSubType(
|
|
||||||
inputType.unwrap(),
|
|
||||||
TypeApproximatorConfiguration.CapturedAndIntegerLiteralsTypesApproximation
|
|
||||||
) ?: return this
|
|
||||||
|
|
||||||
val newProperty = newCopyBuilder().build() as PropertyDescriptorImpl
|
|
||||||
|
|
||||||
val newSetter = with(setter) {
|
|
||||||
PropertySetterDescriptorImpl(newProperty, annotations, modality, visibility, isDefault, isExternal, isInline, kind, original, source)
|
|
||||||
}
|
|
||||||
newSetter.initialize(PropertySetterDescriptorImpl.createSetterParameter(newSetter, approximatedType, setter.annotations))
|
|
||||||
newProperty.initialize(getter, newSetter, backingField, delegateField)
|
|
||||||
newProperty.isSetterProjectedOut = true
|
|
||||||
return newProperty
|
|
||||||
}
|
|
||||||
@@ -382,7 +382,6 @@ class PSICallResolver(
|
|||||||
|
|
||||||
return cache.getOrPut(implicitReceiver) {
|
return cache.getOrPut(implicitReceiver) {
|
||||||
context.transformToReceiverWithSmartCastInfo(implicitReceiver.value)
|
context.transformToReceiverWithSmartCastInfo(implicitReceiver.value)
|
||||||
.prepareReceiverRegardingCaptureTypes()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-2
@@ -110,7 +110,6 @@ class ResolvedAtomCompleter(
|
|||||||
|
|
||||||
kotlinToResolvedCallTransformer.reportDiagnostics(topLevelCallContext, topLevelTrace, resolvedCall, diagnostics)
|
kotlinToResolvedCallTransformer.reportDiagnostics(topLevelCallContext, topLevelTrace, resolvedCall, diagnostics)
|
||||||
|
|
||||||
resolvedCall.approximateCapturedTypesAndHackSetters()
|
|
||||||
return resolvedCall
|
return resolvedCall
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,7 +155,9 @@ class ResolvedAtomCompleter(
|
|||||||
.replaceBindingTrace(topLevelTrace)
|
.replaceBindingTrace(topLevelTrace)
|
||||||
|
|
||||||
val argumentExpression = resultValueArgument.valueArgument.getArgumentExpression() ?: continue
|
val argumentExpression = resultValueArgument.valueArgument.getArgumentExpression() ?: continue
|
||||||
kotlinToResolvedCallTransformer.updateRecordedType(argumentExpression, parameter = null, context = newContext)
|
kotlinToResolvedCallTransformer.updateRecordedType(
|
||||||
|
argumentExpression, parameter = null, context = newContext, reportErrorForTypeMismatch = true
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,12 +24,10 @@ import org.jetbrains.kotlin.resolve.*
|
|||||||
import org.jetbrains.kotlin.resolve.extensions.SyntheticResolveExtension
|
import org.jetbrains.kotlin.resolve.extensions.SyntheticResolveExtension
|
||||||
import org.jetbrains.kotlin.resolve.lazy.declarations.DeclarationProviderFactory
|
import org.jetbrains.kotlin.resolve.lazy.declarations.DeclarationProviderFactory
|
||||||
import org.jetbrains.kotlin.storage.StorageManager
|
import org.jetbrains.kotlin.storage.StorageManager
|
||||||
import org.jetbrains.kotlin.types.SubstitutingScopeProvider
|
|
||||||
import org.jetbrains.kotlin.types.WrappedTypeFactory
|
import org.jetbrains.kotlin.types.WrappedTypeFactory
|
||||||
|
|
||||||
interface LazyClassContext {
|
interface LazyClassContext {
|
||||||
val declarationScopeProvider: DeclarationScopeProvider
|
val declarationScopeProvider: DeclarationScopeProvider
|
||||||
val substitutingScopeProvider: SubstitutingScopeProvider
|
|
||||||
|
|
||||||
val storageManager: StorageManager
|
val storageManager: StorageManager
|
||||||
val trace: BindingTrace
|
val trace: BindingTrace
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ import org.jetbrains.kotlin.resolve.lazy.descriptors.LazyPackageDescriptor;
|
|||||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope;
|
import org.jetbrains.kotlin.resolve.scopes.LexicalScope;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope;
|
import org.jetbrains.kotlin.resolve.scopes.MemberScope;
|
||||||
import org.jetbrains.kotlin.storage.*;
|
import org.jetbrains.kotlin.storage.*;
|
||||||
import org.jetbrains.kotlin.types.SubstitutingScopeProvider;
|
|
||||||
import org.jetbrains.kotlin.types.WrappedTypeFactory;
|
import org.jetbrains.kotlin.types.WrappedTypeFactory;
|
||||||
import org.jetbrains.kotlin.utils.SmartList;
|
import org.jetbrains.kotlin.utils.SmartList;
|
||||||
|
|
||||||
@@ -82,7 +81,6 @@ public class ResolveSession implements KotlinCodeAnalyzer, LazyClassContext {
|
|||||||
private DelegationFilter delegationFilter;
|
private DelegationFilter delegationFilter;
|
||||||
private WrappedTypeFactory wrappedTypeFactory;
|
private WrappedTypeFactory wrappedTypeFactory;
|
||||||
private PlatformDiagnosticSuppressor platformDiagnosticSuppressor;
|
private PlatformDiagnosticSuppressor platformDiagnosticSuppressor;
|
||||||
private SubstitutingScopeProvider substitutingScopeProvider;
|
|
||||||
|
|
||||||
private final SyntheticResolveExtension syntheticResolveExtension;
|
private final SyntheticResolveExtension syntheticResolveExtension;
|
||||||
|
|
||||||
@@ -148,17 +146,6 @@ public class ResolveSession implements KotlinCodeAnalyzer, LazyClassContext {
|
|||||||
this.platformDiagnosticSuppressor = platformDiagnosticSuppressor;
|
this.platformDiagnosticSuppressor = platformDiagnosticSuppressor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
public SubstitutingScopeProvider getSubstitutingScopeProvider() {
|
|
||||||
return substitutingScopeProvider;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
public void setSubstitutingScopeProvider(SubstitutingScopeProvider substitutingScopeProvider) {
|
|
||||||
this.substitutingScopeProvider = substitutingScopeProvider;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Only calls from injectors expected
|
// Only calls from injectors expected
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public ResolveSession(
|
public ResolveSession(
|
||||||
|
|||||||
+1
-1
@@ -113,7 +113,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
|||||||
) {
|
) {
|
||||||
super(c.getStorageManager(), containingDeclaration, name,
|
super(c.getStorageManager(), containingDeclaration, name,
|
||||||
KotlinSourceElementKt.toSourceElement(classLikeInfo.getCorrespondingClassOrObject()),
|
KotlinSourceElementKt.toSourceElement(classLikeInfo.getCorrespondingClassOrObject()),
|
||||||
isExternal, c.getSubstitutingScopeProvider()
|
isExternal
|
||||||
);
|
);
|
||||||
this.c = c;
|
this.c = c;
|
||||||
|
|
||||||
|
|||||||
@@ -1,49 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2019 JetBrains s.r.o. 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.config.LanguageFeature
|
|
||||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.OldCapturedTypeCreator
|
|
||||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
|
||||||
import org.jetbrains.kotlin.resolve.scopes.SubstitutingScope
|
|
||||||
import org.jetbrains.kotlin.types.typesApproximation.OldCaptureTypeApproximator
|
|
||||||
|
|
||||||
class SubstitutingScopeProviderImpl(private val languageVersionSettings: LanguageVersionSettings) : SubstitutingScopeProvider {
|
|
||||||
override val isNewInferenceEnabled: Boolean get() = languageVersionSettings.supportsFeature(LanguageFeature.NewInference)
|
|
||||||
|
|
||||||
override fun createSubstitutingScope(workerScope: MemberScope, givenSubstitutor: TypeSubstitutor): SubstitutingScope {
|
|
||||||
return SubstitutingScope(workerScope, givenSubstitutor, this)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun provideApproximator(): CapturedTypeApproximator {
|
|
||||||
return if (isNewInferenceEnabled) {
|
|
||||||
NoCapturedTypeApproximator
|
|
||||||
} else {
|
|
||||||
OldCaptureTypeApproximator()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun provideCapturedTypeCreator(): CapturedTypeCreator {
|
|
||||||
return if (isNewInferenceEnabled) {
|
|
||||||
NoCapturedTypeCreator
|
|
||||||
} else {
|
|
||||||
OldCapturedTypeCreator
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
object NoCapturedTypeCreator : CapturedTypeCreator {
|
|
||||||
override fun createCapturedType(typeProjection: TypeProjection): TypeProjection {
|
|
||||||
return typeProjection
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
object NoCapturedTypeApproximator : CapturedTypeApproximator {
|
|
||||||
override fun approximateCapturedTypes(typeProjection: TypeProjection?, approximateContravariant: Boolean): TypeProjection? {
|
|
||||||
return typeProjection
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+2
-8
@@ -958,7 +958,6 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
|
|
||||||
boolean result = true;
|
boolean result = true;
|
||||||
KtExpression reportOn = expression != null ? expression : expressionWithParenthesis;
|
KtExpression reportOn = expression != null ? expression : expressionWithParenthesis;
|
||||||
KtExpression originalReportOn = reportOn;
|
|
||||||
if (reportOn instanceof KtQualifiedExpression) {
|
if (reportOn instanceof KtQualifiedExpression) {
|
||||||
KtExpression selector = ((KtQualifiedExpression) reportOn).getSelectorExpression();
|
KtExpression selector = ((KtQualifiedExpression) reportOn).getSelectorExpression();
|
||||||
if (selector != null)
|
if (selector != null)
|
||||||
@@ -969,19 +968,14 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
PropertyDescriptor propertyDescriptor = (PropertyDescriptor) variable;
|
PropertyDescriptor propertyDescriptor = (PropertyDescriptor) variable;
|
||||||
PropertySetterDescriptor setter = propertyDescriptor.getSetter();
|
PropertySetterDescriptor setter = propertyDescriptor.getSetter();
|
||||||
if (propertyDescriptor.isSetterProjectedOut()) {
|
if (propertyDescriptor.isSetterProjectedOut()) {
|
||||||
trace.report(SETTER_PROJECTED_OUT.on(originalReportOn, propertyDescriptor));
|
trace.report(SETTER_PROJECTED_OUT.on(reportOn, propertyDescriptor));
|
||||||
result = false;
|
result = false;
|
||||||
}
|
}
|
||||||
else if (setter != null) {
|
else if (setter != null) {
|
||||||
ResolvedCall<?> resolvedCall = CallUtilKt.getResolvedCall(expressionWithParenthesis, context.trace.getBindingContext());
|
ResolvedCall<?> resolvedCall = CallUtilKt.getResolvedCall(expressionWithParenthesis, context.trace.getBindingContext());
|
||||||
assert resolvedCall != null
|
assert resolvedCall != null
|
||||||
: "Call is not resolved for property setter: " + PsiUtilsKt.getElementTextWithContext(expressionWithParenthesis);
|
: "Call is not resolved for property setter: " + PsiUtilsKt.getElementTextWithContext(expressionWithParenthesis);
|
||||||
if (((PropertyDescriptor)resolvedCall.getResultingDescriptor()).isSetterProjectedOut()) {
|
checkPropertySetterCall(context.replaceBindingTrace(trace), setter, resolvedCall, reportOn);
|
||||||
trace.report(SETTER_PROJECTED_OUT.on(originalReportOn, propertyDescriptor));
|
|
||||||
result = false;
|
|
||||||
} else {
|
|
||||||
checkPropertySetterCall(context.replaceBindingTrace(trace), setter, resolvedCall, reportOn);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-8
@@ -50,7 +50,6 @@ import org.jetbrains.kotlin.resolve.lazy.descriptors.LazyClassDescriptor
|
|||||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
|
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
|
||||||
import org.jetbrains.kotlin.resolve.scopes.LexicalWritableScope
|
import org.jetbrains.kotlin.resolve.scopes.LexicalWritableScope
|
||||||
import org.jetbrains.kotlin.storage.StorageManager
|
import org.jetbrains.kotlin.storage.StorageManager
|
||||||
import org.jetbrains.kotlin.types.SubstitutingScopeProvider
|
|
||||||
import org.jetbrains.kotlin.types.WrappedTypeFactory
|
import org.jetbrains.kotlin.types.WrappedTypeFactory
|
||||||
|
|
||||||
class LocalClassifierAnalyzer(
|
class LocalClassifierAnalyzer(
|
||||||
@@ -66,8 +65,7 @@ class LocalClassifierAnalyzer(
|
|||||||
private val supertypeLoopChecker: SupertypeLoopChecker,
|
private val supertypeLoopChecker: SupertypeLoopChecker,
|
||||||
private val languageVersionSettings: LanguageVersionSettings,
|
private val languageVersionSettings: LanguageVersionSettings,
|
||||||
private val delegationFilter: DelegationFilter,
|
private val delegationFilter: DelegationFilter,
|
||||||
private val wrappedTypeFactory: WrappedTypeFactory,
|
private val wrappedTypeFactory: WrappedTypeFactory
|
||||||
private val substitutingScopeProvider: SubstitutingScopeProvider
|
|
||||||
) {
|
) {
|
||||||
fun processClassOrObject(
|
fun processClassOrObject(
|
||||||
scope: LexicalWritableScope?,
|
scope: LexicalWritableScope?,
|
||||||
@@ -100,8 +98,7 @@ class LocalClassifierAnalyzer(
|
|||||||
languageVersionSettings,
|
languageVersionSettings,
|
||||||
SyntheticResolveExtension.getInstance(project),
|
SyntheticResolveExtension.getInstance(project),
|
||||||
delegationFilter,
|
delegationFilter,
|
||||||
wrappedTypeFactory,
|
wrappedTypeFactory
|
||||||
substitutingScopeProvider
|
|
||||||
),
|
),
|
||||||
analyzerServices
|
analyzerServices
|
||||||
)
|
)
|
||||||
@@ -129,8 +126,7 @@ class LocalClassDescriptorHolder(
|
|||||||
val languageVersionSettings: LanguageVersionSettings,
|
val languageVersionSettings: LanguageVersionSettings,
|
||||||
val syntheticResolveExtension: SyntheticResolveExtension,
|
val syntheticResolveExtension: SyntheticResolveExtension,
|
||||||
val delegationFilter: DelegationFilter,
|
val delegationFilter: DelegationFilter,
|
||||||
val wrappedTypeFactory: WrappedTypeFactory,
|
val wrappedTypeFactory: WrappedTypeFactory
|
||||||
val substitutingScopeProvider: SubstitutingScopeProvider
|
|
||||||
) {
|
) {
|
||||||
// We do not need to synchronize here, because this code is used strictly from one thread
|
// We do not need to synchronize here, because this code is used strictly from one thread
|
||||||
private var classDescriptor: ClassDescriptor? = null
|
private var classDescriptor: ClassDescriptor? = null
|
||||||
@@ -170,7 +166,6 @@ class LocalClassDescriptorHolder(
|
|||||||
override val syntheticResolveExtension = this@LocalClassDescriptorHolder.syntheticResolveExtension
|
override val syntheticResolveExtension = this@LocalClassDescriptorHolder.syntheticResolveExtension
|
||||||
override val delegationFilter: DelegationFilter = this@LocalClassDescriptorHolder.delegationFilter
|
override val delegationFilter: DelegationFilter = this@LocalClassDescriptorHolder.delegationFilter
|
||||||
override val wrappedTypeFactory: WrappedTypeFactory = this@LocalClassDescriptorHolder.wrappedTypeFactory
|
override val wrappedTypeFactory: WrappedTypeFactory = this@LocalClassDescriptorHolder.wrappedTypeFactory
|
||||||
override val substitutingScopeProvider: SubstitutingScopeProvider = this@LocalClassDescriptorHolder.substitutingScopeProvider
|
|
||||||
},
|
},
|
||||||
containingDeclaration,
|
containingDeclaration,
|
||||||
classOrObject.nameAsSafeName,
|
classOrObject.nameAsSafeName,
|
||||||
|
|||||||
+7
-28
@@ -60,20 +60,6 @@ val CallableDescriptor.returnTypeOrNothing: UnwrappedType
|
|||||||
|
|
||||||
fun TypeSubstitutor.substitute(type: UnwrappedType): UnwrappedType = safeSubstitute(type, Variance.INVARIANT).unwrap()
|
fun TypeSubstitutor.substitute(type: UnwrappedType): UnwrappedType = safeSubstitute(type, Variance.INVARIANT).unwrap()
|
||||||
|
|
||||||
fun CallableDescriptor.substituteAndApproximateIntegerLiteralTypes(substitutor: NewTypeSubstitutor): CallableDescriptor {
|
|
||||||
val wrappedSubstitution = object : TypeSubstitution() {
|
|
||||||
override fun get(key: KotlinType): TypeProjection? = null
|
|
||||||
|
|
||||||
override fun prepareTopLevelType(topLevelType: KotlinType, position: Variance) =
|
|
||||||
substitutor.safeSubstitute(topLevelType.unwrap()).let { substitutedType ->
|
|
||||||
TypeApproximator(builtIns).approximateToSuperType(substitutedType, TypeApproximatorConfiguration.IntegerLiteralsTypesApproximation)
|
|
||||||
?: substitutedType
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return substitute(TypeSubstitutor.create(wrappedSubstitution))
|
|
||||||
}
|
|
||||||
|
|
||||||
fun CallableDescriptor.substitute(substitutor: NewTypeSubstitutor): CallableDescriptor {
|
fun CallableDescriptor.substitute(substitutor: NewTypeSubstitutor): CallableDescriptor {
|
||||||
val wrappedSubstitution = object : TypeSubstitution() {
|
val wrappedSubstitution = object : TypeSubstitution() {
|
||||||
override fun get(key: KotlinType): TypeProjection? = null
|
override fun get(key: KotlinType): TypeProjection? = null
|
||||||
@@ -82,25 +68,18 @@ fun CallableDescriptor.substitute(substitutor: NewTypeSubstitutor): CallableDesc
|
|||||||
return substitute(TypeSubstitutor.create(wrappedSubstitution))
|
return substitute(TypeSubstitutor.create(wrappedSubstitution))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <D: CallableDescriptor> D.approximateCapturedTypes(): D {
|
fun CallableDescriptor.substituteAndApproximateCapturedTypes(substitutor: NewTypeSubstitutor): CallableDescriptor {
|
||||||
val approximator = TypeApproximator(builtIns)
|
|
||||||
var anyChanges = false
|
|
||||||
val wrappedSubstitution = object : TypeSubstitution() {
|
val wrappedSubstitution = object : TypeSubstitution() {
|
||||||
override fun get(key: KotlinType): TypeProjection? = null
|
override fun get(key: KotlinType): TypeProjection? = null
|
||||||
|
|
||||||
override fun prepareTopLevelType(topLevelType: KotlinType, position: Variance): KotlinType {
|
override fun prepareTopLevelType(topLevelType: KotlinType, position: Variance) =
|
||||||
val type = topLevelType.unwrap()
|
substitutor.safeSubstitute(topLevelType.unwrap()).let { substitutedType ->
|
||||||
val approximatedType =
|
TypeApproximator(builtIns).approximateToSuperType(substitutedType, TypeApproximatorConfiguration.CapturedAndIntegerLiteralsTypesApproximation)
|
||||||
approximator.approximateToSuperType(type, TypeApproximatorConfiguration.CapturedAndIntegerLiteralsTypesApproximation)
|
?: substitutedType
|
||||||
if (approximatedType != null) {
|
|
||||||
anyChanges = true
|
|
||||||
}
|
}
|
||||||
return approximatedType as? KotlinType ?: type
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val substitutedDescriptor = substitute(TypeSubstitutor.create(wrappedSubstitution)) as D
|
return substitute(TypeSubstitutor.create(wrappedSubstitution))
|
||||||
return if (anyChanges) substitutedDescriptor else this
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun <E> MutableList<E>.trimToSize(newSize: Int) = subList(newSize, size).clear()
|
internal fun <E> MutableList<E>.trimToSize(newSize: Int) = subList(newSize, size).clear()
|
||||||
|
|||||||
@@ -21,10 +21,14 @@ import org.jetbrains.kotlin.config.LanguageFeature
|
|||||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||||
import org.jetbrains.kotlin.resolve.calls.NewCommonSuperTypeCalculator
|
import org.jetbrains.kotlin.resolve.calls.NewCommonSuperTypeCalculator
|
||||||
import org.jetbrains.kotlin.resolve.calls.components.ClassicTypeSystemContextForCS
|
import org.jetbrains.kotlin.resolve.calls.components.ClassicTypeSystemContextForCS
|
||||||
|
import org.jetbrains.kotlin.resolve.calls.inference.model.TypeVariableTypeConstructor
|
||||||
|
import org.jetbrains.kotlin.resolve.constants.IntegerLiteralTypeConstructor
|
||||||
import org.jetbrains.kotlin.types.TypeApproximatorConfiguration.IntersectionStrategy.*
|
import org.jetbrains.kotlin.types.TypeApproximatorConfiguration.IntersectionStrategy.*
|
||||||
|
import org.jetbrains.kotlin.types.checker.NewCapturedType
|
||||||
import org.jetbrains.kotlin.types.checker.NewCapturedTypeConstructor
|
import org.jetbrains.kotlin.types.checker.NewCapturedTypeConstructor
|
||||||
import org.jetbrains.kotlin.types.model.*
|
import org.jetbrains.kotlin.types.model.*
|
||||||
import org.jetbrains.kotlin.types.model.CaptureStatus.*
|
import org.jetbrains.kotlin.types.model.CaptureStatus.*
|
||||||
|
import org.jetbrains.kotlin.types.typeUtil.builtIns
|
||||||
|
|
||||||
|
|
||||||
open class TypeApproximatorConfiguration {
|
open class TypeApproximatorConfiguration {
|
||||||
@@ -420,8 +424,6 @@ abstract class AbstractTypeApproximator(val ctx: TypeSystemInferenceExtensionCon
|
|||||||
if (argument.isStarProjection()) continue
|
if (argument.isStarProjection()) continue
|
||||||
|
|
||||||
val argumentType = argument.getType()//.unwrap()
|
val argumentType = argument.getType()//.unwrap()
|
||||||
val argumentTypeIsNullable = argumentType.asSimpleType()?.isMarkedNullable() ?: false
|
|
||||||
|
|
||||||
val effectiveVariance = AbstractTypeChecker.effectiveVariance(parameter.getVariance(), argument.getVariance())
|
val effectiveVariance = AbstractTypeChecker.effectiveVariance(parameter.getVariance(), argument.getVariance())
|
||||||
when (effectiveVariance) {
|
when (effectiveVariance) {
|
||||||
null -> {
|
null -> {
|
||||||
@@ -485,7 +487,7 @@ abstract class AbstractTypeApproximator(val ctx: TypeSystemInferenceExtensionCon
|
|||||||
*/
|
*/
|
||||||
if (argumentType.typeConstructor() is NewCapturedTypeConstructor) {
|
if (argumentType.typeConstructor() is NewCapturedTypeConstructor) {
|
||||||
val subType = approximateToSubType(argumentType, conf, depth) ?: continue@loop
|
val subType = approximateToSubType(argumentType, conf, depth) ?: continue@loop
|
||||||
if (!subType.isTrivialSub(argumentTypeIsNullable)) {
|
if (!subType.isTrivialSub()) {
|
||||||
newArguments[index] = createTypeArgument(subType, TypeVariance.IN)
|
newArguments[index] = createTypeArgument(subType, TypeVariance.IN)
|
||||||
continue@loop
|
continue@loop
|
||||||
}
|
}
|
||||||
@@ -496,7 +498,7 @@ abstract class AbstractTypeApproximator(val ctx: TypeSystemInferenceExtensionCon
|
|||||||
if (approximatedSuperType.isTrivialSuper()) {
|
if (approximatedSuperType.isTrivialSuper()) {
|
||||||
val approximatedSubType =
|
val approximatedSubType =
|
||||||
approximateToSubType(argumentType, conf, depth) ?: continue@loop // seems like this is never null
|
approximateToSubType(argumentType, conf, depth) ?: continue@loop // seems like this is never null
|
||||||
if (!approximatedSubType.isTrivialSub(argumentTypeIsNullable)) {
|
if (!approximatedSubType.isTrivialSub()) {
|
||||||
newArguments[index] = createTypeArgument(approximatedSubType, TypeVariance.IN)
|
newArguments[index] = createTypeArgument(approximatedSubType, TypeVariance.IN)
|
||||||
continue@loop
|
continue@loop
|
||||||
}
|
}
|
||||||
@@ -525,12 +527,7 @@ abstract class AbstractTypeApproximator(val ctx: TypeSystemInferenceExtensionCon
|
|||||||
private fun KotlinTypeMarker.isTrivialSuper() = upperBoundIfFlexible().isNullableAny()
|
private fun KotlinTypeMarker.isTrivialSuper() = upperBoundIfFlexible().isNullableAny()
|
||||||
|
|
||||||
// Nothing or Nothing!
|
// Nothing or Nothing!
|
||||||
private fun KotlinTypeMarker.isTrivialSub(originalIsNullable: Boolean) = lowerBoundIfFlexible().let {
|
private fun KotlinTypeMarker.isTrivialSub() = lowerBoundIfFlexible().isNothing()
|
||||||
if (originalIsNullable)
|
|
||||||
it.isNothing() || it.isNullableNothing()
|
|
||||||
else
|
|
||||||
it.isNothing()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
//internal fun KotlinTypeMarker.typeDepth() =
|
//internal fun KotlinTypeMarker.typeDepth() =
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
// FILE: test/GenericSam.java
|
// FILE: test/GenericSam.java
|
||||||
// !WITH_NEW_INFERENCE
|
|
||||||
// NI_EXPECTED_FILE
|
|
||||||
|
|
||||||
package test;
|
package test;
|
||||||
|
|
||||||
@@ -18,7 +16,7 @@ fun f3() = java.lang.Runnable::class
|
|||||||
fun f4() = java.lang.Runnable::run
|
fun f4() = java.lang.Runnable::run
|
||||||
|
|
||||||
fun f5() = GenericSam::class
|
fun f5() = GenericSam::class
|
||||||
fun f6() = GenericSam<*>::<!NI;DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>invoke<!>
|
fun f6() = GenericSam<*>::invoke
|
||||||
fun f7() = test.GenericSam::class
|
fun f7() = test.GenericSam::class
|
||||||
fun f8() = test.GenericSam<String>::invoke
|
fun f8() = test.GenericSam<String>::invoke
|
||||||
|
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
package
|
|
||||||
|
|
||||||
public fun f1(): kotlin.reflect.KClass<java.lang.Runnable>
|
|
||||||
public fun f2(): kotlin.reflect.KFunction1<java.lang.Runnable, kotlin.Unit>
|
|
||||||
public fun f3(): kotlin.reflect.KClass<java.lang.Runnable>
|
|
||||||
public fun f4(): kotlin.reflect.KFunction1<java.lang.Runnable, kotlin.Unit>
|
|
||||||
public fun f5(): kotlin.reflect.KClass<test.GenericSam<*>>
|
|
||||||
public fun f6(): kotlin.reflect.KFunction0<[ERROR : <ERROR FUNCTION RETURN TYPE>]>
|
|
||||||
public fun f7(): kotlin.reflect.KClass<test.GenericSam<*>>
|
|
||||||
public fun f8(): kotlin.reflect.KFunction2<test.GenericSam<kotlin.String>, @kotlin.ParameterName(name = "t") kotlin.String!, kotlin.Unit>
|
|
||||||
public fun g1(): kotlin.reflect.KClass<out java.lang.Runnable>
|
|
||||||
public fun g2(): kotlin.reflect.KFunction0<kotlin.Unit>
|
|
||||||
public fun g3(): kotlin.reflect.KClass<out java.lang.Runnable>
|
|
||||||
public fun g4(): kotlin.reflect.KFunction0<kotlin.Unit>
|
|
||||||
public fun g5(): kotlin.reflect.KClass<out test.GenericSam<kotlin.String>>
|
|
||||||
public fun g6(): kotlin.reflect.KFunction1<@kotlin.ParameterName(name = "t") kotlin.String!, kotlin.Unit>
|
|
||||||
public fun g7(): kotlin.reflect.KClass<out test.GenericSam<kotlin.String>>
|
|
||||||
public fun g8(): kotlin.reflect.KFunction1<@kotlin.ParameterName(name = "t") kotlin.String!, kotlin.Unit>
|
|
||||||
|
|
||||||
package test {
|
|
||||||
|
|
||||||
public interface GenericSam</*0*/ T : kotlin.Any!> {
|
|
||||||
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 abstract operator fun invoke(/*0*/ t: T!): kotlin.Unit
|
|
||||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+1
-1
@@ -37,5 +37,5 @@ annotation class AnnArray(val a: Array<String>)
|
|||||||
@AnnArray(<!OI;NON_VARARG_SPREAD!>*<!>["/"])
|
@AnnArray(<!OI;NON_VARARG_SPREAD!>*<!>["/"])
|
||||||
fun testArray() {}
|
fun testArray() {}
|
||||||
|
|
||||||
@Ann1(<!OI;TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH, TYPE_MISMATCH!>[""]<!>)
|
@Ann1(<!NI;TYPE_MISMATCH, OI;TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH, TYPE_MISMATCH!>[""]<!>)
|
||||||
fun testVararg() {}
|
fun testVararg() {}
|
||||||
+1
-1
@@ -34,6 +34,6 @@ val bbb = null ?: ( l() <!USELESS_ELVIS_RIGHT_IS_NULL!>?: null<!>)
|
|||||||
val bbbb = ( l() <!USELESS_ELVIS_RIGHT_IS_NULL!>?: null<!>) ?: ( l() <!USELESS_ELVIS_RIGHT_IS_NULL!>?: null<!>)
|
val bbbb = ( l() <!USELESS_ELVIS_RIGHT_IS_NULL!>?: null<!>) ?: ( l() <!USELESS_ELVIS_RIGHT_IS_NULL!>?: null<!>)
|
||||||
|
|
||||||
fun f(x : Long?): Long {
|
fun f(x : Long?): Long {
|
||||||
var a = x ?: (<!TYPE_MISMATCH!>fun() {}<!> <!USELESS_ELVIS!>?: <!TYPE_MISMATCH!>fun() {}<!><!>)
|
var a = x ?: (<!NI;TYPE_MISMATCH, NI;TYPE_MISMATCH, TYPE_MISMATCH!>fun() {}<!> <!USELESS_ELVIS!>?: <!NI;TYPE_MISMATCH, NI;TYPE_MISMATCH, TYPE_MISMATCH!>fun() {}<!><!>)
|
||||||
return <!OI;DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>a<!>
|
return <!OI;DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>a<!>
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -108,7 +108,7 @@ fun testImplicitCoercion() {
|
|||||||
val <!UNUSED_VARIABLE!>h<!> = if (false) <!IMPLICIT_CAST_TO_ANY!>4<!> else <!IMPLICIT_CAST_TO_ANY!>{}<!>
|
val <!UNUSED_VARIABLE!>h<!> = if (false) <!IMPLICIT_CAST_TO_ANY!>4<!> else <!IMPLICIT_CAST_TO_ANY!>{}<!>
|
||||||
|
|
||||||
bar(<!NI;TYPE_MISMATCH!>if (true) {
|
bar(<!NI;TYPE_MISMATCH!>if (true) {
|
||||||
<!OI;CONSTANT_EXPECTED_TYPE_MISMATCH!>4<!>
|
<!CONSTANT_EXPECTED_TYPE_MISMATCH, NI;CONSTANT_EXPECTED_TYPE_MISMATCH!>4<!>
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
<!UNUSED_VALUE!>z =<!> 342
|
<!UNUSED_VALUE!>z =<!> 342
|
||||||
|
|||||||
+2
-2
@@ -26,7 +26,7 @@ fun test1() {
|
|||||||
<!EXPECTED_PARAMETERS_NUMBER_MISMATCH!><!UNUSED_ANONYMOUS_PARAMETER!>x<!>, <!CANNOT_INFER_PARAMETER_TYPE, UNUSED_ANONYMOUS_PARAMETER!>y<!><!> -> ""
|
<!EXPECTED_PARAMETERS_NUMBER_MISMATCH!><!UNUSED_ANONYMOUS_PARAMETER!>x<!>, <!CANNOT_INFER_PARAMETER_TYPE, UNUSED_ANONYMOUS_PARAMETER!>y<!><!> -> ""
|
||||||
}<!>
|
}<!>
|
||||||
foo1 <!NI;TYPE_MISMATCH!>{
|
foo1 <!NI;TYPE_MISMATCH!>{
|
||||||
<!EXPECTED_PARAMETERS_NUMBER_MISMATCH!><!>-> <!CONSTANT_EXPECTED_TYPE_MISMATCH, NI;CONSTANT_EXPECTED_TYPE_MISMATCH!>42<!>
|
<!EXPECTED_PARAMETERS_NUMBER_MISMATCH!><!>-> <!CONSTANT_EXPECTED_TYPE_MISMATCH, NI;CONSTANT_EXPECTED_TYPE_MISMATCH, NI;CONSTANT_EXPECTED_TYPE_MISMATCH!>42<!>
|
||||||
}<!>
|
}<!>
|
||||||
|
|
||||||
|
|
||||||
@@ -40,6 +40,6 @@ fun test1() {
|
|||||||
<!EXPECTED_PARAMETERS_NUMBER_MISMATCH, UNUSED_ANONYMOUS_PARAMETER!>x<!> -> ""
|
<!EXPECTED_PARAMETERS_NUMBER_MISMATCH, UNUSED_ANONYMOUS_PARAMETER!>x<!> -> ""
|
||||||
}<!>
|
}<!>
|
||||||
foo2 <!NI;TYPE_MISMATCH!>{
|
foo2 <!NI;TYPE_MISMATCH!>{
|
||||||
<!EXPECTED_PARAMETERS_NUMBER_MISMATCH!><!>-> <!CONSTANT_EXPECTED_TYPE_MISMATCH, NI;CONSTANT_EXPECTED_TYPE_MISMATCH!>42<!>
|
<!EXPECTED_PARAMETERS_NUMBER_MISMATCH!><!>-> <!CONSTANT_EXPECTED_TYPE_MISMATCH, NI;CONSTANT_EXPECTED_TYPE_MISMATCH, NI;CONSTANT_EXPECTED_TYPE_MISMATCH!>42<!>
|
||||||
}<!>
|
}<!>
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+2
-2
@@ -1,10 +1,10 @@
|
|||||||
// !WITH_NEW_INFERENCE
|
// !WITH_NEW_INFERENCE
|
||||||
fun test(a: Int) {
|
fun test(a: Int) {
|
||||||
run<Int>f@{
|
run<Int>f@{
|
||||||
if (a > 0) return@f <!TYPE_MISMATCH!>""<!>
|
if (a > 0) return@f <!NI;TYPE_MISMATCH, TYPE_MISMATCH!>""<!>
|
||||||
return@f 1
|
return@f 1
|
||||||
}
|
}
|
||||||
|
|
||||||
run<Int>{ <!TYPE_MISMATCH!>""<!> }
|
run<Int>{ <!NI;TYPE_MISMATCH, TYPE_MISMATCH!>""<!> }
|
||||||
run<Int>{ 1 }
|
run<Int>{ 1 }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
// !WITH_NEW_INFERENCE
|
|
||||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION
|
|
||||||
|
|
||||||
interface Inv<T1>
|
|
||||||
class InvImpl<T2> : Inv<T2>
|
|
||||||
open class OpenInv<T>
|
|
||||||
|
|
||||||
class A<T> {
|
|
||||||
fun <F : OpenInv<T>> foo(x: F) = 1
|
|
||||||
|
|
||||||
}
|
|
||||||
class B<T> {
|
|
||||||
fun <F : Inv<T>> foo(x: F) = 1
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
fun test(a: A<out CharSequence>, b: B<out CharSequence>) {
|
|
||||||
a.<!OI;TYPE_INFERENCE_INCORPORATION_ERROR!>foo<!>(<!OI;TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>OpenInv<!>())
|
|
||||||
b.<!OI;TYPE_INFERENCE_INCORPORATION_ERROR!>foo<!>(<!OI;TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>InvImpl<!>())
|
|
||||||
}
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
package
|
|
||||||
|
|
||||||
public fun test(/*0*/ a: A<out kotlin.CharSequence>, /*1*/ b: B<out kotlin.CharSequence>): kotlin.Unit
|
|
||||||
|
|
||||||
public final class A</*0*/ T> {
|
|
||||||
public constructor A</*0*/ T>()
|
|
||||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
|
||||||
public final fun </*0*/ F : OpenInv<T>> foo(/*0*/ x: F): kotlin.Int
|
|
||||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
|
||||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
|
||||||
}
|
|
||||||
|
|
||||||
public final class B</*0*/ T> {
|
|
||||||
public constructor B</*0*/ T>()
|
|
||||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
|
||||||
public final fun </*0*/ F : Inv<T>> foo(/*0*/ x: F): kotlin.Int
|
|
||||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
|
||||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface Inv</*0*/ T1> {
|
|
||||||
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 InvImpl</*0*/ T2> : Inv<T2> {
|
|
||||||
public constructor InvImpl</*0*/ T2>()
|
|
||||||
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 open class OpenInv</*0*/ T> {
|
|
||||||
public constructor OpenInv</*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
|
|
||||||
}
|
|
||||||
+1
-1
@@ -20,7 +20,7 @@ class Outer<E> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (y is Outer<*>.Inner<*>) {
|
if (y is Outer<*>.Inner<*>) {
|
||||||
<!OI;DEBUG_INFO_SMARTCAST!>y<!>.prop.checkType { _<Any?>() }
|
<!DEBUG_INFO_SMARTCAST!>y<!>.prop.checkType { _<Any?>() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -9,7 +9,7 @@ fun foo(x: Any?, y: C<*>) {
|
|||||||
y.<!OI;MEMBER_PROJECTED_OUT!>bindTo<!>(<!NI;TYPE_MISMATCH!>""<!>)
|
y.<!OI;MEMBER_PROJECTED_OUT!>bindTo<!>(<!NI;TYPE_MISMATCH!>""<!>)
|
||||||
|
|
||||||
if (x is C<*>) {
|
if (x is C<*>) {
|
||||||
<!OI;DEBUG_INFO_SMARTCAST!>x<!>.<!OI;MEMBER_PROJECTED_OUT!>bindTo<!>(<!NI;TYPE_MISMATCH!>""<!>)
|
<!DEBUG_INFO_SMARTCAST!>x<!>.<!OI;MEMBER_PROJECTED_OUT!>bindTo<!>(<!NI;TYPE_MISMATCH!>""<!>)
|
||||||
with(<!DEBUG_INFO_SMARTCAST!>x<!>) {
|
with(<!DEBUG_INFO_SMARTCAST!>x<!>) {
|
||||||
<!OI;MEMBER_PROJECTED_OUT!>bindTo<!>(<!NI;TYPE_MISMATCH!>""<!>)
|
<!OI;MEMBER_PROJECTED_OUT!>bindTo<!>(<!NI;TYPE_MISMATCH!>""<!>)
|
||||||
}
|
}
|
||||||
@@ -17,7 +17,7 @@ fun foo(x: Any?, y: C<*>) {
|
|||||||
|
|
||||||
with(x) {
|
with(x) {
|
||||||
if (this is C<*>) {
|
if (this is C<*>) {
|
||||||
<!OI;DEBUG_INFO_IMPLICIT_RECEIVER_SMARTCAST, OI;MEMBER_PROJECTED_OUT!>bindTo<!>(<!NI;TYPE_MISMATCH!>""<!>)
|
<!DEBUG_INFO_IMPLICIT_RECEIVER_SMARTCAST, OI;MEMBER_PROJECTED_OUT!>bindTo<!>(<!NI;TYPE_MISMATCH!>""<!>)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-2
@@ -5,6 +5,5 @@ interface A<T : A<T?>?> {
|
|||||||
fun foo(): T?
|
fun foo(): T?
|
||||||
}
|
}
|
||||||
fun testA(a: A<*>) {
|
fun testA(a: A<*>) {
|
||||||
// in new inference here we have A<A<A<*>>>
|
a.foo() checkType { _<A<*>?>() }
|
||||||
a.foo() checkType { <!NI;DEBUG_INFO_UNRESOLVED_WITH_TARGET, NI;UNRESOLVED_REFERENCE_WRONG_RECEIVER!>_<!><A<*>?>() }
|
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-5
@@ -14,14 +14,14 @@ class A<E> {
|
|||||||
fun test(a: A<out CharSequence>, z: Out<CharSequence>) {
|
fun test(a: A<out CharSequence>, z: Out<CharSequence>) {
|
||||||
a.foo {
|
a.foo {
|
||||||
val x: String = <!CONSTANT_EXPECTED_TYPE_MISMATCH!>1<!> // Should be no TYPE_MISMATCH_DUE_TO_TYPE_PROJECTIONS
|
val x: String = <!CONSTANT_EXPECTED_TYPE_MISMATCH!>1<!> // Should be no TYPE_MISMATCH_DUE_TO_TYPE_PROJECTIONS
|
||||||
<!NI;TYPE_MISMATCH, TYPE_MISMATCH!>""<!>
|
<!NI;TYPE_MISMATCH, NI;TYPE_MISMATCH, TYPE_MISMATCH!>""<!>
|
||||||
}
|
}
|
||||||
a.bar { <!NI;TYPE_MISMATCH, NI;TYPE_MISMATCH, TYPE_MISMATCH!>Out<CharSequence>()<!> }
|
a.bar { <!NI;TYPE_MISMATCH, NI;TYPE_MISMATCH, NI;TYPE_MISMATCH, TYPE_MISMATCH!>Out<CharSequence>()<!> }
|
||||||
a.bar { Out() }
|
a.bar { Out() }
|
||||||
a.bar { <!NI;TYPE_MISMATCH, TYPE_MISMATCH!>z.id()<!> }
|
a.bar { <!NI;TYPE_MISMATCH, NI;TYPE_MISMATCH, TYPE_MISMATCH!>z.id()<!> }
|
||||||
|
|
||||||
a.foo {
|
a.foo {
|
||||||
z.foobar(if (1 > 2) return@foo <!TYPE_MISMATCH!>""<!> else "")
|
z.foobar(if (1 > 2) return@foo <!NI;TYPE_MISMATCH, NI;TYPE_MISMATCH, TYPE_MISMATCH!>""<!> else "")
|
||||||
<!NI;TYPE_MISMATCH, TYPE_MISMATCH!>""<!>
|
<!NI;TYPE_MISMATCH, NI;TYPE_MISMATCH, TYPE_MISMATCH!>""<!>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-6
@@ -14,14 +14,14 @@ class A<T> {
|
|||||||
|
|
||||||
fun foo2(a: A<out CharSequence>, b: A<in CharSequence>) {
|
fun foo2(a: A<out CharSequence>, b: A<in CharSequence>) {
|
||||||
a.<!OI;TYPE_INFERENCE_UPPER_BOUND_VIOLATED!>foo1<!>(<!NI;TYPE_MISMATCH!>Out<CharSequence>()<!>)
|
a.<!OI;TYPE_INFERENCE_UPPER_BOUND_VIOLATED!>foo1<!>(<!NI;TYPE_MISMATCH!>Out<CharSequence>()<!>)
|
||||||
a.foo1<<!UPPER_BOUND_VIOLATED!>Out<CharSequence><!>>(Out())
|
a.foo1<<!UPPER_BOUND_VIOLATED!>Out<CharSequence><!>>(<!NI;TYPE_MISMATCH!>Out()<!>)
|
||||||
|
|
||||||
a.foo1(Out())
|
a.foo1(Out())
|
||||||
a.foo1(Out<Nothing>())
|
a.foo1(Out<Nothing>())
|
||||||
|
|
||||||
a.<!OI;TYPE_INFERENCE_INCORPORATION_ERROR!>foo2<!>(<!OI;TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>Inv<!>())
|
a.<!OI;TYPE_INFERENCE_INCORPORATION_ERROR!>foo2<!>(<!NI;TYPE_MISMATCH!><!OI;TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>Inv<!>()<!>)
|
||||||
a.<!OI;TYPE_INFERENCE_UPPER_BOUND_VIOLATED!>foo2<!>(<!NI;TYPE_MISMATCH!>Inv<CharSequence>()<!>)
|
a.<!OI;TYPE_INFERENCE_UPPER_BOUND_VIOLATED!>foo2<!>(<!NI;TYPE_MISMATCH!>Inv<CharSequence>()<!>)
|
||||||
a.foo2<<!UPPER_BOUND_VIOLATED!>Inv<CharSequence><!>>(<!NI;TYPE_MISMATCH, NI;TYPE_MISMATCH, NI;TYPE_MISMATCH!>Inv()<!>)
|
a.foo2<<!UPPER_BOUND_VIOLATED!>Inv<CharSequence><!>>(<!NI;TYPE_MISMATCH!>Inv()<!>)
|
||||||
|
|
||||||
a.foo3(In())
|
a.foo3(In())
|
||||||
a.foo3(In<CharSequence>())
|
a.foo3(In<CharSequence>())
|
||||||
@@ -31,13 +31,13 @@ fun foo2(a: A<out CharSequence>, b: A<in CharSequence>) {
|
|||||||
b.foo1(Out<CharSequence>())
|
b.foo1(Out<CharSequence>())
|
||||||
b.foo1<Out<CharSequence>>(Out())
|
b.foo1<Out<CharSequence>>(Out())
|
||||||
|
|
||||||
b.<!OI;TYPE_INFERENCE_INCORPORATION_ERROR!>foo2<!>(<!OI;TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>Inv<!>())
|
b.<!OI;TYPE_INFERENCE_INCORPORATION_ERROR!>foo2<!>(<!NI;TYPE_MISMATCH!><!OI;TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>Inv<!>()<!>)
|
||||||
b.<!OI;TYPE_INFERENCE_UPPER_BOUND_VIOLATED!>foo2<!>(<!NI;TYPE_MISMATCH!>Inv<CharSequence>()<!>)
|
b.<!OI;TYPE_INFERENCE_UPPER_BOUND_VIOLATED!>foo2<!>(<!NI;TYPE_MISMATCH!>Inv<CharSequence>()<!>)
|
||||||
b.foo2<<!UPPER_BOUND_VIOLATED!>Inv<CharSequence><!>>(<!NI;TYPE_MISMATCH, NI;TYPE_MISMATCH, NI;TYPE_MISMATCH, NI;TYPE_MISMATCH!>Inv()<!>)
|
b.foo2<<!UPPER_BOUND_VIOLATED!>Inv<CharSequence><!>>(<!NI;TYPE_MISMATCH!>Inv()<!>)
|
||||||
|
|
||||||
|
|
||||||
b.<!OI;TYPE_INFERENCE_UPPER_BOUND_VIOLATED!>foo3<!>(<!NI;TYPE_MISMATCH!>In<CharSequence>()<!>)
|
b.<!OI;TYPE_INFERENCE_UPPER_BOUND_VIOLATED!>foo3<!>(<!NI;TYPE_MISMATCH!>In<CharSequence>()<!>)
|
||||||
b.foo3<<!UPPER_BOUND_VIOLATED!>In<CharSequence><!>>(In())
|
b.foo3<<!UPPER_BOUND_VIOLATED!>In<CharSequence><!>>(<!NI;TYPE_MISMATCH!>In()<!>)
|
||||||
|
|
||||||
b.foo3(In<Any?>())
|
b.foo3(In<Any?>())
|
||||||
b.foo3(In())
|
b.foo3(In())
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ class Inv2<<!FINITE_BOUNDS_VIOLATION!>T : Inv2<in T><!>>(val x: T)
|
|||||||
fun main(a: A<*>, j: JavaClass<*>, i2: Inv2<*>) {
|
fun main(a: A<*>, j: JavaClass<*>, i2: Inv2<*>) {
|
||||||
// Probably it's too restrictive to suppose star projection type here as Any?,
|
// Probably it's too restrictive to suppose star projection type here as Any?,
|
||||||
// but looks like we can refine it later
|
// but looks like we can refine it later
|
||||||
a.foo() checkType { <!NI;DEBUG_INFO_UNRESOLVED_WITH_TARGET, NI;UNRESOLVED_REFERENCE_WRONG_RECEIVER!>_<!><Any?>() }
|
a.foo() checkType { _<Any?>() }
|
||||||
j.foo() checkType { <!NI;DEBUG_INFO_UNRESOLVED_WITH_TARGET, NI;UNRESOLVED_REFERENCE_WRONG_RECEIVER!>_<!><Any?>() }
|
j.foo() checkType { _<Any?>() }
|
||||||
i2.x checkType { _<Any?>() }
|
i2.x checkType { _<Any?>() }
|
||||||
|
|
||||||
j.bar(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>1<!>, <!CONSTANT_EXPECTED_TYPE_MISMATCH!>2<!>, <!NI;TYPE_MISMATCH, OI;TYPE_MISMATCH_DUE_TO_TYPE_PROJECTIONS!>Any()<!>)
|
j.bar(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>1<!>, <!CONSTANT_EXPECTED_TYPE_MISMATCH!>2<!>, <!NI;TYPE_MISMATCH, OI;TYPE_MISMATCH_DUE_TO_TYPE_PROJECTIONS!>Any()<!>)
|
||||||
|
|||||||
+1
-1
@@ -5,6 +5,6 @@ interface Tr<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun test(t: Tr<*>) {
|
fun test(t: Tr<*>) {
|
||||||
<!SETTER_PROJECTED_OUT!>t.v<!> = <!NI;TYPE_MISMATCH!>t<!>
|
<!SETTER_PROJECTED_OUT!>t.v<!> = t
|
||||||
t.v checkType { _<Tr<*>>() }
|
t.v checkType { _<Tr<*>>() }
|
||||||
}
|
}
|
||||||
+3
-4
@@ -7,9 +7,8 @@ interface Tr<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun test(t: Tr<*>) {
|
fun test(t: Tr<*>) {
|
||||||
<!NI;SETTER_PROJECTED_OUT!>t.v<!> = null!!
|
t.v = null!!
|
||||||
<!SETTER_PROJECTED_OUT!>t.v<!> = <!NI;TYPE_MISMATCH!>""<!>
|
<!SETTER_PROJECTED_OUT!>t.v<!> = ""
|
||||||
<!SETTER_PROJECTED_OUT!>t.v<!> = <!NI;NULL_FOR_NONNULL_TYPE!>null<!>
|
<!SETTER_PROJECTED_OUT!>t.v<!> = null
|
||||||
|
|
||||||
t.v checkType { _<Any?>() }
|
t.v checkType { _<Any?>() }
|
||||||
}
|
}
|
||||||
Vendored
-16
@@ -1,16 +0,0 @@
|
|||||||
// !WITH_NEW_INFERENCE
|
|
||||||
// Issue: KT-31594
|
|
||||||
|
|
||||||
// FILE: Tr.java
|
|
||||||
|
|
||||||
public class Tr<T> {
|
|
||||||
public T getV() { return null; }
|
|
||||||
public void setV(T value) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
// FILE: main.kt
|
|
||||||
|
|
||||||
fun test(t: Tr<*>) {
|
|
||||||
<!NI;SETTER_PROJECTED_OUT!>t.v<!> = null
|
|
||||||
<!NI;SETTER_PROJECTED_OUT!>t.v<!> = <!NI;TYPE_MISMATCH!>""<!>
|
|
||||||
}
|
|
||||||
Vendored
-12
@@ -1,12 +0,0 @@
|
|||||||
package
|
|
||||||
|
|
||||||
public fun test(/*0*/ t: Tr<*>): kotlin.Unit
|
|
||||||
|
|
||||||
public open class Tr</*0*/ T : kotlin.Any!> {
|
|
||||||
public constructor Tr</*0*/ T : kotlin.Any!>()
|
|
||||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
|
||||||
public open fun getV(): T!
|
|
||||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
|
||||||
public open fun setV(/*0*/ value: T!): kotlin.Unit
|
|
||||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
|
||||||
}
|
|
||||||
Vendored
+1
-1
@@ -7,5 +7,5 @@ interface Tr<T> {
|
|||||||
fun test(t: Tr<out String>) {
|
fun test(t: Tr<out String>) {
|
||||||
// resolved as t.v = t.v + null!!, where type of right operand is String,
|
// resolved as t.v = t.v + null!!, where type of right operand is String,
|
||||||
// so TYPE_MISMATCH: String is not <: of Captured(out String)
|
// so TYPE_MISMATCH: String is not <: of Captured(out String)
|
||||||
<!NI;TYPE_MISMATCH!><!SETTER_PROJECTED_OUT!>t.v<!> += null!!<!>
|
<!SETTER_PROJECTED_OUT!>t.v<!> += null!!
|
||||||
}
|
}
|
||||||
+6
-6
@@ -5,15 +5,15 @@
|
|||||||
fun <T: Any> bar(a: Array<T>): Array<T?> = null!!
|
fun <T: Any> bar(a: Array<T>): Array<T?> = null!!
|
||||||
|
|
||||||
fun test1(a: Array<out Int>) {
|
fun test1(a: Array<out Int>) {
|
||||||
val r: Array<out Int?> = bar(a)
|
val r: Array<out Int?> = <!NI;TYPE_MISMATCH!><!NI;UNSUPPORTED!>bar<!>(a)<!>
|
||||||
val t = bar(a)
|
val t = <!NI;UNSUPPORTED!>bar<!>(a)
|
||||||
t checkType { _<Array<out Int?>>() }
|
<!NI;UNSUPPORTED!>t<!> checkType { <!NI;DEBUG_INFO_UNRESOLVED_WITH_TARGET, NI;UNRESOLVED_REFERENCE_WRONG_RECEIVER!>_<!><Array<out Int?>>() }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <T: Any> foo(l: Array<T>): Array<Array<T?>> = null!!
|
fun <T: Any> foo(l: Array<T>): Array<Array<T?>> = null!!
|
||||||
|
|
||||||
fun test2(a: Array<out Int>) {
|
fun test2(a: Array<out Int>) {
|
||||||
val r: Array<out Array<out Int?>> = foo(a)
|
val r: Array<out Array<out Int?>> = <!NI;TYPE_MISMATCH!><!NI;UNSUPPORTED!>foo<!>(a)<!>
|
||||||
val t = foo(a)
|
val t = <!NI;UNSUPPORTED!>foo<!>(a)
|
||||||
t checkType { _<Array<out Array<out Int?>>>() }
|
<!NI;UNSUPPORTED!>t<!> checkType { <!NI;DEBUG_INFO_UNRESOLVED_WITH_TARGET, NI;UNRESOLVED_REFERENCE_WRONG_RECEIVER!>_<!><Array<out Array<out Int?>>>() }
|
||||||
}
|
}
|
||||||
+1
-1
@@ -16,5 +16,5 @@ fun <S> test1(a: ParameterizedChild<S>?, b: Child): Base<S> = myRun {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun <S> test2(a: S?, b: S): S = myRun {
|
fun <S> test2(a: S?, b: S): S = myRun {
|
||||||
<!TYPE_MISMATCH!>select(a, b)<!>
|
<!TYPE_MISMATCH, TYPE_MISMATCH!>select(a, b)<!>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,5 +10,5 @@ fun <A, B> Foo<A>.map(<!UNUSED_PARAMETER!>f<!>: (A) -> B): Foo<B> = object : Foo
|
|||||||
|
|
||||||
fun foo() {
|
fun foo() {
|
||||||
val l: Foo<String> = object : Foo<String> {}
|
val l: Foo<String> = object : Foo<String> {}
|
||||||
val <!UNUSED_VARIABLE!>m<!>: Foo<String> = l.<!OI;TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH!>map { <!UNUSED_ANONYMOUS_PARAMETER!>ppp<!> -> <!NI;CONSTANT_EXPECTED_TYPE_MISMATCH!>1<!> }<!>
|
val <!UNUSED_VARIABLE!>m<!>: Foo<String> = l.<!OI;TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH!>map { <!UNUSED_ANONYMOUS_PARAMETER!>ppp<!> -> <!NI;CONSTANT_EXPECTED_TYPE_MISMATCH, NI;CONSTANT_EXPECTED_TYPE_MISMATCH!>1<!> }<!>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,11 +18,11 @@ public interface J2 extends J {
|
|||||||
fun main() {
|
fun main() {
|
||||||
J <!NI;TYPE_MISMATCH!>{ <!EXPECTED_PARAMETER_TYPE_MISMATCH!>s: String<!> -> s}<!> // should be prohibited, because SAM value parameter has nullable type
|
J <!NI;TYPE_MISMATCH!>{ <!EXPECTED_PARAMETER_TYPE_MISMATCH!>s: String<!> -> s}<!> // should be prohibited, because SAM value parameter has nullable type
|
||||||
J { "" + it<!UNSAFE_CALL!>.<!>length }
|
J { "" + it<!UNSAFE_CALL!>.<!>length }
|
||||||
J { <!NI;NULL_FOR_NONNULL_TYPE, NULL_FOR_NONNULL_TYPE!>null<!> }
|
J { <!NI;NULL_FOR_NONNULL_TYPE, NI;NULL_FOR_NONNULL_TYPE, NULL_FOR_NONNULL_TYPE!>null<!> }
|
||||||
J { <!NI;TYPE_MISMATCH, TYPE_MISMATCH!>it?.length?.toString()<!> }
|
J { <!NI;TYPE_MISMATCH, NI;TYPE_MISMATCH, TYPE_MISMATCH!>it?.length?.toString()<!> }
|
||||||
|
|
||||||
J2 <!NI;TYPE_MISMATCH!>{ <!EXPECTED_PARAMETER_TYPE_MISMATCH!>s: String<!> -> s}<!>
|
J2 <!NI;TYPE_MISMATCH!>{ <!EXPECTED_PARAMETER_TYPE_MISMATCH!>s: String<!> -> s}<!>
|
||||||
J2 { "" + it<!UNSAFE_CALL!>.<!>length }
|
J2 { "" + it<!UNSAFE_CALL!>.<!>length }
|
||||||
J2 { <!NI;NULL_FOR_NONNULL_TYPE, NULL_FOR_NONNULL_TYPE!>null<!> }
|
J2 { <!NI;NULL_FOR_NONNULL_TYPE, NI;NULL_FOR_NONNULL_TYPE, NULL_FOR_NONNULL_TYPE!>null<!> }
|
||||||
J2 { <!NI;TYPE_MISMATCH, TYPE_MISMATCH!>it?.length?.toString()<!> }
|
J2 { <!NI;TYPE_MISMATCH, NI;TYPE_MISMATCH, TYPE_MISMATCH!>it?.length?.toString()<!> }
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -34,7 +34,7 @@ fun main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
A.baz {
|
A.baz {
|
||||||
x -> <!NI;TYPE_MISMATCH, TYPE_MISMATCH!>x.hashCode()<!>
|
x -> <!NI;TYPE_MISMATCH, NI;TYPE_MISMATCH, TYPE_MISMATCH!>x.hashCode()<!>
|
||||||
}
|
}
|
||||||
|
|
||||||
val block: (String) -> Any? = {
|
val block: (String) -> Any? = {
|
||||||
|
|||||||
+1
-1
@@ -14,5 +14,5 @@ class Owner<in T> {
|
|||||||
fun getT() = u
|
fun getT() = u
|
||||||
}
|
}
|
||||||
|
|
||||||
<!NI;TYPE_VARIANCE_CONFLICT!>fun foo(arg: Inner<*>)<!> = arg.getT()
|
fun foo(arg: Inner<*>) = arg.getT()
|
||||||
}
|
}
|
||||||
+2
-2
@@ -3,7 +3,7 @@ package
|
|||||||
public final class Owner</*0*/ in T> {
|
public final class Owner</*0*/ in T> {
|
||||||
public constructor Owner</*0*/ in T>()
|
public constructor Owner</*0*/ in T>()
|
||||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
public final fun foo(/*0*/ arg: Owner<T>.Inner<*>): T
|
public final fun foo(/*0*/ arg: Owner<T>.Inner<*>): kotlin.Any?
|
||||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ public interface Rec</*0*/ T : Rec<T>> {
|
|||||||
|
|
||||||
public interface Super</*0*/ out U> {
|
public interface Super</*0*/ out U> {
|
||||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
public open fun foo(/*0*/ p: Rec<*>): Rec<out Rec<out Rec<out Rec<out Rec<out Rec<out kotlin.Any?>>>>>>
|
public open fun foo(/*0*/ p: Rec<*>): Rec<*>
|
||||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+4
-4
@@ -29,9 +29,9 @@ class WithMod {
|
|||||||
<!FORBIDDEN_BINARY_MOD!>operator<!> fun mod(other: WithMod) = this
|
<!FORBIDDEN_BINARY_MOD!>operator<!> fun mod(other: WithMod) = this
|
||||||
|
|
||||||
fun test() {
|
fun test() {
|
||||||
val a = this <!OI;FORBIDDEN_BINARY_MOD_AS_REM!>%<!> this
|
val a = this <!OI;FORBIDDEN_BINARY_MOD_AS_REM!>%<!> <!NI;TYPE_MISMATCH!>this<!>
|
||||||
var b = this.mod(this)
|
var b = this.mod(this)
|
||||||
<!NI;TYPE_MISMATCH!>b <!OI;FORBIDDEN_BINARY_MOD_AS_REM!>%=<!> this<!>
|
<!NI;TYPE_MISMATCH!>b <!OI;FORBIDDEN_BINARY_MOD_AS_REM!>%=<!> <!NI;TYPE_MISMATCH!>this<!><!>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,6 +43,6 @@ fun builtIns(b: Byte, s: Short) {
|
|||||||
var a = 1 % 2
|
var a = 1 % 2
|
||||||
a <!NI;DEBUG_INFO_UNRESOLVED_WITH_TARGET, NI;UNRESOLVED_REFERENCE!>%=<!> 3
|
a <!NI;DEBUG_INFO_UNRESOLVED_WITH_TARGET, NI;UNRESOLVED_REFERENCE!>%=<!> 3
|
||||||
1.mod(2)
|
1.mod(2)
|
||||||
b % s
|
b % <!NI;TYPE_MISMATCH!>s<!>
|
||||||
1.0 % 2.0
|
1.0 % <!NI;CONSTANT_EXPECTED_TYPE_MISMATCH!>2.0<!>
|
||||||
}
|
}
|
||||||
Vendored
+4
-4
@@ -29,9 +29,9 @@ class WithMod {
|
|||||||
<!DEPRECATED_BINARY_MOD!>operator<!> fun mod(other: WithMod) = this
|
<!DEPRECATED_BINARY_MOD!>operator<!> fun mod(other: WithMod) = this
|
||||||
|
|
||||||
fun test() {
|
fun test() {
|
||||||
val a = this <!OI;DEPRECATED_BINARY_MOD_AS_REM!>%<!> this
|
val a = this <!OI;DEPRECATED_BINARY_MOD_AS_REM!>%<!> <!NI;TYPE_MISMATCH!>this<!>
|
||||||
var b = this.mod(this)
|
var b = this.mod(this)
|
||||||
<!NI;TYPE_MISMATCH!>b <!OI;DEPRECATED_BINARY_MOD_AS_REM!>%=<!> this<!>
|
<!NI;TYPE_MISMATCH!>b <!OI;DEPRECATED_BINARY_MOD_AS_REM!>%=<!> <!NI;TYPE_MISMATCH!>this<!><!>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,6 +43,6 @@ fun builtIns(b: Byte, s: Short) {
|
|||||||
var a = 1 % 2
|
var a = 1 % 2
|
||||||
a <!NI;DEBUG_INFO_UNRESOLVED_WITH_TARGET, NI;UNRESOLVED_REFERENCE!>%=<!> 3
|
a <!NI;DEBUG_INFO_UNRESOLVED_WITH_TARGET, NI;UNRESOLVED_REFERENCE!>%=<!> 3
|
||||||
1.mod(2)
|
1.mod(2)
|
||||||
b % s
|
b % <!NI;TYPE_MISMATCH!>s<!>
|
||||||
1.0 % 2.0
|
1.0 % <!NI;CONSTANT_EXPECTED_TYPE_MISMATCH!>2.0<!>
|
||||||
}
|
}
|
||||||
Vendored
+3
-7
@@ -11,13 +11,9 @@ public class A {
|
|||||||
// FILE: k.kt
|
// FILE: k.kt
|
||||||
|
|
||||||
fun test() {
|
fun test() {
|
||||||
A.<!OI;TYPE_INFERENCE_INCORPORATION_ERROR!>bar<!>(<!OI;NULL_FOR_NONNULL_TYPE!>null<!>, "")
|
A.<!OI;TYPE_INFERENCE_INCORPORATION_ERROR!>bar<!>(<!NULL_FOR_NONNULL_TYPE!>null<!>, "")
|
||||||
|
|
||||||
A.bar<String>(<!NULL_FOR_NONNULL_TYPE!>null<!>, "")
|
A.bar<String>(<!NULL_FOR_NONNULL_TYPE!>null<!>, "")
|
||||||
A.bar<String?>(<!OI;NULL_FOR_NONNULL_TYPE!>null<!>, "")
|
A.bar<String?>(<!NULL_FOR_NONNULL_TYPE!>null<!>, "")
|
||||||
A.<!OI;TYPE_INFERENCE_INCORPORATION_ERROR!>bar<!>(<!OI;NULL_FOR_NONNULL_TYPE!>null<!>, A.platformString())
|
A.<!OI;TYPE_INFERENCE_INCORPORATION_ERROR!>bar<!>(<!NULL_FOR_NONNULL_TYPE!>null<!>, A.platformString())
|
||||||
|
|
||||||
val x: String? = null
|
|
||||||
A.<!OI;TYPE_INFERENCE_INCORPORATION_ERROR!>bar<!>(<!OI;TYPE_MISMATCH!>x<!>, "")
|
|
||||||
A.<!OI;TYPE_INFERENCE_INCORPORATION_ERROR!>bar<!>(<!OI;NULL_FOR_NONNULL_TYPE!>null<!>, "")
|
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||||
|
|
||||||
fun test(a: Int, b: Boolean) {
|
fun test(a: Int, b: Boolean) {
|
||||||
<!OI;TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>bar<!>(a.<!OI;TYPE_INFERENCE_PARAMETER_CONSTRAINT_ERROR!>foo<!>(<!NI;TYPE_MISMATCH, TYPE_MISMATCH!>b<!>))
|
<!OI;TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>bar<!>(a.<!OI;TYPE_INFERENCE_PARAMETER_CONSTRAINT_ERROR!>foo<!>(<!NI;TYPE_MISMATCH, NI;TYPE_MISMATCH, TYPE_MISMATCH!>b<!>))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <T, R> T.foo(l: (T) -> R): R = TODO()
|
fun <T, R> T.foo(l: (T) -> R): R = TODO()
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
// !LANGUAGE: -NewInference
|
|
||||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION
|
|
||||||
// !WITH_NEW_INFERENCE
|
|
||||||
|
|
||||||
abstract class A<Context : A<Context>> {
|
|
||||||
val x: X = TODO()
|
|
||||||
|
|
||||||
fun getGetX(): X = TODO()
|
|
||||||
}
|
|
||||||
|
|
||||||
class B<D> : A<B<D>>()
|
|
||||||
|
|
||||||
class C : A<C>()
|
|
||||||
|
|
||||||
interface X {
|
|
||||||
fun foo()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun B<*>.checkValueArguments() {
|
|
||||||
this.x.foo()
|
|
||||||
x.foo()
|
|
||||||
|
|
||||||
this.getGetX().foo()
|
|
||||||
getGetX().foo()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun C.test() {
|
|
||||||
x.foo()
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
package
|
|
||||||
|
|
||||||
public fun B<*>.checkValueArguments(): kotlin.Unit
|
|
||||||
public fun C.test(): kotlin.Unit
|
|
||||||
|
|
||||||
public abstract class A</*0*/ Context : A<Context>> {
|
|
||||||
public constructor A</*0*/ Context : A<Context>>()
|
|
||||||
public final val x: X
|
|
||||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
|
||||||
public final fun getGetX(): X
|
|
||||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
|
||||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
|
||||||
}
|
|
||||||
|
|
||||||
public final class B</*0*/ D> : A<B<D>> {
|
|
||||||
public constructor B</*0*/ D>()
|
|
||||||
public final override /*1*/ /*fake_override*/ val x: X
|
|
||||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
|
||||||
public final override /*1*/ /*fake_override*/ fun getGetX(): X
|
|
||||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
|
||||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
|
||||||
}
|
|
||||||
|
|
||||||
public final class C : A<C> {
|
|
||||||
public constructor C()
|
|
||||||
public final override /*1*/ /*fake_override*/ val x: X
|
|
||||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
|
||||||
public final override /*1*/ /*fake_override*/ fun getGetX(): X
|
|
||||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
|
||||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface X {
|
|
||||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
|
||||||
public abstract fun foo(): kotlin.Unit
|
|
||||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
|
||||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
|
||||||
}
|
|
||||||
+1
-1
@@ -8,7 +8,7 @@ fun test() {
|
|||||||
<!OI;CONSTANT_EXPECTED_TYPE_MISMATCH!>2<!>
|
<!OI;CONSTANT_EXPECTED_TYPE_MISMATCH!>2<!>
|
||||||
}<!>)
|
}<!>)
|
||||||
|
|
||||||
bar(<!NI;TYPE_MISMATCH, NI;TYPE_MISMATCH!><!OI;CONSTANT_EXPECTED_TYPE_MISMATCH!>1<!> ?: <!OI;CONSTANT_EXPECTED_TYPE_MISMATCH!>2<!><!>)
|
bar(<!NI;TYPE_MISMATCH, NI;TYPE_MISMATCH!><!CONSTANT_EXPECTED_TYPE_MISMATCH, NI;CONSTANT_EXPECTED_TYPE_MISMATCH!>1<!> ?: <!CONSTANT_EXPECTED_TYPE_MISMATCH, NI;CONSTANT_EXPECTED_TYPE_MISMATCH!>2<!><!>)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun bar(s: String) = s
|
fun bar(s: String) = s
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
|
||||||
// !WITH_NEW_INFERENCE
|
|
||||||
|
|
||||||
// FILE: JavaFace.java
|
|
||||||
public interface JavaFace<T> {
|
|
||||||
void singleMethod();
|
|
||||||
}
|
|
||||||
|
|
||||||
// FILE: JavaFaceUser.java
|
|
||||||
public class JavaFaceUser<T> {
|
|
||||||
public <X> void use1(JavaFace<X> face) {}
|
|
||||||
public void use2(JavaFace<T> face) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
// FILE: KotlinSamUser.kt
|
|
||||||
fun JavaFaceUser<out Any>.useOut() {
|
|
||||||
use1<Any> {}
|
|
||||||
use2 {}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun JavaFaceUser<in Any>.useIn() {
|
|
||||||
use1<Any> {}
|
|
||||||
use2 {}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun JavaFaceUser<Any>.useInv() {
|
|
||||||
use1<Any> {}
|
|
||||||
use2 {}
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
package
|
|
||||||
|
|
||||||
public fun JavaFaceUser<in kotlin.Any>.useIn(): kotlin.Unit
|
|
||||||
public fun JavaFaceUser<kotlin.Any>.useInv(): kotlin.Unit
|
|
||||||
public fun JavaFaceUser<out kotlin.Any>.useOut(): kotlin.Unit
|
|
||||||
|
|
||||||
public interface JavaFace</*0*/ T : kotlin.Any!> {
|
|
||||||
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 abstract fun singleMethod(): kotlin.Unit
|
|
||||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
|
||||||
}
|
|
||||||
|
|
||||||
public open class JavaFaceUser</*0*/ T : kotlin.Any!> {
|
|
||||||
public constructor JavaFaceUser</*0*/ T : kotlin.Any!>()
|
|
||||||
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 open fun </*0*/ X : kotlin.Any!> use1(/*0*/ face: JavaFace<X!>!): kotlin.Unit
|
|
||||||
public open fun use2(/*0*/ face: JavaFace<T!>!): kotlin.Unit
|
|
||||||
}
|
|
||||||
@@ -17,9 +17,9 @@ interface B<R, T: B<List<R>, <!UPPER_BOUND_VIOLATED!>T<!>>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun testB(b: B<*, *>) {
|
fun testB(b: B<*, *>) {
|
||||||
<!OI;TYPE_MISMATCH!>b<!>.r().checkType { _<Any?>() }
|
<!OI;TYPE_MISMATCH!>b<!>.<!NI;DEBUG_INFO_UNRESOLVED_WITH_TARGET, NI;UNRESOLVED_REFERENCE_WRONG_RECEIVER!>r<!>().<!NI;DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>checkType<!> { <!NI;UNRESOLVED_REFERENCE!>_<!><Any?>() }
|
||||||
<!OI;TYPE_MISMATCH!>b<!>.t().checkType { <!NI;DEBUG_INFO_UNRESOLVED_WITH_TARGET, NI;UNRESOLVED_REFERENCE_WRONG_RECEIVER!>_<!><B<List<*>, *>>() }
|
<!OI;TYPE_MISMATCH!>b<!>.<!NI;DEBUG_INFO_UNRESOLVED_WITH_TARGET, NI;UNRESOLVED_REFERENCE_WRONG_RECEIVER!>t<!>().<!NI;DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>checkType<!> { <!NI;UNRESOLVED_REFERENCE!>_<!><B<List<*>, *>>() }
|
||||||
|
|
||||||
<!OI;TYPE_MISMATCH!><!OI;TYPE_MISMATCH!>b<!>.t()<!>.r().size
|
<!OI;TYPE_MISMATCH!><!OI;TYPE_MISMATCH!>b<!>.<!NI;DEBUG_INFO_UNRESOLVED_WITH_TARGET, NI;UNRESOLVED_REFERENCE_WRONG_RECEIVER!>t<!>()<!>.<!NI;DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>r<!>().<!NI;DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>size<!>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -21,21 +21,21 @@ fun test2() {}
|
|||||||
@Ann(s = <!NI;TYPE_MISMATCH, OI;TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH!>arrayOf(1)<!>)
|
@Ann(s = <!NI;TYPE_MISMATCH, OI;TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH!>arrayOf(1)<!>)
|
||||||
fun test3() {}
|
fun test3() {}
|
||||||
|
|
||||||
@Ann(s = <!OI;TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH, TYPE_MISMATCH!>["value"]<!>)
|
@Ann(s = <!NI;TYPE_MISMATCH, OI;TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH, TYPE_MISMATCH!>["value"]<!>)
|
||||||
fun test5() {}
|
fun test5() {}
|
||||||
|
|
||||||
@JavaAnn(value = <!NI;TYPE_MISMATCH, OI;TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH!>arrayOf("value")<!>)
|
@JavaAnn(value = <!NI;TYPE_MISMATCH, OI;TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH!>arrayOf("value")<!>)
|
||||||
fun jTest1() {}
|
fun jTest1() {}
|
||||||
|
|
||||||
@JavaAnn(value = <!OI;TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH, TYPE_MISMATCH!>["value"]<!>)
|
@JavaAnn(value = <!NI;TYPE_MISMATCH, OI;TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH, TYPE_MISMATCH!>["value"]<!>)
|
||||||
fun jTest2() {}
|
fun jTest2() {}
|
||||||
|
|
||||||
@JavaAnn(value = <!OI;TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH, TYPE_MISMATCH!>["value"]<!>, path = ["path"])
|
@JavaAnn(value = <!NI;TYPE_MISMATCH, OI;TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH, TYPE_MISMATCH!>["value"]<!>, path = ["path"])
|
||||||
fun jTest3() {}
|
fun jTest3() {}
|
||||||
|
|
||||||
annotation class IntAnn(vararg val i: Int)
|
annotation class IntAnn(vararg val i: Int)
|
||||||
|
|
||||||
@IntAnn(i = <!OI;TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH, TYPE_MISMATCH!>[1, 2]<!>)
|
@IntAnn(i = <!NI;TYPE_MISMATCH, OI;TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH, TYPE_MISMATCH!>[1, 2]<!>)
|
||||||
fun foo1() {}
|
fun foo1() {}
|
||||||
|
|
||||||
@IntAnn(i = <!TYPE_MISMATCH!>intArrayOf(0)<!>)
|
@IntAnn(i = <!TYPE_MISMATCH!>intArrayOf(0)<!>)
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
|
|||||||
import org.jetbrains.kotlin.resolve.*
|
import org.jetbrains.kotlin.resolve.*
|
||||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory
|
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory
|
||||||
import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatformAnalyzerServices
|
import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatformAnalyzerServices
|
||||||
import org.jetbrains.kotlin.types.SubstitutingScopeProviderImpl
|
|
||||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices
|
import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices
|
||||||
import org.jetbrains.kotlin.types.expressions.FakeCallResolver
|
import org.jetbrains.kotlin.types.expressions.FakeCallResolver
|
||||||
|
|
||||||
@@ -41,7 +40,6 @@ fun createContainerForTests(project: Project, module: ModuleDescriptor): Contain
|
|||||||
BindingTraceContext(),
|
BindingTraceContext(),
|
||||||
LanguageVersionSettingsImpl.DEFAULT
|
LanguageVersionSettingsImpl.DEFAULT
|
||||||
)
|
)
|
||||||
useImpl<SubstitutingScopeProviderImpl>()
|
|
||||||
useImpl<AnnotationResolverImpl>()
|
useImpl<AnnotationResolverImpl>()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ fun case_5(x: Any?) {
|
|||||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!><!DEBUG_INFO_EXPRESSION_TYPE("ClassWithThreeTypeParameters<*, *, *> & kotlin.Any?"), DEBUG_INFO_SMARTCAST!>x<!>.x<!>
|
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!><!DEBUG_INFO_EXPRESSION_TYPE("ClassWithThreeTypeParameters<*, *, *> & kotlin.Any?"), DEBUG_INFO_SMARTCAST!>x<!>.x<!>
|
||||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!><!DEBUG_INFO_SMARTCAST!>x<!>.y<!>
|
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!><!DEBUG_INFO_SMARTCAST!>x<!>.y<!>
|
||||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!><!DEBUG_INFO_SMARTCAST!>x<!>.z<!>
|
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!><!DEBUG_INFO_SMARTCAST!>x<!>.z<!>
|
||||||
<!DEBUG_INFO_EXPRESSION_TYPE("ClassWithThreeTypeParameters<*, *, *> & InterfaceWithTwoTypeParameters<*, *> & kotlin.Any & kotlin.Any?")!>x<!>.ip2test()
|
<!DEBUG_INFO_EXPRESSION_TYPE("InterfaceWithTwoTypeParameters<*, *> & kotlin.Any?"), DEBUG_INFO_SMARTCAST!>x<!>.ip2test()
|
||||||
<!DEBUG_INFO_EXPRESSION_TYPE("ClassWithThreeTypeParameters<*, *, *> & InterfaceWithTwoTypeParameters<*, *> & kotlin.Any & kotlin.Any?")!>x<!>
|
<!DEBUG_INFO_EXPRESSION_TYPE("ClassWithThreeTypeParameters<*, *, *> & InterfaceWithTwoTypeParameters<*, *> & kotlin.Any & kotlin.Any?")!>x<!>
|
||||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!><!DEBUG_INFO_EXPRESSION_TYPE("ClassWithThreeTypeParameters<*, *, *> & kotlin.Any?"), DEBUG_INFO_SMARTCAST!>x<!>.x<!>
|
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!><!DEBUG_INFO_EXPRESSION_TYPE("ClassWithThreeTypeParameters<*, *, *> & kotlin.Any?"), DEBUG_INFO_SMARTCAST!>x<!>.x<!>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,18 +14,18 @@
|
|||||||
// TESTCASE NUMBER: 1
|
// TESTCASE NUMBER: 1
|
||||||
fun Any.case_1() {
|
fun Any.case_1() {
|
||||||
if (this is Inv<*>) {
|
if (this is Inv<*>) {
|
||||||
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<*> & kotlin.Any"), DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any")!>this<!>.test()
|
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<*>"), DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any"), DEBUG_INFO_SMARTCAST!>this<!>.test()
|
||||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int")!><!DEBUG_INFO_EXPRESSION_TYPE("Inv<*> & kotlin.Any"), DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any")!>this<!>.prop_4<!>
|
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int")!><!DEBUG_INFO_EXPRESSION_TYPE("Inv<*>"), DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any"), DEBUG_INFO_SMARTCAST!>this<!>.prop_4<!>
|
||||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int")!><!DEBUG_INFO_EXPRESSION_TYPE("Inv<*> & kotlin.Any"), DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any")!>this<!>.prop_4<!>.inv()
|
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int")!><!DEBUG_INFO_EXPRESSION_TYPE("Inv<*>"), DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any"), DEBUG_INFO_SMARTCAST!>this<!>.prop_4<!>.inv()
|
||||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int")!>prop_4<!>
|
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int"), DEBUG_INFO_IMPLICIT_RECEIVER_SMARTCAST!>prop_4<!>
|
||||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int")!>prop_4<!>.inv()
|
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int"), DEBUG_INFO_IMPLICIT_RECEIVER_SMARTCAST!>prop_4<!>.inv()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TESTCASE NUMBER: 2
|
// TESTCASE NUMBER: 2
|
||||||
fun Any.case_2() {
|
fun Any.case_2() {
|
||||||
if (this is ClassWithSixTypeParameters<*, *, *, *, *, *>) {
|
if (this is ClassWithSixTypeParameters<*, *, *, *, *, *>) {
|
||||||
<!DEBUG_INFO_EXPRESSION_TYPE("ClassWithSixTypeParameters<*, *, *, *, *, *> & kotlin.Any"), DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any")!>this<!>.test()
|
<!DEBUG_INFO_EXPRESSION_TYPE("ClassWithSixTypeParameters<*, *, *, *, *, *>"), DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any"), DEBUG_INFO_SMARTCAST!>this<!>.test()
|
||||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!><!DEBUG_INFO_EXPRESSION_TYPE("ClassWithSixTypeParameters<*, *, *, *, *, *>"), DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any"), DEBUG_INFO_SMARTCAST!>this<!>.x<!>
|
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!><!DEBUG_INFO_EXPRESSION_TYPE("ClassWithSixTypeParameters<*, *, *, *, *, *>"), DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any"), DEBUG_INFO_SMARTCAST!>this<!>.x<!>
|
||||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!><!DEBUG_INFO_EXPRESSION_TYPE("ClassWithSixTypeParameters<*, *, *, *, *, *>"), DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any"), DEBUG_INFO_SMARTCAST!>this<!>.y<!>
|
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!><!DEBUG_INFO_EXPRESSION_TYPE("ClassWithSixTypeParameters<*, *, *, *, *, *>"), DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any"), DEBUG_INFO_SMARTCAST!>this<!>.y<!>
|
||||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?"), DEBUG_INFO_IMPLICIT_RECEIVER_SMARTCAST!>x<!>
|
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?"), DEBUG_INFO_IMPLICIT_RECEIVER_SMARTCAST!>x<!>
|
||||||
@@ -36,18 +36,18 @@ fun Any.case_2() {
|
|||||||
// TESTCASE NUMBER: 3
|
// TESTCASE NUMBER: 3
|
||||||
fun <T> T.case_3() {
|
fun <T> T.case_3() {
|
||||||
if (this is Inv<*>) {
|
if (this is Inv<*>) {
|
||||||
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<*> & T & T!!"), DEBUG_INFO_EXPRESSION_TYPE("T")!>this<!>.test()
|
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<*>"), DEBUG_INFO_EXPRESSION_TYPE("T"), DEBUG_INFO_SMARTCAST!>this<!>.test()
|
||||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int")!><!DEBUG_INFO_EXPRESSION_TYPE("Inv<*> & T & T!!"), DEBUG_INFO_EXPRESSION_TYPE("T")!>this<!>.prop_4<!>
|
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int")!><!DEBUG_INFO_EXPRESSION_TYPE("Inv<*>"), DEBUG_INFO_EXPRESSION_TYPE("T"), DEBUG_INFO_SMARTCAST!>this<!>.prop_4<!>
|
||||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int")!><!DEBUG_INFO_EXPRESSION_TYPE("Inv<*> & T & T!!"), DEBUG_INFO_EXPRESSION_TYPE("T")!>this<!>.prop_4<!>.inv()
|
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int")!><!DEBUG_INFO_EXPRESSION_TYPE("Inv<*>"), DEBUG_INFO_EXPRESSION_TYPE("T"), DEBUG_INFO_SMARTCAST!>this<!>.prop_4<!>.inv()
|
||||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int")!>prop_4<!>
|
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int"), DEBUG_INFO_IMPLICIT_RECEIVER_SMARTCAST!>prop_4<!>
|
||||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int")!>prop_4<!>.inv()
|
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int"), DEBUG_INFO_IMPLICIT_RECEIVER_SMARTCAST!>prop_4<!>.inv()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TESTCASE NUMBER: 4
|
// TESTCASE NUMBER: 4
|
||||||
fun <T> T?.case_4() {
|
fun <T> T?.case_4() {
|
||||||
if (this is ClassWithSixTypeParameters<*, *, *, *, *, *>) {
|
if (this is ClassWithSixTypeParameters<*, *, *, *, *, *>) {
|
||||||
<!DEBUG_INFO_EXPRESSION_TYPE("ClassWithSixTypeParameters<*, *, *, *, *, *> & T!! & T?"), DEBUG_INFO_EXPRESSION_TYPE("T?")!>this<!>.test()
|
<!DEBUG_INFO_EXPRESSION_TYPE("ClassWithSixTypeParameters<*, *, *, *, *, *>"), DEBUG_INFO_EXPRESSION_TYPE("T?"), DEBUG_INFO_SMARTCAST!>this<!>.test()
|
||||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!><!DEBUG_INFO_EXPRESSION_TYPE("ClassWithSixTypeParameters<*, *, *, *, *, *>"), DEBUG_INFO_EXPRESSION_TYPE("T?"), DEBUG_INFO_SMARTCAST!>this<!>.x<!>
|
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!><!DEBUG_INFO_EXPRESSION_TYPE("ClassWithSixTypeParameters<*, *, *, *, *, *>"), DEBUG_INFO_EXPRESSION_TYPE("T?"), DEBUG_INFO_SMARTCAST!>this<!>.x<!>
|
||||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!><!DEBUG_INFO_EXPRESSION_TYPE("ClassWithSixTypeParameters<*, *, *, *, *, *>"), DEBUG_INFO_EXPRESSION_TYPE("T?"), DEBUG_INFO_SMARTCAST!>this<!>.y<!>
|
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!><!DEBUG_INFO_EXPRESSION_TYPE("ClassWithSixTypeParameters<*, *, *, *, *, *>"), DEBUG_INFO_EXPRESSION_TYPE("T?"), DEBUG_INFO_SMARTCAST!>this<!>.y<!>
|
||||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?"), DEBUG_INFO_IMPLICIT_RECEIVER_SMARTCAST!>x<!>
|
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?"), DEBUG_INFO_IMPLICIT_RECEIVER_SMARTCAST!>x<!>
|
||||||
|
|||||||
@@ -8093,11 +8093,6 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
|||||||
runTest("compiler/testData/diagnostics/tests/generics/argumentsForT.kt");
|
runTest("compiler/testData/diagnostics/tests/generics/argumentsForT.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("capturedTypeInInputPosition.kt")
|
|
||||||
public void testCapturedTypeInInputPosition() throws Exception {
|
|
||||||
runTest("compiler/testData/diagnostics/tests/generics/capturedTypeInInputPosition.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("commonSupertypeContravariant.kt")
|
@TestMetadata("commonSupertypeContravariant.kt")
|
||||||
public void testCommonSupertypeContravariant() throws Exception {
|
public void testCommonSupertypeContravariant() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/generics/commonSupertypeContravariant.kt");
|
runTest("compiler/testData/diagnostics/tests/generics/commonSupertypeContravariant.kt");
|
||||||
@@ -8937,11 +8932,6 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
|||||||
runTest("compiler/testData/diagnostics/tests/generics/varProjection/setterProjectedOutAssign.kt");
|
runTest("compiler/testData/diagnostics/tests/generics/varProjection/setterProjectedOutAssign.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("setterProjectedOutAssignFromJava.kt")
|
|
||||||
public void testSetterProjectedOutAssignFromJava() throws Exception {
|
|
||||||
runTest("compiler/testData/diagnostics/tests/generics/varProjection/setterProjectedOutAssignFromJava.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("setterProjectedOutNoPlusAssign.kt")
|
@TestMetadata("setterProjectedOutNoPlusAssign.kt")
|
||||||
public void testSetterProjectedOutNoPlusAssign() throws Exception {
|
public void testSetterProjectedOutNoPlusAssign() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/generics/varProjection/setterProjectedOutNoPlusAssign.kt");
|
runTest("compiler/testData/diagnostics/tests/generics/varProjection/setterProjectedOutNoPlusAssign.kt");
|
||||||
@@ -17385,11 +17375,6 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
|||||||
runTest("compiler/testData/diagnostics/tests/resolve/HiddenDeclarations.kt");
|
runTest("compiler/testData/diagnostics/tests/resolve/HiddenDeclarations.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("implicitAndExplicitThis.kt")
|
|
||||||
public void testImplicitAndExplicitThis() throws Exception {
|
|
||||||
runTest("compiler/testData/diagnostics/tests/resolve/implicitAndExplicitThis.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("implicitReceiverProperty.kt")
|
@TestMetadata("implicitReceiverProperty.kt")
|
||||||
public void testImplicitReceiverProperty() throws Exception {
|
public void testImplicitReceiverProperty() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/resolve/implicitReceiverProperty.kt");
|
runTest("compiler/testData/diagnostics/tests/resolve/implicitReceiverProperty.kt");
|
||||||
@@ -18107,11 +18092,6 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
|||||||
runTest("compiler/testData/diagnostics/tests/samConversions/GenericSubstitutionKT.kt");
|
runTest("compiler/testData/diagnostics/tests/samConversions/GenericSubstitutionKT.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("kt25290.kt")
|
|
||||||
public void testKt25290() throws Exception {
|
|
||||||
runTest("compiler/testData/diagnostics/tests/samConversions/kt25290.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("OverloadPriority.kt")
|
@TestMetadata("OverloadPriority.kt")
|
||||||
public void testOverloadPriority() throws Exception {
|
public void testOverloadPriority() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/samConversions/OverloadPriority.kt");
|
runTest("compiler/testData/diagnostics/tests/samConversions/OverloadPriority.kt");
|
||||||
|
|||||||
Generated
-20
@@ -8088,11 +8088,6 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
|
|||||||
runTest("compiler/testData/diagnostics/tests/generics/argumentsForT.kt");
|
runTest("compiler/testData/diagnostics/tests/generics/argumentsForT.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("capturedTypeInInputPosition.kt")
|
|
||||||
public void testCapturedTypeInInputPosition() throws Exception {
|
|
||||||
runTest("compiler/testData/diagnostics/tests/generics/capturedTypeInInputPosition.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("commonSupertypeContravariant.kt")
|
@TestMetadata("commonSupertypeContravariant.kt")
|
||||||
public void testCommonSupertypeContravariant() throws Exception {
|
public void testCommonSupertypeContravariant() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/generics/commonSupertypeContravariant.kt");
|
runTest("compiler/testData/diagnostics/tests/generics/commonSupertypeContravariant.kt");
|
||||||
@@ -8932,11 +8927,6 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
|
|||||||
runTest("compiler/testData/diagnostics/tests/generics/varProjection/setterProjectedOutAssign.kt");
|
runTest("compiler/testData/diagnostics/tests/generics/varProjection/setterProjectedOutAssign.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("setterProjectedOutAssignFromJava.kt")
|
|
||||||
public void testSetterProjectedOutAssignFromJava() throws Exception {
|
|
||||||
runTest("compiler/testData/diagnostics/tests/generics/varProjection/setterProjectedOutAssignFromJava.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("setterProjectedOutNoPlusAssign.kt")
|
@TestMetadata("setterProjectedOutNoPlusAssign.kt")
|
||||||
public void testSetterProjectedOutNoPlusAssign() throws Exception {
|
public void testSetterProjectedOutNoPlusAssign() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/generics/varProjection/setterProjectedOutNoPlusAssign.kt");
|
runTest("compiler/testData/diagnostics/tests/generics/varProjection/setterProjectedOutNoPlusAssign.kt");
|
||||||
@@ -17375,11 +17365,6 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
|
|||||||
runTest("compiler/testData/diagnostics/tests/resolve/HiddenDeclarations.kt");
|
runTest("compiler/testData/diagnostics/tests/resolve/HiddenDeclarations.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("implicitAndExplicitThis.kt")
|
|
||||||
public void testImplicitAndExplicitThis() throws Exception {
|
|
||||||
runTest("compiler/testData/diagnostics/tests/resolve/implicitAndExplicitThis.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("implicitReceiverProperty.kt")
|
@TestMetadata("implicitReceiverProperty.kt")
|
||||||
public void testImplicitReceiverProperty() throws Exception {
|
public void testImplicitReceiverProperty() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/resolve/implicitReceiverProperty.kt");
|
runTest("compiler/testData/diagnostics/tests/resolve/implicitReceiverProperty.kt");
|
||||||
@@ -18097,11 +18082,6 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
|
|||||||
runTest("compiler/testData/diagnostics/tests/samConversions/GenericSubstitutionKT.kt");
|
runTest("compiler/testData/diagnostics/tests/samConversions/GenericSubstitutionKT.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("kt25290.kt")
|
|
||||||
public void testKt25290() throws Exception {
|
|
||||||
runTest("compiler/testData/diagnostics/tests/samConversions/kt25290.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("OverloadPriority.kt")
|
@TestMetadata("OverloadPriority.kt")
|
||||||
public void testOverloadPriority() throws Exception {
|
public void testOverloadPriority() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/samConversions/OverloadPriority.kt");
|
runTest("compiler/testData/diagnostics/tests/samConversions/OverloadPriority.kt");
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ import org.jetbrains.kotlin.load.kotlin.KotlinClassFinder
|
|||||||
import org.jetbrains.kotlin.load.kotlin.PackagePartProvider
|
import org.jetbrains.kotlin.load.kotlin.PackagePartProvider
|
||||||
import org.jetbrains.kotlin.serialization.deserialization.ErrorReporter
|
import org.jetbrains.kotlin.serialization.deserialization.ErrorReporter
|
||||||
import org.jetbrains.kotlin.storage.StorageManager
|
import org.jetbrains.kotlin.storage.StorageManager
|
||||||
import org.jetbrains.kotlin.types.SubstitutingScopeProvider
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class JavaResolverComponents(
|
class JavaResolverComponents(
|
||||||
@@ -65,8 +64,7 @@ class JavaResolverComponents(
|
|||||||
val annotationTypeQualifierResolver: AnnotationTypeQualifierResolver,
|
val annotationTypeQualifierResolver: AnnotationTypeQualifierResolver,
|
||||||
val signatureEnhancement: SignatureEnhancement,
|
val signatureEnhancement: SignatureEnhancement,
|
||||||
val javaClassesTracker: JavaClassesTracker,
|
val javaClassesTracker: JavaClassesTracker,
|
||||||
val settings: JavaResolverSettings,
|
val settings: JavaResolverSettings
|
||||||
val substitutingScopeProvider: SubstitutingScopeProvider
|
|
||||||
) {
|
) {
|
||||||
fun replace(
|
fun replace(
|
||||||
javaResolverCache: JavaResolverCache = this.javaResolverCache
|
javaResolverCache: JavaResolverCache = this.javaResolverCache
|
||||||
@@ -75,7 +73,7 @@ class JavaResolverComponents(
|
|||||||
signaturePropagator, errorReporter, javaResolverCache,
|
signaturePropagator, errorReporter, javaResolverCache,
|
||||||
javaPropertyInitializerEvaluator, samConversionResolver, sourceElementFactory,
|
javaPropertyInitializerEvaluator, samConversionResolver, sourceElementFactory,
|
||||||
moduleClassResolver, packagePartProvider, supertypeLoopChecker, lookupTracker, module, reflectionTypes,
|
moduleClassResolver, packagePartProvider, supertypeLoopChecker, lookupTracker, module, reflectionTypes,
|
||||||
annotationTypeQualifierResolver, signatureEnhancement, javaClassesTracker, settings, substitutingScopeProvider
|
annotationTypeQualifierResolver, signatureEnhancement, javaClassesTracker, settings
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-2
@@ -46,8 +46,7 @@ class LazyJavaClassDescriptor(
|
|||||||
) : ClassDescriptorBase(
|
) : ClassDescriptorBase(
|
||||||
outerContext.storageManager, containingDeclaration, jClass.name,
|
outerContext.storageManager, containingDeclaration, jClass.name,
|
||||||
outerContext.components.sourceElementFactory.source(jClass),
|
outerContext.components.sourceElementFactory.source(jClass),
|
||||||
/* isExternal = */ false,
|
/* isExternal = */ false
|
||||||
outerContext.components.substitutingScopeProvider
|
|
||||||
), JavaClassDescriptor {
|
), JavaClassDescriptor {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|||||||
+1
-2
@@ -43,7 +43,6 @@ import org.jetbrains.kotlin.serialization.deserialization.ContractDeserializer
|
|||||||
import org.jetbrains.kotlin.serialization.deserialization.DeserializationComponents
|
import org.jetbrains.kotlin.serialization.deserialization.DeserializationComponents
|
||||||
import org.jetbrains.kotlin.serialization.deserialization.DeserializationConfiguration
|
import org.jetbrains.kotlin.serialization.deserialization.DeserializationConfiguration
|
||||||
import org.jetbrains.kotlin.storage.LockBasedStorageManager
|
import org.jetbrains.kotlin.storage.LockBasedStorageManager
|
||||||
import org.jetbrains.kotlin.types.SubstitutingScopeProvider
|
|
||||||
import org.jetbrains.kotlin.utils.Jsr305State
|
import org.jetbrains.kotlin.utils.Jsr305State
|
||||||
|
|
||||||
class RuntimeModuleData private constructor(
|
class RuntimeModuleData private constructor(
|
||||||
@@ -71,7 +70,7 @@ class RuntimeModuleData private constructor(
|
|||||||
singleModuleClassResolver, PackagePartProvider.Empty, SupertypeLoopChecker.EMPTY, LookupTracker.DO_NOTHING, module,
|
singleModuleClassResolver, PackagePartProvider.Empty, SupertypeLoopChecker.EMPTY, LookupTracker.DO_NOTHING, module,
|
||||||
ReflectionTypes(module, notFoundClasses), annotationTypeQualifierResolver,
|
ReflectionTypes(module, notFoundClasses), annotationTypeQualifierResolver,
|
||||||
SignatureEnhancement(annotationTypeQualifierResolver, Jsr305State.DISABLED),
|
SignatureEnhancement(annotationTypeQualifierResolver, Jsr305State.DISABLED),
|
||||||
JavaClassesTracker.Default, JavaResolverSettings.Default, SubstitutingScopeProvider.DEFAULT
|
JavaClassesTracker.Default, JavaResolverSettings.Default
|
||||||
)
|
)
|
||||||
|
|
||||||
val lazyJavaPackageFragmentProvider = LazyJavaPackageFragmentProvider(javaResolverComponents)
|
val lazyJavaPackageFragmentProvider = LazyJavaPackageFragmentProvider(javaResolverComponents)
|
||||||
|
|||||||
+5
-10
@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor;
|
|||||||
import org.jetbrains.kotlin.name.Name;
|
import org.jetbrains.kotlin.name.Name;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.InnerClassesScopeWrapper;
|
import org.jetbrains.kotlin.resolve.scopes.InnerClassesScopeWrapper;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope;
|
import org.jetbrains.kotlin.resolve.scopes.MemberScope;
|
||||||
|
import org.jetbrains.kotlin.resolve.scopes.SubstitutingScope;
|
||||||
import org.jetbrains.kotlin.storage.NotNullLazyValue;
|
import org.jetbrains.kotlin.storage.NotNullLazyValue;
|
||||||
import org.jetbrains.kotlin.storage.StorageManager;
|
import org.jetbrains.kotlin.storage.StorageManager;
|
||||||
import org.jetbrains.kotlin.types.*;
|
import org.jetbrains.kotlin.types.*;
|
||||||
@@ -33,11 +34,10 @@ import java.util.List;
|
|||||||
public abstract class AbstractClassDescriptor implements ClassDescriptor {
|
public abstract class AbstractClassDescriptor implements ClassDescriptor {
|
||||||
private final Name name;
|
private final Name name;
|
||||||
protected final NotNullLazyValue<SimpleType> defaultType;
|
protected final NotNullLazyValue<SimpleType> defaultType;
|
||||||
protected final SubstitutingScopeProvider substitutingScopeProvider;
|
|
||||||
private final NotNullLazyValue<MemberScope> unsubstitutedInnerClassesScope;
|
private final NotNullLazyValue<MemberScope> unsubstitutedInnerClassesScope;
|
||||||
private final NotNullLazyValue<ReceiverParameterDescriptor> thisAsReceiverParameter;
|
private final NotNullLazyValue<ReceiverParameterDescriptor> thisAsReceiverParameter;
|
||||||
|
|
||||||
public AbstractClassDescriptor(@NotNull StorageManager storageManager, @NotNull Name name, @NotNull SubstitutingScopeProvider substitutingScopeProvider) {
|
public AbstractClassDescriptor(@NotNull StorageManager storageManager, @NotNull Name name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.defaultType = storageManager.createLazyValue(new Function0<SimpleType>() {
|
this.defaultType = storageManager.createLazyValue(new Function0<SimpleType>() {
|
||||||
@Override
|
@Override
|
||||||
@@ -57,11 +57,6 @@ public abstract class AbstractClassDescriptor implements ClassDescriptor {
|
|||||||
return new LazyClassReceiverParameterDescriptor(AbstractClassDescriptor.this);
|
return new LazyClassReceiverParameterDescriptor(AbstractClassDescriptor.this);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.substitutingScopeProvider = substitutingScopeProvider;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AbstractClassDescriptor(@NotNull StorageManager storageManager, @NotNull Name name) {
|
|
||||||
this(storageManager, name, SubstitutingScopeProvider.Companion.getDEFAULT());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -97,7 +92,7 @@ public abstract class AbstractClassDescriptor implements ClassDescriptor {
|
|||||||
if (typeArguments.isEmpty()) return getUnsubstitutedMemberScope();
|
if (typeArguments.isEmpty()) return getUnsubstitutedMemberScope();
|
||||||
|
|
||||||
TypeSubstitutor substitutor = TypeConstructorSubstitution.create(getTypeConstructor(), typeArguments).buildSubstitutor();
|
TypeSubstitutor substitutor = TypeConstructorSubstitution.create(getTypeConstructor(), typeArguments).buildSubstitutor();
|
||||||
return substitutingScopeProvider.createSubstitutingScope(getUnsubstitutedMemberScope(), substitutor);
|
return new SubstitutingScope(getUnsubstitutedMemberScope(), substitutor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -106,7 +101,7 @@ public abstract class AbstractClassDescriptor implements ClassDescriptor {
|
|||||||
if (typeSubstitution.isEmpty()) return getUnsubstitutedMemberScope();
|
if (typeSubstitution.isEmpty()) return getUnsubstitutedMemberScope();
|
||||||
|
|
||||||
TypeSubstitutor substitutor = TypeSubstitutor.create(typeSubstitution);
|
TypeSubstitutor substitutor = TypeSubstitutor.create(typeSubstitution);
|
||||||
return substitutingScopeProvider.createSubstitutingScope(getUnsubstitutedMemberScope(), substitutor);
|
return new SubstitutingScope(getUnsubstitutedMemberScope(), substitutor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -115,7 +110,7 @@ public abstract class AbstractClassDescriptor implements ClassDescriptor {
|
|||||||
if (substitutor.isEmpty()) {
|
if (substitutor.isEmpty()) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
return new LazySubstitutingClassDescriptor(this, substitutor, substitutingScopeProvider);
|
return new LazySubstitutingClassDescriptor(this, substitutor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
+1
-13
@@ -21,7 +21,6 @@ import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
|
|||||||
import org.jetbrains.kotlin.descriptors.SourceElement;
|
import org.jetbrains.kotlin.descriptors.SourceElement;
|
||||||
import org.jetbrains.kotlin.name.Name;
|
import org.jetbrains.kotlin.name.Name;
|
||||||
import org.jetbrains.kotlin.storage.StorageManager;
|
import org.jetbrains.kotlin.storage.StorageManager;
|
||||||
import org.jetbrains.kotlin.types.SubstitutingScopeProvider;
|
|
||||||
|
|
||||||
public abstract class ClassDescriptorBase extends AbstractClassDescriptor {
|
public abstract class ClassDescriptorBase extends AbstractClassDescriptor {
|
||||||
|
|
||||||
@@ -36,18 +35,7 @@ public abstract class ClassDescriptorBase extends AbstractClassDescriptor {
|
|||||||
@NotNull SourceElement source,
|
@NotNull SourceElement source,
|
||||||
boolean isExternal
|
boolean isExternal
|
||||||
) {
|
) {
|
||||||
this(storageManager, containingDeclaration, name, source, isExternal, SubstitutingScopeProvider.Companion.getDEFAULT());
|
super(storageManager, name);
|
||||||
}
|
|
||||||
|
|
||||||
protected ClassDescriptorBase(
|
|
||||||
@NotNull StorageManager storageManager,
|
|
||||||
@NotNull DeclarationDescriptor containingDeclaration,
|
|
||||||
@NotNull Name name,
|
|
||||||
@NotNull SourceElement source,
|
|
||||||
boolean isExternal,
|
|
||||||
@NotNull SubstitutingScopeProvider substitutingScopeProvider
|
|
||||||
) {
|
|
||||||
super(storageManager, name, substitutingScopeProvider);
|
|
||||||
this.containingDeclaration = containingDeclaration;
|
this.containingDeclaration = containingDeclaration;
|
||||||
this.source = source;
|
this.source = source;
|
||||||
this.isExternal = isExternal;
|
this.isExternal = isExternal;
|
||||||
|
|||||||
+2
-21
@@ -324,21 +324,11 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
|
||||||
public FunctionDescriptor substitute(@NotNull TypeSubstitutor originalSubstitutor) {
|
public FunctionDescriptor substitute(@NotNull TypeSubstitutor originalSubstitutor) {
|
||||||
return substitute(originalSubstitutor, SubstitutingScopeProvider.Companion.getDEFAULT());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public FunctionDescriptor substitute(@NotNull TypeSubstitutor originalSubstitutor, SubstitutingScopeProvider substitutingScopeProvider) {
|
|
||||||
if (originalSubstitutor.isEmpty()) {
|
if (originalSubstitutor.isEmpty()) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
return newCopyBuilder(originalSubstitutor)
|
return newCopyBuilder(originalSubstitutor).setOriginal(getOriginal()).setJustForTypeSubstitution(true).build();
|
||||||
.setOriginal(getOriginal())
|
|
||||||
.setJustForTypeSubstitution(true)
|
|
||||||
.setSubstitutingScopeProvider(substitutingScopeProvider)
|
|
||||||
.build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@@ -375,7 +365,6 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
|||||||
private Map<UserDataKey<?>, Object> userDataMap = new LinkedHashMap<UserDataKey<?>, Object>();
|
private Map<UserDataKey<?>, Object> userDataMap = new LinkedHashMap<UserDataKey<?>, Object>();
|
||||||
private Boolean newHasSynthesizedParameterNames = null;
|
private Boolean newHasSynthesizedParameterNames = null;
|
||||||
protected boolean justForTypeSubstitution = false;
|
protected boolean justForTypeSubstitution = false;
|
||||||
protected @NotNull SubstitutingScopeProvider substitutingScopeProvider;
|
|
||||||
|
|
||||||
public CopyConfiguration(
|
public CopyConfiguration(
|
||||||
@NotNull TypeSubstitution substitution,
|
@NotNull TypeSubstitution substitution,
|
||||||
@@ -397,7 +386,6 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
|||||||
this.newExtensionReceiverParameter = newExtensionReceiverParameter;
|
this.newExtensionReceiverParameter = newExtensionReceiverParameter;
|
||||||
this.newReturnType = newReturnType;
|
this.newReturnType = newReturnType;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
substitutingScopeProvider = SubstitutingScopeProvider.Companion.getDEFAULT();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -566,12 +554,6 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
|||||||
justForTypeSubstitution = value;
|
justForTypeSubstitution = value;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
public CopyConfiguration setSubstitutingScopeProvider(@NotNull SubstitutingScopeProvider substitutingScopeProvider) {
|
|
||||||
this.substitutingScopeProvider = substitutingScopeProvider;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -609,8 +591,7 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
|||||||
List<TypeParameterDescriptor> substitutedTypeParameters =
|
List<TypeParameterDescriptor> substitutedTypeParameters =
|
||||||
new ArrayList<TypeParameterDescriptor>(unsubstitutedTypeParameters.size());
|
new ArrayList<TypeParameterDescriptor>(unsubstitutedTypeParameters.size());
|
||||||
final TypeSubstitutor substitutor = DescriptorSubstitutor.substituteTypeParameters(
|
final TypeSubstitutor substitutor = DescriptorSubstitutor.substituteTypeParameters(
|
||||||
unsubstitutedTypeParameters, configuration.substitution, substitutedDescriptor, substitutedTypeParameters,
|
unsubstitutedTypeParameters, configuration.substitution, substitutedDescriptor, substitutedTypeParameters, wereChanges
|
||||||
wereChanges, configuration.substitutingScopeProvider
|
|
||||||
);
|
);
|
||||||
if (substitutor == null) return null;
|
if (substitutor == null) return null;
|
||||||
|
|
||||||
|
|||||||
+5
-7
@@ -28,12 +28,10 @@ public class LazySubstitutingClassDescriptor implements ClassDescriptor {
|
|||||||
private List<TypeParameterDescriptor> typeConstructorParameters;
|
private List<TypeParameterDescriptor> typeConstructorParameters;
|
||||||
private List<TypeParameterDescriptor> declaredTypeParameters;
|
private List<TypeParameterDescriptor> declaredTypeParameters;
|
||||||
private TypeConstructor typeConstructor;
|
private TypeConstructor typeConstructor;
|
||||||
private final SubstitutingScopeProvider substitutingScopeProvider;
|
|
||||||
|
|
||||||
public LazySubstitutingClassDescriptor(ClassDescriptor descriptor, TypeSubstitutor substitutor, SubstitutingScopeProvider substitutingScopeProvider) {
|
public LazySubstitutingClassDescriptor(ClassDescriptor descriptor, TypeSubstitutor substitutor) {
|
||||||
this.original = descriptor;
|
this.original = descriptor;
|
||||||
this.originalSubstitutor = substitutor;
|
this.originalSubstitutor = substitutor;
|
||||||
this.substitutingScopeProvider = substitutingScopeProvider;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private TypeSubstitutor getSubstitutor() {
|
private TypeSubstitutor getSubstitutor() {
|
||||||
@@ -89,7 +87,7 @@ public class LazySubstitutingClassDescriptor implements ClassDescriptor {
|
|||||||
if (originalSubstitutor.isEmpty()) {
|
if (originalSubstitutor.isEmpty()) {
|
||||||
return memberScope;
|
return memberScope;
|
||||||
}
|
}
|
||||||
return substitutingScopeProvider.createSubstitutingScope(memberScope, getSubstitutor());
|
return new SubstitutingScope(memberScope, getSubstitutor());
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -99,7 +97,7 @@ public class LazySubstitutingClassDescriptor implements ClassDescriptor {
|
|||||||
if (originalSubstitutor.isEmpty()) {
|
if (originalSubstitutor.isEmpty()) {
|
||||||
return memberScope;
|
return memberScope;
|
||||||
}
|
}
|
||||||
return substitutingScopeProvider.createSubstitutingScope(memberScope, getSubstitutor());
|
return new SubstitutingScope(memberScope, getSubstitutor());
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -109,7 +107,7 @@ public class LazySubstitutingClassDescriptor implements ClassDescriptor {
|
|||||||
if (originalSubstitutor.isEmpty()) {
|
if (originalSubstitutor.isEmpty()) {
|
||||||
return memberScope;
|
return memberScope;
|
||||||
}
|
}
|
||||||
return substitutingScopeProvider.createSubstitutingScope(memberScope, getSubstitutor());
|
return new SubstitutingScope(memberScope, getSubstitutor());
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -177,7 +175,7 @@ public class LazySubstitutingClassDescriptor implements ClassDescriptor {
|
|||||||
@Override
|
@Override
|
||||||
public ClassDescriptor substitute(@NotNull TypeSubstitutor substitutor) {
|
public ClassDescriptor substitute(@NotNull TypeSubstitutor substitutor) {
|
||||||
if (substitutor.isEmpty()) return this;
|
if (substitutor.isEmpty()) return this;
|
||||||
return new LazySubstitutingClassDescriptor(this, TypeSubstitutor.createChainedSubstitutor(substitutor.getSubstitution(), getSubstitutor().getSubstitution()), substitutingScopeProvider);
|
return new LazySubstitutingClassDescriptor(this, TypeSubstitutor.createChainedSubstitutor(substitutor.getSubstitution(), getSubstitutor().getSubstitution()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+3
-66
@@ -47,8 +47,6 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp
|
|||||||
private final boolean isExternal;
|
private final boolean isExternal;
|
||||||
private final boolean isDelegated;
|
private final boolean isDelegated;
|
||||||
|
|
||||||
private final SubstitutingScopeProvider substitutingScopeProvider;
|
|
||||||
|
|
||||||
private ReceiverParameterDescriptor dispatchReceiverParameter;
|
private ReceiverParameterDescriptor dispatchReceiverParameter;
|
||||||
private ReceiverParameterDescriptor extensionReceiverParameter;
|
private ReceiverParameterDescriptor extensionReceiverParameter;
|
||||||
private List<TypeParameterDescriptor> typeParameters;
|
private List<TypeParameterDescriptor> typeParameters;
|
||||||
@@ -74,28 +72,6 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp
|
|||||||
boolean isActual,
|
boolean isActual,
|
||||||
boolean isExternal,
|
boolean isExternal,
|
||||||
boolean isDelegated
|
boolean isDelegated
|
||||||
) {
|
|
||||||
this(containingDeclaration, original, annotations, modality, visibility, isVar, name, kind, source,
|
|
||||||
lateInit, isConst, isExpect, isActual, isExternal, isDelegated, SubstitutingScopeProvider.Companion.getDEFAULT());
|
|
||||||
}
|
|
||||||
|
|
||||||
protected PropertyDescriptorImpl(
|
|
||||||
@NotNull DeclarationDescriptor containingDeclaration,
|
|
||||||
@Nullable PropertyDescriptor original,
|
|
||||||
@NotNull Annotations annotations,
|
|
||||||
@NotNull Modality modality,
|
|
||||||
@NotNull Visibility visibility,
|
|
||||||
boolean isVar,
|
|
||||||
@NotNull Name name,
|
|
||||||
@NotNull Kind kind,
|
|
||||||
@NotNull SourceElement source,
|
|
||||||
boolean lateInit,
|
|
||||||
boolean isConst,
|
|
||||||
boolean isExpect,
|
|
||||||
boolean isActual,
|
|
||||||
boolean isExternal,
|
|
||||||
boolean isDelegated,
|
|
||||||
@NotNull SubstitutingScopeProvider substitutingScopeProvider
|
|
||||||
) {
|
) {
|
||||||
super(containingDeclaration, annotations, name, null, isVar, source);
|
super(containingDeclaration, annotations, name, null, isVar, source);
|
||||||
this.modality = modality;
|
this.modality = modality;
|
||||||
@@ -108,7 +84,6 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp
|
|||||||
this.isActual = isActual;
|
this.isActual = isActual;
|
||||||
this.isExternal = isExternal;
|
this.isExternal = isExternal;
|
||||||
this.isDelegated = isDelegated;
|
this.isDelegated = isDelegated;
|
||||||
this.substitutingScopeProvider = substitutingScopeProvider;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -127,39 +102,10 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp
|
|||||||
boolean isActual,
|
boolean isActual,
|
||||||
boolean isExternal,
|
boolean isExternal,
|
||||||
boolean isDelegated
|
boolean isDelegated
|
||||||
) {
|
|
||||||
return create(containingDeclaration, annotations, modality, visibility, isVar, name, kind, source,
|
|
||||||
lateInit, isConst, isExpect, isActual, isExternal, isDelegated, SubstitutingScopeProvider.Companion.getDEFAULT());
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
public static PropertyDescriptorImpl create(
|
|
||||||
@NotNull DeclarationDescriptor containingDeclaration,
|
|
||||||
@NotNull Annotations annotations,
|
|
||||||
@NotNull Modality modality,
|
|
||||||
@NotNull Visibility visibility,
|
|
||||||
boolean isVar,
|
|
||||||
@NotNull Name name,
|
|
||||||
@NotNull Kind kind,
|
|
||||||
@NotNull SourceElement source,
|
|
||||||
boolean lateInit,
|
|
||||||
boolean isConst,
|
|
||||||
boolean isExpect,
|
|
||||||
boolean isActual,
|
|
||||||
boolean isExternal,
|
|
||||||
boolean isDelegated,
|
|
||||||
@NotNull SubstitutingScopeProvider substitutingScopeProvider
|
|
||||||
) {
|
) {
|
||||||
return new PropertyDescriptorImpl(containingDeclaration, null, annotations,
|
return new PropertyDescriptorImpl(containingDeclaration, null, annotations,
|
||||||
modality, visibility, isVar, name, kind, source, lateInit, isConst,
|
modality, visibility, isVar, name, kind, source, lateInit, isConst,
|
||||||
isExpect, isActual, isExternal, isDelegated, substitutingScopeProvider);
|
isExpect, isActual, isExternal, isDelegated);
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
public PropertyDescriptorImpl getCopy() {
|
|
||||||
return new PropertyDescriptorImpl(getContainingDeclaration(), original, getAnnotations(),
|
|
||||||
modality, visibility, isVar(), getName(), kind, getSource(), lateInit, isConst,
|
|
||||||
isExpect, isActual, isExternal, isDelegated, substitutingScopeProvider);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setType(
|
public void setType(
|
||||||
@@ -312,7 +258,6 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp
|
|||||||
private ReceiverParameterDescriptor dispatchReceiverParameter = PropertyDescriptorImpl.this.dispatchReceiverParameter;
|
private ReceiverParameterDescriptor dispatchReceiverParameter = PropertyDescriptorImpl.this.dispatchReceiverParameter;
|
||||||
private List<TypeParameterDescriptor> newTypeParameters = null;
|
private List<TypeParameterDescriptor> newTypeParameters = null;
|
||||||
private Name name = getName();
|
private Name name = getName();
|
||||||
private boolean setterProjectedOut = PropertyDescriptorImpl.this.setterProjectedOut;
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
@@ -419,7 +364,6 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp
|
|||||||
TypeSubstitutor substitutor = DescriptorSubstitutor.substituteTypeParameters(
|
TypeSubstitutor substitutor = DescriptorSubstitutor.substituteTypeParameters(
|
||||||
originalTypeParameters, copyConfiguration.substitution, substitutedDescriptor, substitutedTypeParameters
|
originalTypeParameters, copyConfiguration.substitution, substitutedDescriptor, substitutedTypeParameters
|
||||||
);
|
);
|
||||||
substitutor.setSubstitutingScopeProvider(substitutingScopeProvider);
|
|
||||||
|
|
||||||
KotlinType originalOutType = getType();
|
KotlinType originalOutType = getType();
|
||||||
KotlinType outType = substitutor.substitute(originalOutType, Variance.OUT_VARIANCE);
|
KotlinType outType = substitutor.substitute(originalOutType, Variance.OUT_VARIANCE);
|
||||||
@@ -516,8 +460,6 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp
|
|||||||
substitutedDescriptor.setCompileTimeInitializer(compileTimeInitializer);
|
substitutedDescriptor.setCompileTimeInitializer(compileTimeInitializer);
|
||||||
}
|
}
|
||||||
|
|
||||||
substitutedDescriptor.setterProjectedOut = copyConfiguration.setterProjectedOut;
|
|
||||||
|
|
||||||
return substitutedDescriptor;
|
return substitutedDescriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -528,7 +470,7 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp
|
|||||||
return prev;
|
return prev;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FunctionDescriptor getSubstitutedInitialSignatureDescriptor(
|
private static FunctionDescriptor getSubstitutedInitialSignatureDescriptor(
|
||||||
@NotNull TypeSubstitutor substitutor,
|
@NotNull TypeSubstitutor substitutor,
|
||||||
@NotNull PropertyAccessorDescriptor accessorDescriptor
|
@NotNull PropertyAccessorDescriptor accessorDescriptor
|
||||||
) {
|
) {
|
||||||
@@ -548,7 +490,7 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp
|
|||||||
) {
|
) {
|
||||||
return new PropertyDescriptorImpl(
|
return new PropertyDescriptorImpl(
|
||||||
newOwner, original, getAnnotations(), newModality, newVisibility, isVar(), newName, kind, SourceElement.NO_SOURCE,
|
newOwner, original, getAnnotations(), newModality, newVisibility, isVar(), newName, kind, SourceElement.NO_SOURCE,
|
||||||
isLateInit(), isConst(), isExpect(), isActual(), isExternal(), isDelegated(), substitutingScopeProvider
|
isLateInit(), isConst(), isExpect(), isActual(), isExternal(), isDelegated()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -622,9 +564,4 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp
|
|||||||
public <V> V getUserData(UserDataKey<V> key) {
|
public <V> V getUserData(UserDataKey<V> key) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
public SubstitutingScopeProvider getSubstitutingScopeProvider() {
|
|
||||||
return substitutingScopeProvider;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -21,7 +21,6 @@ import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
|||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
import org.jetbrains.kotlin.types.TypeSubstitutor
|
import org.jetbrains.kotlin.types.TypeSubstitutor
|
||||||
import org.jetbrains.kotlin.types.Variance
|
|
||||||
import org.jetbrains.kotlin.utils.join
|
import org.jetbrains.kotlin.utils.join
|
||||||
|
|
||||||
open class ValueParameterDescriptorImpl(
|
open class ValueParameterDescriptorImpl(
|
||||||
@@ -103,7 +102,8 @@ open class ValueParameterDescriptorImpl(
|
|||||||
override fun getOriginal() = if (original === this) this else original.original
|
override fun getOriginal() = if (original === this) this else original.original
|
||||||
|
|
||||||
override fun substitute(substitutor: TypeSubstitutor): ValueParameterDescriptor {
|
override fun substitute(substitutor: TypeSubstitutor): ValueParameterDescriptor {
|
||||||
return this
|
if (substitutor.isEmpty) return this
|
||||||
|
throw UnsupportedOperationException() // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun <R, D> accept(visitor: DeclarationDescriptorVisitor<R, D>, data: D): R {
|
override fun <R, D> accept(visitor: DeclarationDescriptorVisitor<R, D>, data: D): R {
|
||||||
|
|||||||
+5
-20
@@ -100,25 +100,16 @@ class CapturedType(
|
|||||||
CapturedType(typeProjection, constructor, isMarkedNullable, newAnnotations)
|
CapturedType(typeProjection, constructor, isMarkedNullable, newAnnotations)
|
||||||
}
|
}
|
||||||
|
|
||||||
object OldCapturedTypeCreator : CapturedTypeCreator {
|
|
||||||
override fun createCapturedType(typeProjection: TypeProjection): TypeProjection {
|
|
||||||
return TypeProjectionImpl(CapturedType(typeProjection))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun createCapturedType(typeProjection: TypeProjection): KotlinType = CapturedType(typeProjection)
|
fun createCapturedType(typeProjection: TypeProjection): KotlinType = CapturedType(typeProjection)
|
||||||
|
|
||||||
fun KotlinType.isCaptured(): Boolean = constructor is CapturedTypeConstructor
|
fun KotlinType.isCaptured(): Boolean = constructor is CapturedTypeConstructor
|
||||||
|
|
||||||
fun TypeSubstitution.wrapWithCapturingSubstitution(
|
fun TypeSubstitution.wrapWithCapturingSubstitution(needApproximation: Boolean = true): TypeSubstitution =
|
||||||
capturedTypeCreator: CapturedTypeCreator = OldCapturedTypeCreator,
|
|
||||||
needApproximation: Boolean = true
|
|
||||||
): TypeSubstitution =
|
|
||||||
if (this is IndexedParametersSubstitution)
|
if (this is IndexedParametersSubstitution)
|
||||||
IndexedParametersSubstitution(
|
IndexedParametersSubstitution(
|
||||||
this.parameters,
|
this.parameters,
|
||||||
this.arguments.zip(this.parameters).map {
|
this.arguments.zip(this.parameters).map {
|
||||||
it.first.createCapturedIfNeeded(it.second, capturedTypeCreator)
|
it.first.createCapturedIfNeeded(it.second)
|
||||||
}.toTypedArray(),
|
}.toTypedArray(),
|
||||||
approximateCapturedTypes = needApproximation
|
approximateCapturedTypes = needApproximation
|
||||||
)
|
)
|
||||||
@@ -126,16 +117,10 @@ fun TypeSubstitution.wrapWithCapturingSubstitution(
|
|||||||
object : DelegatedTypeSubstitution(this@wrapWithCapturingSubstitution) {
|
object : DelegatedTypeSubstitution(this@wrapWithCapturingSubstitution) {
|
||||||
override fun approximateContravariantCapturedTypes() = needApproximation
|
override fun approximateContravariantCapturedTypes() = needApproximation
|
||||||
override fun get(key: KotlinType) =
|
override fun get(key: KotlinType) =
|
||||||
super.get(key)?.createCapturedIfNeeded(
|
super.get(key)?.createCapturedIfNeeded(key.constructor.declarationDescriptor as? TypeParameterDescriptor)
|
||||||
key.constructor.declarationDescriptor as? TypeParameterDescriptor,
|
|
||||||
capturedTypeCreator
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun TypeProjection.createCapturedIfNeeded(
|
private fun TypeProjection.createCapturedIfNeeded(typeParameterDescriptor: TypeParameterDescriptor?): TypeProjection {
|
||||||
typeParameterDescriptor: TypeParameterDescriptor?,
|
|
||||||
capturedTypeCreator: CapturedTypeCreator
|
|
||||||
): TypeProjection {
|
|
||||||
if (typeParameterDescriptor == null || projectionKind == Variance.INVARIANT) return this
|
if (typeParameterDescriptor == null || projectionKind == Variance.INVARIANT) return this
|
||||||
|
|
||||||
// Treat consistent projections as invariant
|
// Treat consistent projections as invariant
|
||||||
@@ -149,5 +134,5 @@ private fun TypeProjection.createCapturedIfNeeded(
|
|||||||
TypeProjectionImpl(this@createCapturedIfNeeded.type)
|
TypeProjectionImpl(this@createCapturedIfNeeded.type)
|
||||||
}
|
}
|
||||||
|
|
||||||
return capturedTypeCreator.createCapturedType(this)
|
return TypeProjectionImpl(createCapturedType(this))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,24 +18,18 @@ package org.jetbrains.kotlin.resolve.scopes
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.Substitutable
|
import org.jetbrains.kotlin.descriptors.Substitutable
|
||||||
import org.jetbrains.kotlin.descriptors.impl.FunctionDescriptorImpl
|
|
||||||
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.wrapWithCapturingSubstitution
|
import org.jetbrains.kotlin.resolve.calls.inference.wrapWithCapturingSubstitution
|
||||||
import org.jetbrains.kotlin.types.ErrorUtils
|
|
||||||
import org.jetbrains.kotlin.types.SubstitutingScopeProvider
|
|
||||||
import org.jetbrains.kotlin.types.TypeSubstitutor
|
import org.jetbrains.kotlin.types.TypeSubstitutor
|
||||||
import org.jetbrains.kotlin.utils.Printer
|
import org.jetbrains.kotlin.utils.Printer
|
||||||
import org.jetbrains.kotlin.utils.newLinkedHashSetWithExpectedSize
|
import org.jetbrains.kotlin.utils.newLinkedHashSetWithExpectedSize
|
||||||
import org.jetbrains.kotlin.utils.sure
|
import org.jetbrains.kotlin.utils.sure
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class SubstitutingScope(private val workerScope: MemberScope, givenSubstitutor: TypeSubstitutor, private val substitutingScopeProvider: SubstitutingScopeProvider) : MemberScope {
|
class SubstitutingScope(private val workerScope: MemberScope, givenSubstitutor: TypeSubstitutor) : MemberScope {
|
||||||
|
|
||||||
private val substitutor: TypeSubstitutor = givenSubstitutor.substitution
|
private val substitutor = givenSubstitutor.substitution.wrapWithCapturingSubstitution().buildSubstitutor()
|
||||||
.wrapWithCapturingSubstitution(capturedTypeCreator = substitutingScopeProvider.provideCapturedTypeCreator())
|
|
||||||
.buildSubstitutor().also { it.setSubstitutingScopeProvider(substitutingScopeProvider) }
|
|
||||||
|
|
||||||
private var substitutedDescriptors: MutableMap<DeclarationDescriptor, DeclarationDescriptor>? = null
|
private var substitutedDescriptors: MutableMap<DeclarationDescriptor, DeclarationDescriptor>? = null
|
||||||
|
|
||||||
@@ -49,44 +43,11 @@ class SubstitutingScope(private val workerScope: MemberScope, givenSubstitutor:
|
|||||||
}
|
}
|
||||||
|
|
||||||
val substituted = substitutedDescriptors!!.getOrPut(descriptor) {
|
val substituted = substitutedDescriptors!!.getOrPut(descriptor) {
|
||||||
val assertionMessage = {
|
|
||||||
"We expect that no conflict should happen while substitution is guaranteed to generate invariant projection, " +
|
|
||||||
"but $descriptor substitution fails"
|
|
||||||
}
|
|
||||||
when (descriptor) {
|
when (descriptor) {
|
||||||
/*
|
is Substitutable<*> -> descriptor.substitute(substitutor).sure {
|
||||||
* Here we can take null if NI enabled, because inside this place we have OI and NI collide. See following example:
|
"We expect that no conflict should happen while substitution is guaranteed to generate invariant projection, " +
|
||||||
*
|
"but $descriptor substitution fails"
|
||||||
* class Out<out T>
|
|
||||||
*
|
|
||||||
* class A<T> {
|
|
||||||
* fun T.foo() {}
|
|
||||||
* fun Out<T>.bar() {}
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* fun test(x: A<out CharSequence>, y: Out<CharSequence>) {
|
|
||||||
* with(x) {
|
|
||||||
* "".foo() <-- problem is here
|
|
||||||
* }
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* Because of we don't capture type projections, in call "".foo() we have `out CharSequence` as substituted type `T`
|
|
||||||
* (instead of `CapturedType(out CharSequence)`, and `in String` as type from receiver, so we have type variance error
|
|
||||||
* and can not substitute descriptor.
|
|
||||||
*
|
|
||||||
* So, fix of it is hack
|
|
||||||
*/
|
|
||||||
is FunctionDescriptorImpl -> {
|
|
||||||
val substitutedDescriptor = descriptor.substitute(substitutor, substitutingScopeProvider)
|
|
||||||
if (substitutingScopeProvider.isNewInferenceEnabled) {
|
|
||||||
substitutedDescriptor ?: ErrorUtils.createErrorScope("Cannot substitute functional descriptor")
|
|
||||||
.getContributedFunctions(descriptor.name, NoLookupLocation.WHEN_RESOLVE_DECLARATION).first()
|
|
||||||
} else {
|
|
||||||
substitutedDescriptor.sure(assertionMessage)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
is Substitutable<*> -> descriptor.substitute(substitutor).sure(assertionMessage)
|
|
||||||
else -> error("Unknown descriptor in scope: $descriptor")
|
else -> error("Unknown descriptor in scope: $descriptor")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -111,7 +72,7 @@ class SubstitutingScope(private val workerScope: MemberScope, givenSubstitutor:
|
|||||||
override fun getContributedVariables(name: Name, location: LookupLocation) = substitute(workerScope.getContributedVariables(name, location))
|
override fun getContributedVariables(name: Name, location: LookupLocation) = substitute(workerScope.getContributedVariables(name, location))
|
||||||
|
|
||||||
override fun getContributedClassifier(name: Name, location: LookupLocation) =
|
override fun getContributedClassifier(name: Name, location: LookupLocation) =
|
||||||
workerScope.getContributedClassifier(name, location)?.let { substitute(it) }
|
workerScope.getContributedClassifier(name, location)?.let { substitute(it) }
|
||||||
|
|
||||||
override fun getContributedFunctions(name: Name, location: LookupLocation) = substitute(workerScope.getContributedFunctions(name, location))
|
override fun getContributedFunctions(name: Name, location: LookupLocation) = substitute(workerScope.getContributedFunctions(name, location))
|
||||||
|
|
||||||
|
|||||||
@@ -28,12 +28,6 @@ import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
|||||||
import org.jetbrains.kotlin.types.typeUtil.builtIns
|
import org.jetbrains.kotlin.types.typeUtil.builtIns
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class OldCaptureTypeApproximator : CapturedTypeApproximator {
|
|
||||||
override fun approximateCapturedTypes(typeProjection: TypeProjection?, approximateContravariant: Boolean): TypeProjection? {
|
|
||||||
return approximateCapturedTypesIfNecessary(typeProjection, approximateContravariant)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
data class ApproximationBounds<out T>(
|
data class ApproximationBounds<out T>(
|
||||||
val lower: T,
|
val lower: T,
|
||||||
val upper: T
|
val upper: T
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public class DescriptorSubstitutor {
|
|||||||
@NotNull DeclarationDescriptor newContainingDeclaration,
|
@NotNull DeclarationDescriptor newContainingDeclaration,
|
||||||
@NotNull @Mutable List<TypeParameterDescriptor> result
|
@NotNull @Mutable List<TypeParameterDescriptor> result
|
||||||
) {
|
) {
|
||||||
TypeSubstitutor substitutor = substituteTypeParameters(typeParameters, originalSubstitution, newContainingDeclaration, result, null, SubstitutingScopeProvider.Companion.getDEFAULT());
|
TypeSubstitutor substitutor = substituteTypeParameters(typeParameters, originalSubstitution, newContainingDeclaration, result, null);
|
||||||
if (substitutor == null) throw new AssertionError("Substitution failed");
|
if (substitutor == null) throw new AssertionError("Substitution failed");
|
||||||
return substitutor;
|
return substitutor;
|
||||||
}
|
}
|
||||||
@@ -51,8 +51,7 @@ public class DescriptorSubstitutor {
|
|||||||
@NotNull TypeSubstitution originalSubstitution,
|
@NotNull TypeSubstitution originalSubstitution,
|
||||||
@NotNull DeclarationDescriptor newContainingDeclaration,
|
@NotNull DeclarationDescriptor newContainingDeclaration,
|
||||||
@NotNull @Mutable List<TypeParameterDescriptor> result,
|
@NotNull @Mutable List<TypeParameterDescriptor> result,
|
||||||
@Nullable boolean[] wereChanges,
|
@Nullable boolean[] wereChanges
|
||||||
@NotNull SubstitutingScopeProvider substitutingScopeProvider
|
|
||||||
) {
|
) {
|
||||||
Map<TypeConstructor, TypeProjection> mutableSubstitution = new HashMap<TypeConstructor, TypeProjection>();
|
Map<TypeConstructor, TypeProjection> mutableSubstitution = new HashMap<TypeConstructor, TypeProjection>();
|
||||||
|
|
||||||
@@ -77,7 +76,7 @@ public class DescriptorSubstitutor {
|
|||||||
|
|
||||||
TypeSubstitutor substitutor = TypeSubstitutor.createChainedSubstitutor(
|
TypeSubstitutor substitutor = TypeSubstitutor.createChainedSubstitutor(
|
||||||
originalSubstitution, TypeConstructorSubstitution.createByConstructorsMap(mutableSubstitution)
|
originalSubstitution, TypeConstructorSubstitution.createByConstructorsMap(mutableSubstitution)
|
||||||
).setSubstitutingScopeProvider(substitutingScopeProvider);
|
);
|
||||||
|
|
||||||
for (TypeParameterDescriptor descriptor : typeParameters) {
|
for (TypeParameterDescriptor descriptor : typeParameters) {
|
||||||
TypeParameterDescriptorImpl substituted = substitutedMap.get(descriptor);
|
TypeParameterDescriptorImpl substituted = substitutedMap.get(descriptor);
|
||||||
|
|||||||
@@ -1,47 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2019 JetBrains s.r.o. 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.OldCapturedTypeCreator
|
|
||||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
|
||||||
import org.jetbrains.kotlin.resolve.scopes.SubstitutingScope
|
|
||||||
import org.jetbrains.kotlin.types.typesApproximation.OldCaptureTypeApproximator
|
|
||||||
|
|
||||||
interface SubstitutingScopeProvider {
|
|
||||||
fun createSubstitutingScope(workerScope: MemberScope, givenSubstitutor: TypeSubstitutor): SubstitutingScope
|
|
||||||
|
|
||||||
fun provideCapturedTypeCreator(): CapturedTypeCreator
|
|
||||||
|
|
||||||
fun provideApproximator(): CapturedTypeApproximator
|
|
||||||
|
|
||||||
val isNewInferenceEnabled: Boolean
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
val DEFAULT: SubstitutingScopeProvider = object : SubstitutingScopeProvider {
|
|
||||||
override fun createSubstitutingScope(workerScope: MemberScope, givenSubstitutor: TypeSubstitutor): SubstitutingScope {
|
|
||||||
return SubstitutingScope(workerScope, givenSubstitutor, this)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun provideCapturedTypeCreator(): CapturedTypeCreator {
|
|
||||||
return OldCapturedTypeCreator
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun provideApproximator(): CapturedTypeApproximator {
|
|
||||||
return OldCaptureTypeApproximator()
|
|
||||||
}
|
|
||||||
|
|
||||||
override val isNewInferenceEnabled: Boolean get() = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
interface CapturedTypeCreator {
|
|
||||||
fun createCapturedType(typeProjection: TypeProjection): TypeProjection
|
|
||||||
}
|
|
||||||
|
|
||||||
interface CapturedTypeApproximator {
|
|
||||||
fun approximateCapturedTypes(typeProjection: TypeProjection?, approximateContravariant: Boolean): TypeProjection?
|
|
||||||
}
|
|
||||||
@@ -28,6 +28,7 @@ import org.jetbrains.kotlin.name.FqName;
|
|||||||
import org.jetbrains.kotlin.resolve.calls.inference.CapturedTypeConstructorKt;
|
import org.jetbrains.kotlin.resolve.calls.inference.CapturedTypeConstructorKt;
|
||||||
import org.jetbrains.kotlin.types.model.TypeSubstitutorMarker;
|
import org.jetbrains.kotlin.types.model.TypeSubstitutorMarker;
|
||||||
import org.jetbrains.kotlin.types.typeUtil.TypeUtilsKt;
|
import org.jetbrains.kotlin.types.typeUtil.TypeUtilsKt;
|
||||||
|
import org.jetbrains.kotlin.types.typesApproximation.CapturedTypeApproximationKt;
|
||||||
import org.jetbrains.kotlin.utils.ExceptionUtilsKt;
|
import org.jetbrains.kotlin.utils.ExceptionUtilsKt;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -46,14 +47,6 @@ public class TypeSubstitutor implements TypeSubstitutorMarker {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private @NotNull SubstitutingScopeProvider substitutingScopeProvider;
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
public TypeSubstitutor setSubstitutingScopeProvider(@NotNull SubstitutingScopeProvider substitutingScopeProvider) {
|
|
||||||
this.substitutingScopeProvider = substitutingScopeProvider;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static TypeSubstitutor create(@NotNull TypeSubstitution substitution) {
|
public static TypeSubstitutor create(@NotNull TypeSubstitution substitution) {
|
||||||
return new TypeSubstitutor(substitution);
|
return new TypeSubstitutor(substitution);
|
||||||
@@ -80,7 +73,6 @@ public class TypeSubstitutor implements TypeSubstitutorMarker {
|
|||||||
|
|
||||||
protected TypeSubstitutor(@NotNull TypeSubstitution substitution) {
|
protected TypeSubstitutor(@NotNull TypeSubstitution substitution) {
|
||||||
this.substitution = substitution;
|
this.substitution = substitution;
|
||||||
this.substitutingScopeProvider = SubstitutingScopeProvider.Companion.getDEFAULT();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEmpty() {
|
public boolean isEmpty() {
|
||||||
@@ -118,12 +110,8 @@ public class TypeSubstitutor implements TypeSubstitutorMarker {
|
|||||||
if (!substitution.approximateCapturedTypes() && !substitution.approximateContravariantCapturedTypes()) {
|
if (!substitution.approximateCapturedTypes() && !substitution.approximateContravariantCapturedTypes()) {
|
||||||
return substitutedTypeProjection;
|
return substitutedTypeProjection;
|
||||||
}
|
}
|
||||||
|
return CapturedTypeApproximationKt.approximateCapturedTypesIfNecessary(
|
||||||
CapturedTypeApproximator approximator = substitutingScopeProvider.provideApproximator();
|
substitutedTypeProjection, substitution.approximateContravariantCapturedTypes());
|
||||||
return approximator.approximateCapturedTypes(
|
|
||||||
substitutedTypeProjection,
|
|
||||||
substitution.approximateContravariantCapturedTypes()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|||||||
@@ -55,11 +55,6 @@ public class TypeUtils {
|
|||||||
throw new IllegalStateException(name);
|
throw new IllegalStateException(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isMarkedNullable() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
|||||||
@@ -521,10 +521,6 @@ internal fun UnwrappedType.typeDepthInternal() =
|
|||||||
internal fun SimpleType.typeDepthInternal(): Int {
|
internal fun SimpleType.typeDepthInternal(): Int {
|
||||||
if (this is TypeUtils.SpecialType) return 0
|
if (this is TypeUtils.SpecialType) return 0
|
||||||
|
|
||||||
if (this is NewCapturedType) {
|
|
||||||
return constructor.projection.type.unwrap().typeDepthInternal()
|
|
||||||
}
|
|
||||||
|
|
||||||
val maxInArguments = arguments.asSequence().map {
|
val maxInArguments = arguments.asSequence().map {
|
||||||
if (it.isStarProjection) 1 else it.type.unwrap().typeDepthInternal()
|
if (it.isStarProjection) 1 else it.type.unwrap().typeDepthInternal()
|
||||||
}.max() ?: 0
|
}.max() ?: 0
|
||||||
|
|||||||
+5
-2
@@ -72,7 +72,10 @@ import org.jetbrains.kotlin.resolve.lazy.declarations.FileBasedDeclarationProvid
|
|||||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
|
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
|
||||||
import org.jetbrains.kotlin.storage.LockBasedStorageManager
|
import org.jetbrains.kotlin.storage.LockBasedStorageManager
|
||||||
import org.jetbrains.kotlin.storage.StorageManager
|
import org.jetbrains.kotlin.storage.StorageManager
|
||||||
import org.jetbrains.kotlin.types.*
|
import org.jetbrains.kotlin.types.ErrorUtils
|
||||||
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
|
import org.jetbrains.kotlin.types.TypeUtils
|
||||||
|
import org.jetbrains.kotlin.types.WrappedTypeFactory
|
||||||
import org.jetbrains.kotlin.utils.sure
|
import org.jetbrains.kotlin.utils.sure
|
||||||
|
|
||||||
|
|
||||||
@@ -331,7 +334,7 @@ internal object IDELightClassContexts {
|
|||||||
})
|
})
|
||||||
|
|
||||||
IdeaEnvironment.configure(this)
|
IdeaEnvironment.configure(this)
|
||||||
useImpl<SubstitutingScopeProviderImpl>()
|
|
||||||
useImpl<ResolveSession>()
|
useImpl<ResolveSession>()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ import org.jetbrains.kotlin.platform.js.JsPlatforms
|
|||||||
import org.jetbrains.kotlin.resolve.*
|
import org.jetbrains.kotlin.resolve.*
|
||||||
import org.jetbrains.kotlin.resolve.lazy.KotlinCodeAnalyzer
|
import org.jetbrains.kotlin.resolve.lazy.KotlinCodeAnalyzer
|
||||||
import org.jetbrains.kotlin.resolve.lazy.declarations.DeclarationProviderFactory
|
import org.jetbrains.kotlin.resolve.lazy.declarations.DeclarationProviderFactory
|
||||||
import org.jetbrains.kotlin.types.SubstitutingScopeProviderImpl
|
|
||||||
|
|
||||||
fun createTopDownAnalyzerForJs(
|
fun createTopDownAnalyzerForJs(
|
||||||
moduleContext: ModuleContext,
|
moduleContext: ModuleContext,
|
||||||
@@ -56,7 +55,6 @@ fun createTopDownAnalyzerForJs(
|
|||||||
|
|
||||||
configureIncrementalCompilation(lookupTracker, expectActualTracker)
|
configureIncrementalCompilation(lookupTracker, expectActualTracker)
|
||||||
configureStandardResolveComponents()
|
configureStandardResolveComponents()
|
||||||
useImpl<SubstitutingScopeProviderImpl>()
|
|
||||||
|
|
||||||
useInstance(declarationProviderFactory)
|
useInstance(declarationProviderFactory)
|
||||||
CompilerEnvironment.configure(this)
|
CompilerEnvironment.configure(this)
|
||||||
|
|||||||
Reference in New Issue
Block a user