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.types;
018
019 import org.jetbrains.annotations.NotNull;
020 import org.jetbrains.kotlin.descriptors.annotations.Annotations;
021 import org.jetbrains.kotlin.resolve.scopes.JetScope;
022
023 import java.util.List;
024
025 public final class JetTypeImpl extends AbstractJetType {
026
027 private final TypeConstructor constructor;
028 private final List<? extends TypeProjection> arguments;
029 private final boolean nullable;
030 private final JetScope memberScope;
031 private final Annotations annotations;
032
033 public JetTypeImpl(
034 @NotNull Annotations annotations,
035 @NotNull TypeConstructor constructor,
036 boolean nullable,
037 @NotNull List<? extends TypeProjection> arguments,
038 @NotNull JetScope memberScope
039 ) {
040 this.annotations = annotations;
041
042 if (memberScope instanceof ErrorUtils.ErrorScope) {
043 throw new IllegalStateException("JetTypeImpl should not be created for error type: " + memberScope + "\n" + constructor);
044 }
045
046 this.constructor = constructor;
047 this.nullable = nullable;
048 this.arguments = arguments;
049 this.memberScope = memberScope;
050 }
051
052 @NotNull
053 @Override
054 public Annotations getAnnotations() {
055 return annotations;
056 }
057
058 @NotNull
059 @Override
060 public TypeConstructor getConstructor() {
061 return constructor;
062 }
063
064 @NotNull
065 @Override
066 public List<TypeProjection> getArguments() {
067 //noinspection unchecked
068 return (List) arguments;
069 }
070
071 @Override
072 public boolean isMarkedNullable() {
073 return nullable;
074 }
075
076 @NotNull
077 @Override
078 public JetScope getMemberScope() {
079 return memberScope;
080 }
081
082 @Override
083 public boolean isError() {
084 return false;
085 }
086 }