@@ -686,6 +686,7 @@ elabInstance info syn fc cs n ps t ds
686 let ds' = insertDefaults (class_defaults ci) ns ds
686 let ds' = insertDefaults (class_defaults ci) ns ds
687 iLOG ("Defaults inserted: " ++ show ds' ++ "\n" ++ show ci)
687 iLOG ("Defaults inserted: " ++ show ds' ++ "\n" ++ show ci)
688 mapM_ (warnMissing ds' ns) (map fst (class_methods ci))
688 mapM_ (warnMissing ds' ns) (map fst (class_methods ci))
689+ mapM_ (checkInClass (map fst (class_methods ci))) (concatMap defined ds')
689 let wb = map mkTyDecl mtys ++ map (decorateid (decorate ns)) ds'
690 let wb = map mkTyDecl mtys ++ map (decorateid (decorate ns)) ds'
690 logLvl 3 $ "Method types " ++ showSep "\n" (map (showDeclImp True . mkTyDecl) mtys)
691 logLvl 3 $ "Method types " ++ showSep "\n" (map (showDeclImp True . mkTyDecl) mtys)
691 -- get the implicit parameters that need passing through to the where block
692 -- 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
780 = iWarn fc $ "method " ++ show meth ++ " not defined"
781 = iWarn fc $ "method " ++ show meth ++ " not defined"
781 | otherwise = return ()
782 | otherwise = return ()
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))
789+ eqRoot x y = nsroot x == nsroot y
783 clauseFor m ns (PClauses _ _ m' _) = decorate ns m == decorate ns m'
791 clauseFor m ns (PClauses _ _ m' _) = decorate ns m == decorate ns m'
784 clauseFor m ns _ = False
792 clauseFor m ns _ = False