Class DeclaredType

java.lang.Object
org.sonar.python.types.DeclaredType
All Implemented Interfaces:
InferredType

public class DeclaredType extends Object implements InferredType
  • Constructor Details

  • Method Details

    • canHaveMember

      public boolean canHaveMember(String memberName)
      Specified by:
      canHaveMember in interface InferredType
    • declaresMember

      public boolean declaresMember(String memberName)
      Description copied from interface: InferredType
      Used to handle uncertainty of declared types. It return false when a member is not present in a declared type, while canHaveMember returns true because one of its subtype may have it.
      Specified by:
      declaresMember in interface InferredType
    • isIdentityComparableWith

      public boolean isIdentityComparableWith(InferredType other)
      Specified by:
      isIdentityComparableWith in interface InferredType
    • resolveMember

      public Optional<Symbol> resolveMember(String memberName)
      Specified by:
      resolveMember in interface InferredType
    • resolveDeclaredMember

      public Optional<Symbol> resolveDeclaredMember(String memberName)
      Specified by:
      resolveDeclaredMember in interface InferredType
    • canBeOrExtend

      public boolean canBeOrExtend(String typeName)
      Specified by:
      canBeOrExtend in interface InferredType
    • canOnlyBe

      public boolean canOnlyBe(String typeName)
      Specified by:
      canOnlyBe in interface InferredType
    • isCompatibleWith

      public boolean isCompatibleWith(InferredType other)
      Specified by:
      isCompatibleWith in interface InferredType
    • mustBeOrExtend

      public boolean mustBeOrExtend(String typeName)
      Description copied from interface: InferredType
      mustBeOrExtend implies we know for sure the given type is either of the given typeName or a subtype of it. As opposed to "canBeOrExtend", this will return true only when we are sure the subtyping relationship is present. For types inferred from type annotations (DeclaredType), the actual underlying type might be different from what has been declared, but it must be or extend the declared type.
      Specified by:
      mustBeOrExtend in interface InferredType
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • typeName

      public String typeName()
    • getTypeClass

      public Symbol getTypeClass()
    • alternativeTypeSymbols

      public Set<Symbol> alternativeTypeSymbols()
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • fromInferredType

      public static InferredType fromInferredType(InferredType inferredType)