anchor.diff:                      | None -> failwithf "[Ag] could not inherit attribute %A" i
   
               member x.Inherit<'r>(i : int) : 'r =
  -                let disp = Globals.inhDispatchers.[i] |> unbox<IDispatcher<Scope, 'r>>
  -                let root = Globals.rootDispatchers.[i] |> unbox<IDispatcher<'r>>
  +                let disp = Globals.getInhDispatcher<Scope,'r> i
  +                let root = Globals.getRootDispatcher<'r> i
                   x.InheritInternal(i, disp, root)
   
               member x.TryInherit<'r>(i : int) : Option<'r> =
  -                let disp = Globals.inhDispatchers.[i] |> unbox<IDispatcher<Scope, 'r>>
  -                let root = Globals.rootDispatchers.[i] |> unbox<IDispatcher<'r>>
  +                let disp = Globals.getInhDispatcher<Scope,'r> i
  +                let root = Globals.getRootDispatcher<'r> i
                   x.TryInheritInternal(i, disp, root)
  +
  +
  +            member x.TryAutoInherit(i : int) =
  +                match x.TryGet i with
  +                    | Some v -> Some v
  +                    | None ->
  +                        match x.Parent with
  +                            | null -> None
  +                            | p -> p.TryAutoInherit i
  +
  +            member x.TryInheritUntyped (i : int) =
  +                if i >= 0 && i < Globals.inhDispatchers.Length then
  +                    let disp = 
  +                        match Globals.inhDispatchers.[i] with
  +                            | null -> Globals.NopDispatcher<Scope, obj>.ObjInstance
  +                            | :? IObjectDispatcher<Scope> as d -> d
  +                            | _ -> Globals.NopDispatcher<Scope, obj>.ObjInstance
  +
  +                    let root =
  +                        match Globals.rootDispatchers.[i] with
  +                            | null -> Globals.NopDispatcher<obj>.ObjInstance
  +                            | d -> d
  +
  +                    x.TryInheritUntypedInternal(i, disp, root)
  +                else
  +                    x.TryAutoInherit i
   
               override x.ToString() =
                   match x.Parent with
  
positive.code: 
              ()
  
      let mutable private initialized = 0
      let init() =
          if System.Threading.Interlocked.Exchange(&initialized, 1) = 0 then
  
negative.code:             Globals.rootDispatchers <- Array.zeroCreate cnt
  
              SemanticFunctions.compileAll functions
  
  
              Frontend.instance <-
                  { new IAg with
                      member x.GetSynFunction<'r>(name : string) = getSynFunction<'r> name
                      member x.GetInhFunction<'r>(name : string) = getInhFunction<'r> name
                      member x.GetUntypedSynFunction (name : string) = getUntypedSynFunction name
                      member x.AttachValue(target, name, obj) = Globals.attachValue target (Globals.getAttributeIndex name) obj
                  }
  
              Log.stop()
  
  
  module NewestAgDemo =
  