Fix solveOneFromTheOther for RecursiveSuperclasses
authorSimon Peyton Jones <simonpj@microsoft.com>
Wed, 7 Feb 2018 11:57:40 +0000 (11:57 +0000)
committerSimon Peyton Jones <simonpj@microsoft.com>
Wed, 7 Feb 2018 11:57:40 +0000 (11:57 +0000)
commit65069806ea3637882d584e785dcb9e650271e4b6
tree0a6af3f754c2e7ce93fb87c4034b2469cb371a4d
parent41d29d5ad100d4c8bf4d2175c11cc710b23843da
Fix solveOneFromTheOther for RecursiveSuperclasses

This patch fixes the redundant superclass expansion
in Trac #14774.

The main change is to fix TcInterac.solveOneFromTheOther, so
that it does not prefer a work-item with a binding if that binding
transitively depends on the inert item we are comparing it with.

Explained in Note [Replacement vs keeping] in TcInert, esp
item (c) of the "Constraints coming from the same level" part.

To make this work I refactored out a new function
TcEvidence.findNeededEvVars, which was previously buried
inside TcSimplify.neededEvVars.

I added quite a few more comments and signposts about superclass
expansion.
compiler/typecheck/TcCanonical.hs
compiler/typecheck/TcEvidence.hs
compiler/typecheck/TcInteract.hs
compiler/typecheck/TcSimplify.hs
testsuite/tests/typecheck/should_compile/Makefile
testsuite/tests/typecheck/should_compile/T14774.hs [new file with mode: 0644]
testsuite/tests/typecheck/should_compile/T14774.stdout [new file with mode: 0644]
testsuite/tests/typecheck/should_compile/all.T