org.python.indexer.types
Class NUnionType
- java.lang.Object
-
- org.python.indexer.types.NType
-
- org.python.indexer.types.NUnionType
-
public class NUnionType extends NType
A union type is a set of several other types. During a union operation, destructuring happens and unknown types are unified.
-
-
Constructor Summary
Constructors Constructor and Description NUnionType()NUnionType(NType... initialTypes)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidaddType(NType t)booleancontains(NType t)NTypefirstKnownAlternate()Returns the first alternate whose type is not unknown.NTypefirstKnownNonNullAlternate()Returns the first alternate whose type is not unknown and is notIndexer#idx.builtins.None.java.util.Set<NType>getTypes()static NUnionTypenewUnion(NType... types)voidprintKids(org.python.indexer.types.NType.CyclicTypeRecorder ctr, java.lang.StringBuilder sb)Internal method to support printing in the presence of type-graph cycles.voidsetTypes(java.util.Set<NType> types)static NTypeunion(NType u, NType v)-
Methods inherited from class org.python.indexer.types.NType
asClassType, asDictType, asFuncType, asInstanceType, asListType, asModuleType, asTupleType, asUnionType, asUnknownType, follow, getTable, isClassType, isDictType, isFuncType, isInstanceType, isListType, isModuleType, isNative, isNumType, isStrType, isTupleType, isUnionType, isUnknownType, setTable, toString
-
-
-
-
Constructor Detail
-
NUnionType
public NUnionType()
-
NUnionType
public NUnionType(NType... initialTypes)
-
-
Method Detail
-
setTypes
public void setTypes(java.util.Set<NType> types)
-
getTypes
public java.util.Set<NType> getTypes()
-
addType
public void addType(NType t)
-
contains
public boolean contains(NType t)
-
newUnion
public static NUnionType newUnion(NType... types)
-
firstKnownAlternate
public NType firstKnownAlternate()
Returns the first alternate whose type is not unknown.- Returns:
- the first non-unknown alternate, or
nullif none found
-
firstKnownNonNullAlternate
public NType firstKnownNonNullAlternate()
Returns the first alternate whose type is not unknown and is notIndexer#idx.builtins.None.- Returns:
- the first non-unknown, non-
Nonealternate, ornullif none found
-
printKids
public void printKids(org.python.indexer.types.NType.CyclicTypeRecorder ctr, java.lang.StringBuilder sb)Description copied from class:NTypeInternal method to support printing in the presence of type-graph cycles.
-
-
DMelt 3.0 © DataMelt by jWork.ORG