コード例 #1
0
ファイル: KotlinBuiltIns.java プロジェクト: anujk3/kotlin
 @NotNull
 public JetType getArrayElementType(@NotNull JetType arrayType) {
   if (isArray(arrayType)) {
     if (arrayType.getArguments().size() != 1) {
       throw new IllegalStateException();
     }
     return arrayType.getArguments().get(0).getType();
   }
   JetType primitiveType =
       jetArrayTypeToPrimitiveJetType.get(TypeUtils.makeNotNullable(arrayType));
   if (primitiveType == null) {
     throw new IllegalStateException("not array: " + arrayType);
   }
   return primitiveType;
 }
コード例 #2
0
ファイル: KotlinBuiltIns.java プロジェクト: anujk3/kotlin
 @Nullable
 public static JetType getReceiverType(@NotNull JetType type) {
   assert isFunctionOrExtensionFunctionType(type) : type;
   if (isExtensionFunctionType(type)) {
     return type.getArguments().get(0).getType();
   }
   return null;
 }
コード例 #3
0
ファイル: KotlinBuiltIns.java プロジェクト: anujk3/kotlin
  private static boolean isTypeConstructorFqNameInSet(
      @NotNull JetType type, @NotNull Set<FqNameUnsafe> classes) {
    ClassifierDescriptor declarationDescriptor = type.getConstructor().getDeclarationDescriptor();

    if (declarationDescriptor == null) return false;

    FqNameUnsafe fqName = DescriptorUtils.getFqName(declarationDescriptor);
    return classes.contains(fqName);
  }
コード例 #4
0
ファイル: KotlinBuiltIns.java プロジェクト: anujk3/kotlin
  public static boolean isExtensionFunctionType(@NotNull JetType type) {
    if (isExactExtensionFunctionType(type)) return true;

    for (JetType superType : type.getConstructor().getSupertypes()) {
      if (isExtensionFunctionType(superType)) return true;
    }

    return false;
  }
コード例 #5
0
ファイル: KotlinBuiltIns.java プロジェクト: anujk3/kotlin
 @NotNull
 public static List<TypeProjection> getParameterTypeProjectionsFromFunctionType(
     @NotNull JetType type) {
   assert isFunctionOrExtensionFunctionType(type);
   List<TypeProjection> arguments = type.getArguments();
   int first = isExtensionFunctionType(type) ? 1 : 0;
   int last = arguments.size() - 2;
   List<TypeProjection> parameterTypes = new ArrayList<TypeProjection>(last - first + 1);
   for (int i = first; i <= last; i++) {
     parameterTypes.add(arguments.get(i));
   }
   return parameterTypes;
 }
コード例 #6
0
ファイル: KotlinBuiltIns.java プロジェクト: anujk3/kotlin
 public static boolean isNullableAny(@NotNull JetType type) {
   return isAnyOrNullableAny(type) && type.isMarkedNullable();
 }
コード例 #7
0
ファイル: KotlinBuiltIns.java プロジェクト: anujk3/kotlin
 public static boolean isNullableNothing(@NotNull JetType type) {
   return isNothingOrNullableNothing(type) && type.isMarkedNullable();
 }
コード例 #8
0
ファイル: KotlinBuiltIns.java プロジェクト: anujk3/kotlin
 private static boolean isNotNullConstructedFromGivenClass(
     @NotNull JetType type, @NotNull FqNameUnsafe fqName) {
   return !type.isMarkedNullable() && isConstructedFromGivenClass(type, fqName);
 }
コード例 #9
0
ファイル: KotlinBuiltIns.java プロジェクト: anujk3/kotlin
 private static boolean isConstructedFromGivenClass(
     @NotNull JetType type, @NotNull FqNameUnsafe fqName) {
   ClassifierDescriptor descriptor = type.getConstructor().getDeclarationDescriptor();
   return descriptor != null && fqName.equals(DescriptorUtils.getFqName(descriptor));
 }
コード例 #10
0
ファイル: KotlinBuiltIns.java プロジェクト: anujk3/kotlin
 @NotNull
 public static JetType getReturnTypeFromFunctionType(@NotNull JetType type) {
   assert isFunctionOrExtensionFunctionType(type);
   List<TypeProjection> arguments = type.getArguments();
   return arguments.get(arguments.size() - 1).getType();
 }
コード例 #11
0
ファイル: KotlinBuiltIns.java プロジェクト: anujk3/kotlin
 public static boolean isPrimitiveType(@NotNull JetType type) {
   ClassifierDescriptor descriptor = type.getConstructor().getDeclarationDescriptor();
   return !type.isMarkedNullable()
       && descriptor != null
       && FQ_NAMES.primitiveTypes.contains(DescriptorUtils.getFqName(descriptor));
 }