Fix a bad error in tcMatchTy

This patch fixes #17395, a very subtle and hard-to-trigger
bug in tcMatchTy.  It's all explained in
  Note [Matching in the presence of casts (2)]

I have not added a regression test because it is very hard
to trigger it, until we have the upcoming mkAppTyM patch,
after which lacking this patch means you can't even compile
the libraries.
22 jobs for master in 535 minutes and 42 seconds (queued for 4 seconds)
Status Job ID Name Coverage
  Lint
passed #190344
lint
lint-linters

00:00:14

passed #190347
lint
lint-submods-branch

00:00:16

passed #190345
lint
lint-testsuite

00:00:15

passed #190346
lint
typecheck-testsuite

00:00:14

 
  Quick Build
passed #190348
x86_64-linux
hadrian-ghc-in-ghci

00:19:39

 
  Build
passed #190351
x86_64-linux
release-x86_64-linux-deb9-dwarf

01:41:26

passed #190350
x86_64-linux
validate-x86_64-linux-deb9-debug

03:48:31

passed #190349
x86_64-linux
validate-x86_64-linux-deb9-hadrian

02:22:16

 
  Full Build
failed #190354
aarch64-linux allowed to fail
validate-aarch64-linux-deb9

03:56:54

failed #190355
armv7-linux allowed to fail
validate-armv7-linux-deb9

03:37:18

passed #190356
x86_64-linux
validate-i386-linux-deb9

01:52:23

passed #190353
x86_64-darwin
validate-x86_64-darwin

01:00:49

passed #190357
x86_64-linux
validate-x86_64-linux-deb9-integer-simple

01:53:31

passed #190352
x86_64-linux
validate-x86_64-linux-deb9-unreg-hadrian

04:32:05

passed #190358
x86_64-linux
validate-x86_64-linux-fedora27

01:14:16

failed #190360
x86_64-windows allowed to fail
validate-x86_64-windows

00:09:17

failed #190359
x86_64-windows allowed to fail
validate-x86_64-windows-hadrian

00:33:21

 
  Cleanup
passed #190361
x86_64-darwin
cleanup-darwin

00:00:05

 
  Packaging
failed #190362
x86_64-linux allowed to fail
doc-tarball

00:00:45

 
  Testing
manual #190363
x86_64-linux allowed to fail manual
hackage
passed #190364
x86_64-linux
perf-nofib

00:13:22

 
  Deploy
failed #190365
x86_64-linux allowed to fail
pages

00:00:26

 
Name Stage Failure
failed
validate-aarch64-linux-deb9 Full Build
Uploading artifacts...
ghc-aarch64-linux-deb9.tar.xz: found 1 matching files
junit.xml: found 1 matching files

performance-metrics.tsv: found 1 matching files

Uploading artifacts to coordinator... ok
id=190354 responseStatus=201 Created token=P7EC7jx2
Uploading artifacts...
junit.xml: found 1 matching files

Uploading artifacts to coordinator... ok
id=190354 responseStatus=201 Created token=P7EC7jx2
ERROR: Job failed: exit code 1
failed
validate-x86_64-windows-hadrian Full Build
Runtime platform                                    arch=amd64 os=windows pid=2456 revision=1f513601 version=11.10.1
WARNING: ghc.tar.xz: no matching files
WARNING: junit.xml: no matching files
ERROR: No files to upload
Uploading artifacts...
Runtime platform
arch=amd64 os=windows pid=5332 revision=1f513601 version=11.10.1
WARNING: junit.xml: no matching files
ERROR: No files to upload
ERROR: Job failed: exit status 1
failed
validate-x86_64-windows Full Build
Runtime platform                                    arch=amd64 os=windows pid=6084 revision=1f513601 version=11.10.1
WARNING: $BIN_DIST_PREP_TAR_COMP: no matching files
WARNING: junit.xml: no matching files
ERROR: No files to upload
Uploading artifacts...
Runtime platform
arch=amd64 os=windows pid=6092 revision=1f513601 version=11.10.1
WARNING: junit.xml: no matching files
ERROR: No files to upload
ERROR: Job failed: exit status 2
failed
validate-armv7-linux-deb9 Full Build
Uploading artifacts...
ghc-armv7-linux-deb9.tar.xz: found 1 matching files
junit.xml: found 1 matching files

performance-metrics.tsv: found 1 matching files

Uploading artifacts to coordinator... ok
id=190355 responseStatus=201 Created token=vDHrG3EL
Uploading artifacts...
junit.xml: found 1 matching files

Uploading artifacts to coordinator... ok
id=190355 responseStatus=201 Created token=vDHrG3EL
ERROR: Job failed: exit code 1
failed
doc-tarball Packaging
Synchronizing submodule url for 'nofib'
Synchronizing submodule url for 'utils/haddock'
Synchronizing submodule url for 'utils/hsc2hs'
$ git submodule update --init --recursive
$ git checkout .gitmodules
$ git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true
$ if [ ! -f "$LINUX_BINDIST" ]; then # collapsed multi-line command
Error: ghc-x86_64-mingw32.tar.xz does not exist. Did the 64-bit Windows job fail?
ERROR: Job failed: exit code 1
failed
pages Deploy
$ git checkout .gitmodules
$ git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true
From https://gitlab.haskell.org/ghc/ghc-performance-notes
04bb94b6e9..4438bdd7fb refs/notes/perf -> refs/notes/perf
$ mkdir -p public/doc
$ tar -xf haddock.html.tar.xz -C public/doc
tar: haddock.html.tar.xz: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now
ERROR: Job failed: exit code 1