com.sun.tools.javac.code.Type.UnionClassType Java Examples

The following examples show how to use com.sun.tools.javac.code.Type.UnionClassType. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JavacTrees.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public TypeMirror getLub(CatchTree tree) {
    JCCatch ct = (JCCatch) tree;
    JCVariableDecl v = ct.param;
    if (v.type != null && v.type.getKind() == TypeKind.UNION) {
        UnionClassType ut = (UnionClassType) v.type;
        return ut.getLub();
    } else {
        return v.type;
    }
}
 
Example #2
Source File: JavacTrees.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public TypeMirror getLub(CatchTree tree) {
    JCCatch ct = (JCCatch) tree;
    JCVariableDecl v = ct.param;
    if (v.type != null && v.type.getKind() == TypeKind.UNION) {
        UnionClassType ut = (UnionClassType) v.type;
        return ut.getLub();
    } else {
        return v.type;
    }
}
 
Example #3
Source File: JavacTrees.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
@Override
public TypeMirror getLub(CatchTree tree) {
    JCCatch ct = (JCCatch) tree;
    JCVariableDecl v = ct.param;
    if (v.type != null && v.type.getKind() == TypeKind.UNION) {
        UnionClassType ut = (UnionClassType) v.type;
        return ut.getLub();
    } else {
        return v.type;
    }
}
 
Example #4
Source File: JavacTrees.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
public TypeMirror getLub(CatchTree tree) {
    JCCatch ct = (JCCatch) tree;
    JCVariableDecl v = ct.param;
    if (v.type != null && v.type.getKind() == TypeKind.UNION) {
        UnionClassType ut = (UnionClassType) v.type;
        return ut.getLub();
    } else {
        return v.type;
    }
}
 
Example #5
Source File: JavacTrees.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override @DefinedBy(Api.COMPILER_TREE)
public TypeMirror getLub(CatchTree tree) {
    JCCatch ct = (JCCatch) tree;
    JCVariableDecl v = ct.param;
    if (v.type != null && v.type.getKind() == TypeKind.UNION) {
        UnionClassType ut = (UnionClassType) v.type;
        return ut.getLub();
    } else {
        return v.type;
    }
}
 
Example #6
Source File: JavacTrees.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
public TypeMirror getLub(CatchTree tree) {
    JCCatch ct = (JCCatch) tree;
    JCVariableDecl v = ct.param;
    if (v.type != null && v.type.getKind() == TypeKind.UNION) {
        UnionClassType ut = (UnionClassType) v.type;
        return ut.getLub();
    } else {
        return v.type;
    }
}
 
Example #7
Source File: JavacTrees.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
@Override
public TypeMirror getLub(CatchTree tree) {
    JCCatch ct = (JCCatch) tree;
    JCVariableDecl v = ct.param;
    if (v.type != null && v.type.getKind() == TypeKind.UNION) {
        UnionClassType ut = (UnionClassType) v.type;
        return ut.getLub();
    } else {
        return v.type;
    }
}
 
Example #8
Source File: JavacTrees.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override @DefinedBy(Api.COMPILER_TREE)
public TypeMirror getLub(CatchTree tree) {
    JCCatch ct = (JCCatch) tree;
    JCVariableDecl v = ct.param;
    if (v.type != null && v.type.getKind() == TypeKind.UNION) {
        UnionClassType ut = (UnionClassType) v.type;
        return ut.getLub();
    } else {
        return v.type;
    }
}
 
Example #9
Source File: JavacTrees.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
public TypeMirror getLub(CatchTree tree) {
    JCCatch ct = (JCCatch) tree;
    JCVariableDecl v = ct.param;
    if (v.type != null && v.type.getKind() == TypeKind.UNION) {
        UnionClassType ut = (UnionClassType) v.type;
        return ut.getLub();
    } else {
        return v.type;
    }
}
 
Example #10
Source File: JavacTrees.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
public TypeMirror getLub(CatchTree tree) {
    JCCatch ct = (JCCatch) tree;
    JCVariableDecl v = ct.param;
    if (v.type != null && v.type.getKind() == TypeKind.UNION) {
        UnionClassType ut = (UnionClassType) v.type;
        return ut.getLub();
    } else {
        return v.type;
    }
}
 
Example #11
Source File: JavacTrees.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public TypeMirror getLub(CatchTree tree) {
    JCCatch ct = (JCCatch) tree;
    JCVariableDecl v = ct.param;
    if (v.type != null && v.type.getKind() == TypeKind.UNION) {
        UnionClassType ut = (UnionClassType) v.type;
        return ut.getLub();
    } else {
        return v.type;
    }
}
 
Example #12
Source File: JavaEnvironment.java    From j2cl with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a type descriptor for the given TypeMirror, taking into account nullability.
 *
 * @param typeMirror the type provided by javac, used to create the type descriptor.
 * @param elementAnnotations the annotations on the element
 */
private TypeDescriptor createTypeDescriptorWithNullability(
    TypeMirror typeMirror, List<? extends AnnotationMirror> elementAnnotations) {
  if (typeMirror == null || typeMirror.getKind() == TypeKind.NONE) {
    return null;
  }

  if (typeMirror.getKind().isPrimitive() || typeMirror.getKind() == TypeKind.VOID) {
    return PrimitiveTypes.get(asElement(typeMirror).getSimpleName().toString());
  }

  if (typeMirror.getKind() == TypeKind.INTERSECTION) {
    return createIntersectionType((IntersectionClassType) typeMirror);
  }

  if (typeMirror.getKind() == TypeKind.UNION) {
    return createUnionType((UnionClassType) typeMirror);
  }

  if (typeMirror.getKind() == TypeKind.NULL) {
    return TypeDescriptors.get().javaLangObject;
  }

  if (typeMirror.getKind() == TypeKind.TYPEVAR) {
    return createTypeVariable((javax.lang.model.type.TypeVariable) typeMirror);
  }

  if (typeMirror.getKind() == TypeKind.WILDCARD) {
    return createWildcardTypeVariable(
        ((javax.lang.model.type.WildcardType) typeMirror).getExtendsBound());
  }

  boolean isNullable = isNullable(typeMirror, elementAnnotations);
  if (typeMirror.getKind() == TypeKind.ARRAY) {
    ArrayType arrayType = (ArrayType) typeMirror;
    TypeDescriptor componentTypeDescriptor = createTypeDescriptor(arrayType.getComponentType());
    return ArrayTypeDescriptor.newBuilder()
        .setComponentTypeDescriptor(componentTypeDescriptor)
        .setNullable(isNullable)
        .build();
  }

  return withNullability(createDeclaredType((ClassType) typeMirror), isNullable);
}
 
Example #13
Source File: JavaEnvironment.java    From j2cl with Apache License 2.0 4 votes vote down vote up
private TypeDescriptor createUnionType(UnionClassType unionType) {
  List<TypeDescriptor> unionTypeDescriptors = createTypeDescriptors(unionType.getAlternatives());
  return UnionTypeDescriptor.newBuilder().setUnionTypeDescriptors(unionTypeDescriptors).build();
}