diff --git a/mypy/checkpattern.py b/mypy/checkpattern.py
--- a/mypy/checkpattern.py
+++ b/mypy/checkpattern.py
@@ -468,7 +468,7 @@ def visit_class_pattern(self, o: ClassPattern) -> PatternType:
                 name = type_info.type.str_with_options(self.options)
             else:
                 name = type_info.name
-            self.msg.fail(message_registry.CLASS_PATTERN_TYPE_REQUIRED.format(name), o.class_ref)
+            self.msg.fail(message_registry.CLASS_PATTERN_TYPE_REQUIRED.format(name), o)
             return self.early_non_match()
 
         new_type, rest_type = self.chk.conditional_types_with_intersection(

diff --git a/test-data/unit/check-python310.test b/test-data/unit/check-python310.test
--- a/test-data/unit/check-python310.test
+++ b/test-data/unit/check-python310.test
@@ -1958,3 +1958,23 @@ def redefinition_bad(a: int):
             ...
 
 [builtins fixtures/primitives.pyi]
+
+[case testPatternMatchingClassPatternLocation]
+# See https://github.com/python/mypy/issues/15496
+from some_missing_lib import DataFrame, Series  # type: ignore[import]
+from typing import TypeVar
+
+T = TypeVar("T", Series, DataFrame)
+
+def f(x: T) -> None:
+    match x:
+        case Series() | DataFrame():  # type: ignore[misc]
+            pass
+
+def f2(x: T) -> None:
+    match x:
+        case Series():  # type: ignore[misc]
+            pass
+        case DataFrame():  # type: ignore[misc]
+            pass
+[builtins fixtures/primitives.pyi]

error: Expected type in class pattern; found "Any" (cannot be ignored, error without line number)
Found a strange bug today: https://mypy-play.net/?mypy=master&python=3.11&gist=5069b99b248041428036a717e52a3476

```python
from pandas import DataFrame, Series
from typing import TypeVar

T = TypeVar("T", Series, DataFrame)

def f(x: T) -> None:
    match x:
        case Series() | DataFrame():  # type: ignore[misc]  # ignore does not work!
            pass
        case _:
            pass
```

This makes `mypy` emit `main.py: error: Expected type in class pattern; found "Any"  [misc]` without any line number. Adding the `# type:ignore[misc]` statement ends up not doing anything. I think it is because both `Series` and `DataFrame` are of `Any`-type (not using `pandas-stubs` here since it still raises too many issues)


**Your Environment**

- Mypy version used: 1.4.0
- Python version used: 3.11

mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchSequencePatternAlreadyNarrowerBoth mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchValuePatternUnreachable mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchCapturePatternType mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchSequencePatternTupleTooShort mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchLiteralPatternNarrows mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchNestedSequencePatternNarrowsInner mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchSequencePatternCaptures mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchSequencePatternTupleNarrows mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchSequencePatternCapturesStarred mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchNestedSequencePatternNarrowsOuter mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchSequencePatternTupleStarred mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchLiteralPatternUnreachable mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchSequencePatternNarrowsInner mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchSequencePatternDoesntNarrowInvariant mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchSequencePatternTupleStarredUnion mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchValuePatternNarrows mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchSequencePatternNarrowsOuter mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchValuePatternAlreadyNarrower mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchSequencePatternTupleStarredTooShort mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchSequencePatternAlreadyNarrowerInner mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchNonMatchingSequencePattern mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchValuePatternIntersect mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchSequencePatternAlreadyNarrowerOuter mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchSequencePatternWithInvalidClassPattern mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchMappingPatternCaptures mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchMappingPatternCaptureRest mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchMappingPatternCapturesWrongKeyType mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchClassPatternCaptureNamedTupleClass mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchMappingPatternCaptureRestFromMapping mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchClassPatternCaptureGeneric mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchMappingPatternCapturesTypedDict mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchSequencePatternMatches mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchClassPatternCapturePositional mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchClassPatternCaptureGenericAlreadyKnown mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchMappingPatternCapturesTypedDictWithLiteral mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchClassPatternCaptureFilledGenericTypeAlias mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchSequencePatternCapturesTuple mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchClassPatternMemberClassCapturePositional mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchMappingPatternCapturesTypedDictWithNonLiteral mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchClassPatternCaptureGenericTypeAlias mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchSequencePatternTupleTooLong mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchClassPatternCaptureKeyword mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchInvalidClassPattern mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchMappingPatternCapturesTypedDictUnreachable mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchClassPatternNarrows mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchClassPatternCaptureSelf mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchClassPatternNarrowsUnion mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchClassPatternCaptureDataclass mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchClassPatternTooManyPositionals mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchClassPatternNarrowSelfCapture mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchClassPatternIsNotType mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchClassPatternAlreadyNarrower mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchClassPatternCaptureDataclassNoMatchArgs mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchNonLiteralMatchArgs mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchClassPatternIntersection mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchClassPatternNestedGenerics mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchClassPatternCaptureDataclassPartialMatchArgs mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchExternalMatchArgs mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchClassPatternNonexistentKeyword mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchNonFinalMatchArgs mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchAsPattern mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchClassPatternDuplicateKeyword mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchClassPatternCaptureNamedTupleInline mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchAsPatternNarrows mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchAnyTupleMatchArgs mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchClassPatternDuplicateImplicitKeyword mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchClassPatternCaptureNamedTupleInlineTyped mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchAsPatternCapturesOr mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchAsPatternAlreadyNarrower mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchCapturePatternPreexistingNarrows mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchOrPatternCapturesJoin mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchAlwaysTruePatternGuard mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchOrPatternNarrows mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchCapturePatternPreexistingIncompatible mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchCapturePatternMultipleCases mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchAlwaysFalsePatternGuard mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchOrPatternNarrowsStr mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchCapturePatternPreexistingIncompatibleLater mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchCapturePatternMultipleCaptures mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchOrPatternNarrowsUnion mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchRedefiningPatternGuard mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchSimplePatternGuard mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchCapturePatternPreexistingSame mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchAssigningPatternGuard mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchOrPatterCapturesMissing mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchNarrowingPatternGuard mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchUnionNegativeNarrowing mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchNonExhaustiveReturn mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchNonExhaustiveError mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchMoreExhaustiveReturnCases mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchOrPatternNegativeNarrowing mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchExhaustiveNoError mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchIncompatiblePatternGuard mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchExhaustiveReturn mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchSequencePatternNegativeNarrowing mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchUnreachablePatternGuard mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchMiscNonExhaustiveReturn mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchNarrowDownUnionPartially mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchAssertFalseToSilenceFalsePositives mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchNarrowUsingPatternGuardSpecialCase mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchLiteralPatternEnumNegativeNarrowing mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchNarrowDownUsingLiteralMatch mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchAsPatternExhaustiveness mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchWithBreakAndContinue mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchAndWithStatementScope mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchReachableDottedNames mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testNoneTypeWarning mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchTupleInstanceUnionNoCrash mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testOverrideMatchArgs mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchValueConstrainedTypeVar mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchTupleOptionalNoCrash mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchUnionTwoTuplesNoCrash mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testPossiblyUndefinedMatchUnreachable mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testUsedBeforeDefMatchWalrus mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testPossiblyUndefinedMatch mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchNamedAndKeywordsAreTheSame mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchStatementWalrus mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testNarrowedVariableInNestedModifiedInMatch mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testMatchSubjectRedefinition mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testTypeAliasWithNewUnionSyntaxAndNoneLeftOperand
mypy/test/testcheck.py::TypeCheckSuite::check-python310.test::testPatternMatchingClassPatternLocation