@@ -1262,7 +1262,7 @@ elabClass info syn doc fc constraints tn ps ds
12621262 -- allow dependent type classes, but building instances will
12631263 -- then need some attention.
12641264 let cty = impbind ps $ conbind constraints
1265− $ pibind (map (\ (n, ty) -> (mdec n, ty)) methods)
1265+ $ pibind (map (\ (n, ty) -> (nsroot n, ty)) methods)
12661266 constraint
12671267 let cons = [("", cn, cty, fc)]
12681268 let ddecl = PDatadecl tn tty cons
@@ -1427,11 +1427,15 @@ elabInstance info syn fc cs n ps t expn ds
14271427 PApp _ _ args -> getWParams args
14281428 _ -> return []) ps
14291429 let pnames = map pname (concat (nub wparams))
1430+ let all_meths = map (nsroot . fst) (class_methods ci)
14301431 let mtys = map (\ (n, (op, t)) ->
1431− let t' = substMatchesShadow ips pnames t in
1432− (decorate ns iname n,
1433− op, coninsert cs t', t'))
1434− (class_methods ci)
1432+ let t_in = substMatchesShadow ips pnames t
1433+ mnamemap = map (\n -> (n, PRef fc (decorate ns iname n)))
1434+ all_meths
1435+ t' = substMatchesShadow mnamemap pnames t_in in
1436+ (decorate ns iname n,
1437+ op, coninsert cs t', t'))
1438+ (class_methods ci)
14351439 logLvl 3 (show (mtys, ips))
14361440 let ds' = insertDefaults i iname (class_defaults ci) ns ds
14371441 iLOG ("Defaults inserted: " ++ show ds' ++ "\n" ++ show ci)