diff --git a/compiler/testData/diagnostics/tests/j+k/recursiveRawUpperBound.txt b/compiler/testData/diagnostics/tests/j+k/recursiveRawUpperBound.txt index 29312aec310..4952e3db58d 100644 --- a/compiler/testData/diagnostics/tests/j+k/recursiveRawUpperBound.txt +++ b/compiler/testData/diagnostics/tests/j+k/recursiveRawUpperBound.txt @@ -1,6 +1,6 @@ package -internal fun foo(/*0*/ p: X): (Bad<(Bad!>..Bad!>?)>..Bad!>..Bad!>?)>?) +internal fun foo(/*0*/ p: X): (Bad!>..Bad!>?) public/*package*/ open class Bad>..Bad>?)> { public/*package*/ constructor Bad>..Bad>?)>() @@ -12,7 +12,7 @@ public/*package*/ open class Bad>..Bad>?)> { public/*package*/ open class X { public/*package*/ constructor X() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public/*package*/ open fun foo(): (Bad<(Bad!>..Bad!>?)>..Bad!>..Bad!>?)>?) + public/*package*/ open fun foo(): (Bad!>..Bad!>?) public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } diff --git a/compiler/testData/diagnostics/tests/platformTypes/rawTypes/nonTrivialErasure.txt b/compiler/testData/diagnostics/tests/platformTypes/rawTypes/nonTrivialErasure.txt index c29fa568548..b1711738ef0 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/rawTypes/nonTrivialErasure.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/rawTypes/nonTrivialErasure.txt @@ -30,5 +30,5 @@ public/*package*/ open class Test { } // Static members - public/*package*/ final var rawAField: (A<(A!, A<*, *, *>!, kotlin.(Mutable)List<*>!>..A!, out A<*, *, *>!, out kotlin.(Mutable)List<*>!>?), (A!, A<*, *, *>!, kotlin.(Mutable)List<*>!>..A!, out A<*, *, *>!, out kotlin.(Mutable)List<*>!>?), (kotlin.MutableList..kotlin.List<*>?)>..A!, A<*, *, *>!, kotlin.(Mutable)List<*>!>..A!, out A<*, *, *>!, out kotlin.(Mutable)List<*>!>?), out (A!, A<*, *, *>!, kotlin.(Mutable)List<*>!>..A!, out A<*, *, *>!, out kotlin.(Mutable)List<*>!>?), out (kotlin.MutableList..kotlin.List<*>?)>?) + public/*package*/ final var rawAField: (A!, A<*, *, *>!, kotlin.(Mutable)List<*>!>..A!, out A<*, *, *>!, out kotlin.(Mutable)List<*>!>?) } diff --git a/compiler/testData/diagnostics/tests/platformTypes/rawTypes/rawTypeInUpperBound.txt b/compiler/testData/diagnostics/tests/platformTypes/rawTypes/rawTypeInUpperBound.txt index ede9115b0eb..dfe8381d5df 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/rawTypes/rawTypeInUpperBound.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/rawTypes/rawTypeInUpperBound.txt @@ -28,5 +28,5 @@ public open class Test { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String // Static members - public/*package*/ final var rawB: (B<(A..A<*>?)>..B..A<*>?)>?) + public/*package*/ final var rawB: (B!>..B!>?) } diff --git a/compiler/testData/diagnostics/tests/platformTypes/rawTypes/rawWithInProjection.txt b/compiler/testData/diagnostics/tests/platformTypes/rawTypes/rawWithInProjection.txt index 717ef620710..514ffc5d1b0 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/rawTypes/rawWithInProjection.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/rawTypes/rawWithInProjection.txt @@ -9,5 +9,5 @@ public/*package*/ open class Test { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String // Static members - public/*package*/ open fun foo(/*0*/ x: (kotlin.Comparable..kotlin.Comparable?)): kotlin.Unit + public/*package*/ open fun foo(/*0*/ x: (kotlin.Comparable..kotlin.Comparable?)): kotlin.Unit } diff --git a/compiler/testData/diagnostics/tests/platformTypes/rawTypes/starProjectionToRaw.txt b/compiler/testData/diagnostics/tests/platformTypes/rawTypes/starProjectionToRaw.txt index 9bad5424952..5e8cf3df940 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/rawTypes/starProjectionToRaw.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/rawTypes/starProjectionToRaw.txt @@ -23,5 +23,5 @@ public/*package*/ open class Test { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String // Static members - public/*package*/ open fun foo(/*0*/ x: (B<(A..A<*>?)>..B..A<*>?)>?)): kotlin.Unit + public/*package*/ open fun foo(/*0*/ x: (B!>..B!>?)): kotlin.Unit } diff --git a/compiler/testData/loadJava/compiledJava/signaturePropagation/RawSuperTypeWithRecursiveBound.txt b/compiler/testData/loadJava/compiledJava/signaturePropagation/RawSuperTypeWithRecursiveBound.txt index 7422aabbe1c..ec049a63a2a 100644 --- a/compiler/testData/loadJava/compiledJava/signaturePropagation/RawSuperTypeWithRecursiveBound.txt +++ b/compiler/testData/loadJava/compiledJava/signaturePropagation/RawSuperTypeWithRecursiveBound.txt @@ -6,7 +6,7 @@ public open class RawSuperTypeWithRecursiveBound { public open inner class Derived : test.RawSuperTypeWithRecursiveBound.Super!> { public constructor Derived() public open override /*1*/ fun dummy(): kotlin.Unit - public open override /*1*/ fun foo(/*0*/ p0: (test.RawSuperTypeWithRecursiveBound.Super<(test.RawSuperTypeWithRecursiveBound.Super!>..test.RawSuperTypeWithRecursiveBound.Super!>?)>..test.RawSuperTypeWithRecursiveBound.Super!>..test.RawSuperTypeWithRecursiveBound.Super!>?)>?)): kotlin.Unit + public open override /*1*/ fun foo(/*0*/ p0: (test.RawSuperTypeWithRecursiveBound.Super!>..test.RawSuperTypeWithRecursiveBound.Super!>?)): kotlin.Unit public open fun foo(/*0*/ p0: kotlin.Any!): kotlin.Unit } diff --git a/compiler/testData/loadJava/compiledJava/signaturePropagation/RawSuperTypeWithRecursiveBoundMultipleParameters.txt b/compiler/testData/loadJava/compiledJava/signaturePropagation/RawSuperTypeWithRecursiveBoundMultipleParameters.txt index 9f20e6321ea..6abec577b92 100644 --- a/compiler/testData/loadJava/compiledJava/signaturePropagation/RawSuperTypeWithRecursiveBoundMultipleParameters.txt +++ b/compiler/testData/loadJava/compiledJava/signaturePropagation/RawSuperTypeWithRecursiveBoundMultipleParameters.txt @@ -6,7 +6,7 @@ public open class RawSuperTypeWithRecursiveBoundMultipleParameters { public open inner class Derived : test.RawSuperTypeWithRecursiveBoundMultipleParameters.Super!> { public constructor Derived() public open override /*1*/ fun dummy(): kotlin.Unit - public open override /*1*/ fun foo(/*0*/ p0: kotlin.Any!, /*1*/ p1: (test.RawSuperTypeWithRecursiveBoundMultipleParameters.Super!>..test.RawSuperTypeWithRecursiveBoundMultipleParameters.Super<*, out test.RawSuperTypeWithRecursiveBoundMultipleParameters.Super<*, *>!>?)>..test.RawSuperTypeWithRecursiveBoundMultipleParameters.Super<*, out (test.RawSuperTypeWithRecursiveBoundMultipleParameters.Super!>..test.RawSuperTypeWithRecursiveBoundMultipleParameters.Super<*, out test.RawSuperTypeWithRecursiveBoundMultipleParameters.Super<*, *>!>?)>?)): kotlin.Unit + public open override /*1*/ fun foo(/*0*/ p0: kotlin.Any!, /*1*/ p1: (test.RawSuperTypeWithRecursiveBoundMultipleParameters.Super!>..test.RawSuperTypeWithRecursiveBoundMultipleParameters.Super<*, out test.RawSuperTypeWithRecursiveBoundMultipleParameters.Super<*, *>!>?)): kotlin.Unit public open fun foo(/*0*/ p0: kotlin.Any!, /*1*/ p1: kotlin.Any!): kotlin.Unit } diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/typeEnhancement.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/typeEnhancement.kt index 7561c2f74ad..2c426fd2844 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/typeEnhancement.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/typeEnhancement.kt @@ -98,7 +98,7 @@ private fun JetType.enhanceInflexible(qualifiers: (Int) -> JavaTypeQualifiers, i enhancedNullabilityAnnotations ).filterNotNull().compositeAnnotationsOrSingle() - val (newSubstitution, substitutedEnhancedArgs) = computeNewSubstitutionAndArguments( + val newSubstitution = computeNewSubstitution( typeConstructor.parameters, enhancedArguments ) @@ -106,7 +106,7 @@ private fun JetType.enhanceInflexible(qualifiers: (Int) -> JavaTypeQualifiers, i newAnnotations, typeConstructor, enhancedNullability, - substitutedEnhancedArgs, + enhancedArguments, newSubstitution, if (enhancedClassifier is ClassDescriptor) enhancedClassifier.getMemberScope(newSubstitution) diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/TypeSubstitution.kt b/core/descriptors/src/org/jetbrains/kotlin/types/TypeSubstitution.kt index cb030ffb999..1bb0d52bac1 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/TypeSubstitution.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/TypeSubstitution.kt @@ -91,25 +91,23 @@ public class IndexedParametersSubstitution( } } -public fun JetType.computeNewSubstitutionAndArguments( +public fun JetType.computeNewSubstitution( newParameters: List, newArguments: List -): Pair> { +): TypeSubstitution { val previousSubstitution = getSubstitution() - if (newArguments.isEmpty()) return Pair(previousSubstitution, emptyList()) + if (newArguments.isEmpty()) return previousSubstitution val newIndexedSubstitution = IndexedParametersSubstitution(newParameters, newArguments) // If previous substitution was trivial just replace it with indexed one if (previousSubstitution is IndexedParametersSubstitution || previousSubstitution.isEmpty()) { - return Pair(newIndexedSubstitution, newArguments) + return newIndexedSubstitution } val composedSubstitution = CompositeTypeSubstitution(newIndexedSubstitution, previousSubstitution) - val newSubstitutor = composedSubstitution.buildSubstitutor() - val resultArguments = newParameters.map { newSubstitutor.substitute(TypeProjectionImpl(it.variance, it.defaultType))!! } - return Pair(composedSubstitution, resultArguments) + return composedSubstitution } private class CompositeTypeSubstitution(