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.resolve.lazy.descriptors;
018    
019    import org.jetbrains.annotations.NotNull;
020    import org.jetbrains.kotlin.resolve.lazy.LazyClassContext;
021    import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
022    import org.jetbrains.kotlin.descriptors.Visibilities;
023    import org.jetbrains.kotlin.descriptors.Visibility;
024    import org.jetbrains.kotlin.name.Name;
025    import org.jetbrains.kotlin.resolve.TemporaryBindingTrace;
026    import org.jetbrains.kotlin.resolve.lazy.ResolveSession;
027    import org.jetbrains.kotlin.resolve.lazy.data.JetScriptInfo;
028    import org.jetbrains.kotlin.resolve.lazy.declarations.ClassMemberDeclarationProvider;
029    
030    public class LazyScriptClassDescriptor extends LazyClassDescriptor {
031        public LazyScriptClassDescriptor(
032                @NotNull ResolveSession resolveSession,
033                @NotNull DeclarationDescriptor containingDeclaration,
034                @NotNull Name name,
035                @NotNull JetScriptInfo scriptInfo
036        ) {
037            super(resolveSession, containingDeclaration, name, scriptInfo);
038        }
039    
040        @NotNull
041        @Override
042        protected LazyScriptClassMemberScope createMemberScope(
043                @NotNull LazyClassContext c,
044                @NotNull ClassMemberDeclarationProvider declarationProvider
045        ) {
046            return new LazyScriptClassMemberScope(
047                    // Must be a ResolveSession for scripts
048                    (ResolveSession) c,
049                    declarationProvider,
050                    this,
051                    TemporaryBindingTrace.create(c.getTrace(), "A trace for script class, needed to avoid rewrites on members")
052            );
053        }
054    
055        @NotNull
056        @Override
057        public LazyScriptClassMemberScope getUnsubstitutedMemberScope() {
058            return (LazyScriptClassMemberScope) super.getUnsubstitutedMemberScope();
059        }
060    
061        @NotNull
062        @Override
063        public Visibility getVisibility() {
064            return Visibilities.PUBLIC;
065        }
066    }