001 /*
002 * Copyright 2010-2015 JetBrains s.r.o.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017 package org.jetbrains.kotlin.load.java.components;
018
019 import org.jetbrains.annotations.NotNull;
020 import org.jetbrains.annotations.Nullable;
021 import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor;
022 import org.jetbrains.kotlin.descriptors.ClassDescriptor;
023 import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor;
024 import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor;
025 import org.jetbrains.kotlin.load.java.JavaBindingContext;
026 import org.jetbrains.kotlin.load.java.structure.JavaMethod;
027 import org.jetbrains.kotlin.resolve.BindingTrace;
028 import org.jetbrains.kotlin.resolve.jvm.kotlinSignature.SignaturesPropagationData;
029 import org.jetbrains.kotlin.types.KotlinType;
030
031 import java.util.List;
032
033 public class SignaturePropagatorImpl implements SignaturePropagator {
034 private final BindingTrace trace;
035
036 public SignaturePropagatorImpl(@NotNull BindingTrace trace) {
037 this.trace = trace;
038 }
039
040 @Override
041 @NotNull
042 public PropagatedSignature resolvePropagatedSignature(
043 @NotNull JavaMethod method,
044 @NotNull ClassDescriptor owner,
045 @NotNull KotlinType returnType,
046 @Nullable KotlinType receiverType,
047 @NotNull List<ValueParameterDescriptor> valueParameters,
048 @NotNull List<TypeParameterDescriptor> typeParameters
049 ) {
050 SignaturesPropagationData data =
051 new SignaturesPropagationData(owner, returnType, receiverType, valueParameters, typeParameters, method);
052 return new PropagatedSignature(
053 returnType, data.getModifiedReceiverType(), data.getModifiedValueParameters(),
054 typeParameters, data.getSignatureErrors(), data.getModifiedHasStableParameterNames()
055 );
056 }
057
058 @Override
059 public void reportSignatureErrors(@NotNull CallableMemberDescriptor descriptor, @NotNull List<String> signatureErrors) {
060 trace.record(JavaBindingContext.LOAD_FROM_JAVA_SIGNATURE_ERRORS, descriptor.getOriginal(), signatureErrors);
061 }
062 }