Skip to content

Commit

Permalink
Extract Java specific check from common method out
Browse files Browse the repository at this point in the history
 This is needed for further refactoring
  • Loading branch information
zarechenskiy committed Apr 14, 2020
1 parent cf90fe8 commit 04223f5
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,12 @@ private static <F extends FunctionDescriptor> SamAdapterDescriptor<F> initSamAda
@NotNull SamConversionResolver samResolver,
@NotNull SamConversionOracle samConversionOracle
) {
TypeParameters typeParameters = recreateAndInitializeTypeParameters(original.getTypeParameters(), adapter);
TypeParameters typeParameters;
if (adapter instanceof SamAdapterClassConstructorDescriptor) {
typeParameters = new TypeParameters(original.getTypeParameters(), TypeSubstitutor.EMPTY);
} else {
typeParameters = recreateAndInitializeTypeParameters(original.getTypeParameters(), adapter);
}

KotlinType returnTypeUnsubstituted = original.getReturnType();
assert returnTypeUnsubstituted != null : "Creating SAM adapter for not initialized original: " + original;
Expand Down Expand Up @@ -248,10 +253,6 @@ private static TypeParameters recreateAndInitializeTypeParameters(
@NotNull List<TypeParameterDescriptor> originalParameters,
@Nullable DeclarationDescriptor newOwner
) {
if (newOwner instanceof SamAdapterClassConstructorDescriptor) {
return new TypeParameters(originalParameters, TypeSubstitutor.EMPTY);
}

Map<TypeParameterDescriptor, TypeParameterDescriptorImpl> traitToFunTypeParameters =
JavaResolverUtils.recreateTypeParametersAndReturnMapping(originalParameters, newOwner);
TypeSubstitutor typeParametersSubstitutor = JavaResolverUtils.createSubstitutorForTypeParameters(traitToFunTypeParameters);
Expand Down

0 comments on commit 04223f5

Please sign in to comment.