@@ -6202,16 +6202,18 @@ impl<'db> Type<'db> {
62026202 KnownInstanceType :: TypeAliasType ( type_alias) => {
62036203 Some ( TypeDefinition :: TypeAlias ( type_alias. definition ( db) ) )
62046204 }
6205- KnownInstanceType :: NewType ( newtype) => Some ( TypeDefinition :: NewType ( newtype. definition ( db) ) ) ,
6205+ KnownInstanceType :: NewType ( newtype) => {
6206+ Some ( TypeDefinition :: NewType ( newtype. definition ( db) ) )
6207+ }
62066208 _ => None ,
62076209 } ,
62086210
62096211 Self :: SubclassOf ( subclass_of_type) => match subclass_of_type. subclass_of ( ) {
62106212 SubclassOfInner :: Dynamic ( _) => None ,
62116213 SubclassOfInner :: Class ( class) => class. type_definition ( db) ,
6212- SubclassOfInner :: TypeVar ( bound_typevar) => {
6213- Some ( TypeDefinition :: TypeVar ( bound_typevar. typevar ( db) . definition ( db) ?) )
6214- }
6214+ SubclassOfInner :: TypeVar ( bound_typevar) => Some ( TypeDefinition :: TypeVar (
6215+ bound_typevar. typevar ( db) . definition ( db) ?,
6216+ ) ) ,
62156217 } ,
62166218
62176219 Self :: TypeAlias ( alias) => alias. value_type ( db) . definition ( db) ,
@@ -6221,17 +6223,27 @@ impl<'db> Type<'db> {
62216223 . getter ( db)
62226224 . and_then ( |getter| getter. definition ( db) )
62236225 . or_else ( || property. setter ( db) . and_then ( |setter| setter. definition ( db) ) )
6224- . or_else ( || property. deleter ( db) . and_then ( |deleter| deleter. definition ( db) ) ) ,
6226+ . or_else ( || {
6227+ property
6228+ . deleter ( db)
6229+ . and_then ( |deleter| deleter. definition ( db) )
6230+ } ) ,
6231+
6232+ Self :: LiteralValue ( literal) => literal
6233+ . as_enum ( )
6234+ . and_then ( |enum_lit| enum_lit. definition ( db) )
6235+ . map ( TypeDefinition :: EnumMember )
6236+ . or_else ( || self . to_meta_type ( db) . definition ( db) ) ,
62256237
6226- Self :: LiteralValue ( _)
6227- // TODO: For enum literals, it would be even better to jump to the definition of the specific member
6228- | Self :: KnownBoundMethod ( _)
6238+ Self :: KnownBoundMethod ( _)
62296239 | Self :: WrapperDescriptor ( _)
62306240 | Self :: DataclassDecorator ( _)
62316241 | Self :: DataclassTransformer ( _)
62326242 | Self :: BoundSuper ( _) => self . to_meta_type ( db) . definition ( db) ,
62336243
6234- Self :: TypeVar ( bound_typevar) => Some ( TypeDefinition :: TypeVar ( bound_typevar. typevar ( db) . definition ( db) ?) ) ,
6244+ Self :: TypeVar ( bound_typevar) => Some ( TypeDefinition :: TypeVar (
6245+ bound_typevar. typevar ( db) . definition ( db) ?,
6246+ ) ) ,
62356247
62366248 Self :: ProtocolInstance ( protocol) => match protocol. inner {
62376249 Protocol :: FromClass ( class) => class. type_definition ( db) ,
@@ -6244,8 +6256,12 @@ impl<'db> Type<'db> {
62446256
62456257 Self :: SpecialForm ( special_form) => special_form. definition ( db) ,
62466258 Self :: Never => Type :: SpecialForm ( SpecialFormType :: Never ) . definition ( db) ,
6247- Self :: Dynamic ( DynamicType :: Any ) => Type :: SpecialForm ( SpecialFormType :: Any ) . definition ( db) ,
6248- Self :: Dynamic ( DynamicType :: Unknown | DynamicType :: UnknownGeneric ( _) ) => Type :: SpecialForm ( SpecialFormType :: Unknown ) . definition ( db) ,
6259+ Self :: Dynamic ( DynamicType :: Any ) => {
6260+ Type :: SpecialForm ( SpecialFormType :: Any ) . definition ( db)
6261+ }
6262+ Self :: Dynamic ( DynamicType :: Unknown | DynamicType :: UnknownGeneric ( _) ) => {
6263+ Type :: SpecialForm ( SpecialFormType :: Unknown ) . definition ( db)
6264+ }
62496265 Self :: AlwaysTruthy => Type :: SpecialForm ( SpecialFormType :: AlwaysTruthy ) . definition ( db) ,
62506266 Self :: AlwaysFalsy => Type :: SpecialForm ( SpecialFormType :: AlwaysFalsy ) . definition ( db) ,
62516267
@@ -6257,7 +6273,7 @@ impl<'db> Type<'db> {
62576273 | DynamicType :: TodoStarredExpression
62586274 | DynamicType :: TodoTypeVarTuple
62596275 | DynamicType :: InvalidConcatenateUnknown
6260- | DynamicType :: UnspecializedTypeVar
6276+ | DynamicType :: UnspecializedTypeVar ,
62616277 )
62626278 | Self :: Callable ( _)
62636279 | Self :: TypeIs ( _)
0 commit comments