Extract 'doSubstitute' parameters into SubstitutionConfiguration
This commit is contained in:
+5
-33
@@ -157,45 +157,17 @@ class SamAdapterFunctionsScope(storageManager: StorageManager) : BaseImportingSc
|
||||
}
|
||||
}
|
||||
|
||||
override fun doSubstitute(
|
||||
originalSubstitutor: TypeSubstitutor,
|
||||
newOwner: DeclarationDescriptor,
|
||||
newModality: Modality,
|
||||
newVisibility: Visibility,
|
||||
isOperator: Boolean,
|
||||
isInfix: Boolean,
|
||||
isExternal: Boolean,
|
||||
isInline: Boolean,
|
||||
isTailrec: Boolean,
|
||||
hasStableParameterNames: Boolean,
|
||||
hasSynthesizedParameterNames: Boolean,
|
||||
original: FunctionDescriptor?,
|
||||
copyOverrides: Boolean,
|
||||
kind: CallableMemberDescriptor.Kind,
|
||||
newValueParameterDescriptors: MutableList<ValueParameterDescriptor>,
|
||||
newExtensionReceiverParameterType: KotlinType?,
|
||||
newReturnType: KotlinType,
|
||||
name: Name?,
|
||||
preserveSource: Boolean,
|
||||
signatureChange: Boolean
|
||||
): FunctionDescriptor? {
|
||||
val descriptor = super.doSubstitute(
|
||||
originalSubstitutor, newOwner, newModality, newVisibility,
|
||||
isOperator, isInfix, isExternal, isInline, isTailrec, hasStableParameterNames, hasSynthesizedParameterNames, original,
|
||||
copyOverrides, kind, newValueParameterDescriptors, newExtensionReceiverParameterType, newReturnType, name,
|
||||
preserveSource, signatureChange)
|
||||
as MyFunctionDescriptor? ?: return null
|
||||
|
||||
if (original == null) {
|
||||
throw UnsupportedOperationException("doSubstitute with no original should not be called for synthetic extension")
|
||||
}
|
||||
override fun doSubstitute(configuration: CopyConfiguration): FunctionDescriptor? {
|
||||
val descriptor = super.doSubstitute(configuration) as MyFunctionDescriptor? ?: return null
|
||||
val original = configuration.original
|
||||
?: throw UnsupportedOperationException("doSubstitute with no original should not be called for synthetic extension")
|
||||
|
||||
original as MyFunctionDescriptor
|
||||
assert(original.original == original) { "original in doSubstitute should have no other original" }
|
||||
|
||||
val substitutionMap = HashMap<TypeConstructor, TypeProjection>()
|
||||
for (typeParameter in original.typeParameters) {
|
||||
val typeProjection = originalSubstitutor.substitution[typeParameter.defaultType] ?: continue
|
||||
val typeProjection = configuration.originalSubstitutor.substitution[typeParameter.defaultType] ?: continue
|
||||
val sourceTypeParameter = original.toSourceFunctionTypeParameters!![typeParameter]!!
|
||||
substitutionMap[sourceTypeParameter.typeConstructor] = typeProjection
|
||||
|
||||
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// FILE: A.java
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public interface A {
|
||||
<R> void foo();
|
||||
}
|
||||
|
||||
// FILE: B.java
|
||||
|
||||
public interface B extends A {}
|
||||
|
||||
// FILE: k.kt
|
||||
|
||||
class C(x: A) : A by x, B {}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package
|
||||
|
||||
public interface A {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public abstract fun </*0*/ R : kotlin.Any!> foo(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface B : A {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public abstract override /*1*/ /*fake_override*/ fun </*0*/ R : kotlin.Any!> foo(): kotlin.Unit
|
||||
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, B {
|
||||
public constructor C(/*0*/ x: A)
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*delegation*/ fun </*0*/ R : kotlin.Any!> foo(): kotlin.Unit
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
@@ -11370,6 +11370,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/platformTypes"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("delegateByComplexInheritance.kt")
|
||||
public void testDelegateByComplexInheritance() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/platformTypes/delegateByComplexInheritance.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("dereference.kt")
|
||||
public void testDereference() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/platformTypes/dereference.kt");
|
||||
|
||||
Reference in New Issue
Block a user