Cannot inherit from generic forward types
Split from #18861

```nim
type
  ConnectionRequest* = ref object of RootObj
  ConnectionStrBool* = distinct bool
  ConnectionSetRequest = ref object of ConnectionRequestT[ConnectionStrBool]
  ConnectionRequestT*[T] = ref object of ConnectionRequest
proc execute*(req: ConnectionRequestT[bool]) = discard
proc execute*(req: ConnectionRequestT[ConnectionStrBool]) = discard
ConnectionSetRequest().execute()
```

Apparently used to give this error:

```
/tmp/zzz.nim(4, 37) Error: inheritance only works with non-final objects; for ConnectionRequestT[zzz.ConnectionStrBool] to be inheritable it must be 'object of RootObj' instead of 'object', but swapping object declaration order into 
```

But now segfaults the compiler in `lookupInRecordAndBuildCheck` called [here](https://github.com/nim-lang/Nim/blob/05c74d684481733c507dd18a7da8a296289ca32d/compiler/semexprs.nim#L1340).

This case also used to not compile:

```nim
type
  Foo = object of Bar
  Bar = object of RootObj
```

and now compiles, but might not work if `Foo` is used further.

#5687 might be related