diff --git a/numba/core/lowering.py b/numba/core/lowering.py
index 2f605d6a9..c49a220c3 100644
--- a/numba/core/lowering.py
+++ b/numba/core/lowering.py
@@ -550,10 +550,12 @@ class Lower(BaseLower):
             argty = self.typeof("arg." + value.name)
             if isinstance(argty, types.Omitted):
                 pyval = argty.value
+                tyctx = self.context.typing_context
+                valty = tyctx.resolve_value_type_prefer_literal(pyval)
                 # use the type of the constant value
-                valty = self.context.typing_context.resolve_value_type(pyval)
-                const = self.context.get_constant_generic(self.builder, valty,
-                                                          pyval)
+                const = self.context.get_constant_generic(
+                    self.builder, valty, pyval,
+                )
                 # cast it to the variable type
                 res = self.context.cast(self.builder, const, valty, ty)
             else:
diff --git a/numba/core/typeinfer.py b/numba/core/typeinfer.py
index 9477a43d1..4ca5d7b61 100644
--- a/numba/core/typeinfer.py
+++ b/numba/core/typeinfer.py
@@ -208,7 +208,9 @@ class ArgConstraint(object):
                 return
             ty = src.getone()
             if isinstance(ty, types.Omitted):
-                ty = typeinfer.context.resolve_value_type(ty.value)
+                ty = typeinfer.context.resolve_value_type_prefer_literal(
+                    ty.value,
+                )
             if not ty.is_precise():
                 raise TypingError('non-precise type {}'.format(ty))
             typeinfer.add_type(self.dst, ty, loc=self.loc)
diff --git a/numba/core/types/misc.py b/numba/core/types/misc.py
index e4c579202..dfc8d63f3 100644
--- a/numba/core/types/misc.py
+++ b/numba/core/types/misc.py
@@ -84,12 +84,16 @@ class Omitted(Opaque):
     """
 
     def __init__(self, value):
-        self.value = value
+        self._value = value
         super(Omitted, self).__init__("omitted(default=%r)" % (value,))
 
     @property
     def key(self):
-        return type(self.value), id(self.value)
+        return type(self._value), id(self._value)
+
+    @property
+    def value(self):
+        return self._value
 
 
 class VarArg(Type):
diff --git a/numba/core/typing/builtins.py b/numba/core/typing/builtins.py
index 0aa397137..3354205f4 100644
--- a/numba/core/typing/builtins.py
+++ b/numba/core/typing/builtins.py
@@ -992,7 +992,9 @@ class TypeBuiltin(AbstractTemplate):
         assert not kws
         if len(args) == 1:
             # One-argument type() -> return the __class__
-            classty = self.context.resolve_getattr(args[0], "__class__")
+            # Avoid literal types
+            arg = types.unliteral(args[0])
+            classty = self.context.resolve_getattr(arg, "__class__")
             if classty is not None:
                 return signature(classty, *args)
 
diff --git a/numba/core/typing/context.py b/numba/core/typing/context.py
index 61f8452fc..81059ac5f 100644
--- a/numba/core/typing/context.py
+++ b/numba/core/typing/context.py
@@ -385,6 +385,15 @@ class BaseContext(object):
 
         raise typeof_exc
 
+    def resolve_value_type_prefer_literal(self, value):
+        """Resolve value type and prefer Literal types whenever possible.
+        """
+        lit = types.maybe_literal(value)
+        if lit is None:
+            return self.resolve_value_type(value)
+        else:
+            return lit
+
     def _get_global_type(self, gv):
         ty = self._lookup_global(gv)
         if ty is not None:

Default value is not literal
<!--

Thanks for opening an issue! To help the Numba team handle your information
efficiently, please first ensure that there is no other issue present that
already describes the issue you have
(search at https://github.com/numba/numba/issues?&q=is%3Aissue).

For more general "how do I do X?" type questions, please speak to us in real
time on https://gitter.im/numba/numba or post to the Numba mailing list
https://groups.google.com/a/continuum.io/forum/#!forum/numba-users.

-->

## Reporting a bug

<!--

Before submitting a bug report please ensure that you can check off these boxes:

-->

- [x] I am using the latest released version of Numba (most recent is visible in
 the change log (https://github.com/numba/numba/blob/master/CHANGE_LOG).
- [x] I have included below a minimal working reproducer (if you are unsure how
 to write one see http://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports).

<!--

Please include details of the bug here, including, if applicable, what you
expected to happen!

-->

```python
import numba

def inner(a):
    pass

@numba.extending.overload(inner)
def inner_overload(a):
    if not isinstance(a, numba.types.Literal):
        return None

    def impl(a):
        print(a)

    return impl

@numba.extending.register_jitable
def my_func(a='a'):
    inner(a)

@numba.njit()
def f():
    my_func()

f()
```

Output:
```
Traceback (most recent call last):
  File "./test.py", line 24, in <module>
    f()
  File ".../numba/core/dispatcher.py", line 401, in _compile_for_args
    error_rewrite(e, 'typing')
  File ".../numba/core/dispatcher.py", line 344, in error_rewrite
    reraise(type(e), e, None)
  File ".../numba/core/utils.py", line 79, in reraise
    raise value.with_traceback(tb)
numba.core.errors.TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Invalid use of Function(<function my_func at 0x7ff222b79f70>) with argument(s) of type(s): ()
 * parameterized
In definition 0:
    TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Invalid use of Function(<function inner at 0x7ff23f0ab700>) with argument(s) of type(s): (unicode_type)
 * parameterized
In definition 0:
    All templates rejected with literals.
In definition 1:
    All templates rejected without literals.
This error is usually caused by passing an argument of a type that is unsupported by the named function.
```

Version:
```python
@numba.njit()
def f_1():
    my_func('a')
```

Works fine.

Numba version is 0a8b8118987944e82603bfa3c90d87b80ffe5d99
diff --git a/numba/tests/test_types.py b/numba/tests/test_types.py
index e90178628..f09882de7 100644
--- a/numba/tests/test_types.py
+++ b/numba/tests/test_types.py
@@ -785,5 +785,61 @@ class FooType(types.Type):
                              f(Foo()))
 
 
+class TestIssues(TestCase):
+    def test_omitted_type(self):
+        # issue https://github.com/numba/numba/issues/5471
+        def inner(a):
+            pass
+
+        @overload(inner)
+        def inner_overload(a):
+            if not isinstance(a, types.Literal):
+                return
+            return lambda a: a
+
+        @njit
+        def my_func(a='a'):
+            return inner(a)
+
+        @njit
+        def f():
+            return my_func()
+
+        @njit
+        def g():
+            return my_func('b')
+
+        self.assertEqual(f(), 'a')
+        self.assertEqual(g(), 'b')
+
+    def test_type_of_literal(self):
+        # type(val) where val is a literal should not give a literal type.
+        def inner(a):
+            pass
+
+        @overload(inner)
+        def inner_overload(a):
+            if not isinstance(a, types.Literal):
+                return
+            self.assertIsInstance(a, types.Literal)
+            # NOTE: using 1.23 to ensure that the result is indeed an int.
+            return lambda a: type(a)(a + 1.23)
+
+        @njit
+        def my_func(a=1):
+            return inner(a)
+
+        @njit
+        def f():
+            return my_func()
+
+        @njit
+        def g():
+            return my_func(100)
+
+        self.assertEqual(f(), 2)
+        self.assertEqual(g(), 101)
+
+
 if __name__ == '__main__':
     unittest.main()

pip install -e .
parse_log_pytest
requirements.txt
pytest
apt-get update apt-get install -y gcc g++
3.7
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
certifi @ file:///croot/certifi_1671487769961/work/certifi
exceptiongroup==1.2.2
importlib-metadata==6.7.0
iniconfig==2.0.0
llvmlite==0.31.0
-e git+https://github.com/numba/numba.git@1e2dc49c699b72c48b258a7c15998b505058289a#egg=numba
numpy==1.21.6
packaging==24.0
pluggy==1.2.0
pytest==7.4.4
tomli==2.0.1
typing_extensions==4.7.1
zipp==3.15.0

name: numba
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2022.12.7=py37h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=22.3.1=py37h06a4308_0
  - python=3.7.16=h7a1cb2a_0
  - readline=8.2=h5eee18b_0
  - setuptools=65.6.3=py37h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.38.4=py37h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - argparse==1.4.0
      - exceptiongroup==1.2.2
      - importlib-metadata==6.7.0
      - iniconfig==2.0.0
      - llvmlite==0.31.0
      - numpy==1.21.6
      - packaging==24.0
      - pluggy==1.2.0
      - pytest==7.4.4
      - tomli==2.0.1
      - typing-extensions==4.7.1
      - zipp==3.15.0
prefix: /opt/conda/envs/numba

numba/tests/test_types.py::TestIssues::test_omitted_type numba/tests/test_types.py::TestIssues::test_type_of_literal
numba/tests/test_types.py::TestTypes::test_array_notation numba/tests/test_types.py::TestTypes::test_array_notation_for_dtype numba/tests/test_types.py::TestTypes::test_cache_trimming numba/tests/test_types.py::TestTypes::test_call_notation numba/tests/test_types.py::TestTypes::test_equality numba/tests/test_types.py::TestTypes::test_function_incompatible_templates numba/tests/test_types.py::TestTypes::test_interning numba/tests/test_types.py::TestTypes::test_list_type_getitem numba/tests/test_types.py::TestTypes::test_weaktype numba/tests/test_types.py::TestNumbers::test_bitwidth numba/tests/test_types.py::TestNumbers::test_from_bidwidth numba/tests/test_types.py::TestNumbers::test_minval_maxval numba/tests/test_types.py::TestNumbers::test_ordering numba/tests/test_types.py::TestNdIter::test_properties numba/tests/test_types.py::TestPickling::test_arrays numba/tests/test_types.py::TestPickling::test_atomic_types numba/tests/test_types.py::TestPickling::test_enums numba/tests/test_types.py::TestPickling::test_generator numba/tests/test_types.py::TestPickling::test_lists numba/tests/test_types.py::TestPickling::test_namedtuples numba/tests/test_types.py::TestPickling::test_optional numba/tests/test_types.py::TestPickling::test_predefined_types numba/tests/test_types.py::TestPickling::test_records numba/tests/test_types.py::TestPickling::test_tuples numba/tests/test_types.py::TestSignatures::test_normalize_signature numba/tests/test_types.py::TestRecordDtype::test_record_type_equiv numba/tests/test_types.py::TestRecordDtype::test_user_specified numba/tests/test_types.py::TestDType::test_dtype_with_string numba/tests/test_types.py::TestDType::test_dtype_with_type numba/tests/test_types.py::TestDType::test_kind numba/tests/test_types.py::TestDType::test_type_attr numba/tests/test_types.py::TestIsInternalTypeMarker::test_create_temp_module numba/tests/test_types.py::TestIsInternalTypeMarker::test_create_temp_module_with_exception numba/tests/test_types.py::TestIsInternalTypeMarker::test_externally_defined_type_is_external numba/tests/test_types.py::TestIsInternalTypeMarker::test_mixin_against_real_example
numba/core/typing/builtins.py numba/core/lowering.py numba/core/typing/context.py numba/core/types/misc.py numba/core/typeinfer.py
numba/core/typing/builtins.py numba/core/lowering.py numba/core/typing/context.py numba/core/types/misc.py numba/core/typeinfer.py