001/*
002 * Copyright 2010-2013 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
017package org.jetbrains.jet.lang.resolve.java.descriptor;
018
019import org.jetbrains.annotations.NotNull;
020import org.jetbrains.annotations.Nullable;
021import org.jetbrains.jet.lang.descriptors.ClassKind;
022import org.jetbrains.jet.lang.descriptors.ConstructorDescriptor;
023import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
024import org.jetbrains.jet.lang.descriptors.impl.MutableClassDescriptorLite;
025import org.jetbrains.jet.lang.resolve.java.scope.JavaClassNonStaticMembersScope;
026import org.jetbrains.jet.lang.types.JetType;
027
028import java.util.Collection;
029
030/**
031 * @see org.jetbrains.jet.lang.resolve.lazy.descriptors.LazyClassDescriptor
032 */
033public class ClassDescriptorFromJvmBytecode extends MutableClassDescriptorLite {
034    private JetType functionTypeForSamInterface;
035
036    private JavaClassNonStaticMembersScope scopeForConstructorResolve;
037
038    public ClassDescriptorFromJvmBytecode(
039            @NotNull DeclarationDescriptor containingDeclaration,
040            @NotNull ClassKind kind,
041            boolean isInner
042    ) {
043        super(containingDeclaration, kind, isInner);
044    }
045
046
047    @NotNull
048    @Override
049    public Collection<ConstructorDescriptor> getConstructors() {
050        assert scopeForConstructorResolve != null;
051        return scopeForConstructorResolve.getConstructors();
052    }
053
054    @Nullable
055    @Override
056    public ConstructorDescriptor getUnsubstitutedPrimaryConstructor() {
057        return scopeForConstructorResolve.getPrimaryConstructor();
058    }
059
060    public void setScopeForConstructorResolve(@NotNull JavaClassNonStaticMembersScope scopeForConstructorResolve) {
061        this.scopeForConstructorResolve = scopeForConstructorResolve;
062    }
063
064    @Nullable
065    public JetType getFunctionTypeForSamInterface() {
066        return functionTypeForSamInterface;
067    }
068
069    public void setFunctionTypeForSamInterface(@NotNull JetType functionTypeForSamInterface) {
070        this.functionTypeForSamInterface = functionTypeForSamInterface;
071    }
072}