@@ -686,6 +686,7 @@ elabInstance info syn fc cs n ps t ds
686686 let ds' = insertDefaults (class_defaults ci) ns ds
687687 iLOG ("Defaults inserted: " ++ show ds' ++ "\n" ++ show ci)
688688 mapM_ (warnMissing ds' ns) (map fst (class_methods ci))
689+ mapM_ (checkInClass (map fst (class_methods ci))) (concatMap defined ds')
689690 let wb = map mkTyDecl mtys ++ map (decorateid (decorate ns)) ds'
690691 logLvl 3 $ "Method types " ++ showSep "\n" (map (showDeclImp True . mkTyDecl) mtys)
691692 -- get the implicit parameters that need passing through to the where block
@@ -780,6 +781,13 @@ elabInstance info syn fc cs n ps t ds
780781 = iWarn fc $ "method " ++ show meth ++ " not defined"
781782 | otherwise = return ()
782783
784+ checkInClass ns meth
785+ | not (null (filter (eqRoot meth) ns)) = return ()
786+ | otherwise = tclift $ tfail (At fc (Msg $
787+ show meth ++ " not a method of class " ++ show n))
788+
789+ eqRoot x y = nsroot x == nsroot y
790+
783791 clauseFor m ns (PClauses _ _ m' _) = decorate ns m == decorate ns m'
784792 clauseFor m ns _ = False
785793