Reject casts to builtin typeclasses (#14788)

* Closes #14231, closes #14452

* Merge test to tcast.nim
This commit is contained in:
Danil Yarantsev 2020-06-24 23:32:01 +03:00 • committed by GitHub
commit 80952cadaa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View file

@ -191,6 +191,8 @@ proc isCastable(conf: ConfigRef; dst, src: PType): bool =
return false
if skipTypes(src, abstractInst-{tyTypeDesc}).kind == tyTypeDesc:
return false
if skipTypes(dst, abstractInst).kind == tyBuiltInTypeClass:
return false
if conf.selectedGC in {gcArc, gcOrc}:
let d = skipTypes(dst, abstractInst)
let s = skipTypes(src, abstractInst)