Problem using parent type casting in switch cases
Here's a minimum repro ksy:
```yaml
# Checks <insert description here>
meta:
  id: nav_parent_switch_cast
seq:
  - id: foo
    type: foo
types:
  foo:
    seq:
      - id: buf_type
        type: u1
      - id: flag
        type: u1
      - id: buf
        size: 4
        type:
          switch-on: buf_type
          cases:
            0: zero
            1: one
    types:
      zero:
        seq:
        - id: bar
          type: bar
      one:
        seq:
        - id: bar
          type: bar
      bar:
        instances:
          flag:
            value: '_parent._parent.as<foo>.flag'
```

You can test it with this data:
```
00 00 39 05 00 00
```

It currently throws this error:
```
scala.MatchError: KaitaiStructType (of class io.kaitai.struct.datatype.DataType$KaitaiStructType$)
        at io.kaitai.struct.translators.BaseTranslator.translate(BaseTranslator.scala:85)
        at io.kaitai.struct.translators.BaseTranslator.doCast(BaseTranslator.scala:164)
        at io.kaitai.struct.translators.BaseTranslator.translate(BaseTranslator.scala:158)
        at io.kaitai.struct.translators.BaseTranslator.userTypeField(BaseTranslator.scala:172)
        at io.kaitai.struct.translators.BaseTranslator.translate(BaseTranslator.scala:87)
        at io.kaitai.struct.languages.components.ObjectOrientedLanguage$class.expression(ObjectOrientedLanguage.scala:9)
        at io.kaitai.struct.languages.JavaScriptCompiler.expression(JavaScriptCompiler.scala:12)
        at io.kaitai.struct.languages.components.EveryReadIsExpression$class.instanceCalculate(EveryReadIsExpression.scala:185)
        at io.kaitai.struct.languages.JavaScriptCompiler.instanceCalculate(JavaScriptCompiler.scala:12)
        at io.kaitai.struct.ClassCompiler.compileInstance(ClassCompiler.scala:196)
        at io.kaitai.struct.ClassCompiler$$anonfun$compileInstances$1.apply(ClassCompiler.scala:176)
        at io.kaitai.struct.ClassCompiler$$anonfun$compileInstances$1.apply(ClassCompiler.scala:175)
        at scala.collection.immutable.Map$Map1.foreach(Map.scala:116)
        at io.kaitai.struct.ClassCompiler.compileInstances(ClassCompiler.scala:175)
        at io.kaitai.struct.ClassCompiler.compileClass(ClassCompiler.scala:82)
        at io.kaitai.struct.ClassCompiler$$anonfun$compileSubclasses$1.apply(ClassCompiler.scala:172)
        at io.kaitai.struct.ClassCompiler$$anonfun$compileSubclasses$1.apply(ClassCompiler.scala:172)
        at scala.collection.immutable.Map$Map3.foreach(Map.scala:161)
        at io.kaitai.struct.ClassCompiler.compileSubclasses(ClassCompiler.scala:172)
        at io.kaitai.struct.ClassCompiler.compileClass(ClassCompiler.scala:77)
        at io.kaitai.struct.ClassCompiler$$anonfun$compileSubclasses$1.apply(ClassCompiler.scala:172)
        at io.kaitai.struct.ClassCompiler$$anonfun$compileSubclasses$1.apply(ClassCompiler.scala:172)
        at scala.collection.immutable.Map$Map1.foreach(Map.scala:116)
        at io.kaitai.struct.ClassCompiler.compileSubclasses(ClassCompiler.scala:172)
        at io.kaitai.struct.ClassCompiler.compileClass(ClassCompiler.scala:77)
        at io.kaitai.struct.ClassCompiler.compile(ClassCompiler.scala:24)
        at io.kaitai.struct.Main$.compile(Main.scala:63)
        at io.kaitai.struct.JavaMain.compileSpecAndWriteToFile(JavaMain.scala:281)
        at io.kaitai.struct.JavaMain$$anonfun$compileOneLang$2.apply(JavaMain.scala:265)
        at io.kaitai.struct.JavaMain$$anonfun$compileOneLang$2.apply(JavaMain.scala:263)
        at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)
        at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)
        at scala.collection.mutable.HashMap$$anonfun$foreach$1.apply(HashMap.scala:130)
        at scala.collection.mutable.HashMap$$anonfun$foreach$1.apply(HashMap.scala:130)
        at scala.collection.mutable.HashTable$class.foreachEntry(HashTable.scala:236)
        at scala.collection.mutable.HashMap.foreachEntry(HashMap.scala:40)
        at scala.collection.mutable.HashMap.foreach(HashMap.scala:130)
        at scala.collection.TraversableLike$class.map(TraversableLike.scala:234)
        at scala.collection.AbstractTraversable.map(Traversable.scala:104)
        at io.kaitai.struct.JavaMain.compileOneLang(JavaMain.scala:263)
        at io.kaitai.struct.JavaMain.io$kaitai$struct$JavaMain$$compileOneInput(JavaMain.scala:242)
        at io.kaitai.struct.JavaMain$$anonfun$18.apply(JavaMain.scala:212)
        at io.kaitai.struct.JavaMain$$anonfun$18.apply(JavaMain.scala:210)
        at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)
        at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)
        at scala.collection.immutable.List.foreach(List.scala:392)
        at scala.collection.TraversableLike$class.map(TraversableLike.scala:234)
        at scala.collection.immutable.List.map(List.scala:296)
        at io.kaitai.struct.JavaMain.run(JavaMain.scala:210)
        at io.kaitai.struct.JavaMain$.main(JavaMain.scala:201)
        at io.kaitai.struct.JavaMain.main(JavaMain.scala)
KaitaiStructType (of class io.kaitai.struct.datatype.DataType$KaitaiStructType$)
```