diff options
author | Araq <rumpf_a@web.de> | 2018-10-15 11:50:12 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2018-10-15 11:50:12 +0200 |
commit | bf01d7136eaa8ac545a4fb74869bfa5834917b3c (patch) | |
tree | 15f7010e43d924a37fc03e6caba3208ba52822fd /compiler/ast.nim | |
parent | 8252c65cf2501b8d6401e7d8295df374ef6b1994 (diff) | |
parent | 541c2a3fecd7b1f3e6d9dc7e23a7583000cb68f1 (diff) | |
download | Nim-bf01d7136eaa8ac545a4fb74869bfa5834917b3c.tar.gz |
Merge branch 'Fixes-7845' of https://github.com/cooldome/Nim into cooldome-Fixes-7845
Diffstat (limited to 'compiler/ast.nim')
-rw-r--r-- | compiler/ast.nim | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/compiler/ast.nim b/compiler/ast.nim index f5575d8e5..eaf79a190 100644 --- a/compiler/ast.nim +++ b/compiler/ast.nim @@ -1714,8 +1714,7 @@ proc toVar*(typ: PType): PType = proc toRef*(typ: PType): PType = ## If ``typ`` is a tyObject then it is converted into a `ref <typ>` and ## returned. Otherwise ``typ`` is simply returned as-is. - result = typ - if typ.kind == tyObject: + if typ.skipTypes({tyAlias, tyGenericInst}).kind == tyObject: result = newType(tyRef, typ.owner) rawAddSon(result, typ) @@ -1723,15 +1722,15 @@ proc toObject*(typ: PType): PType = ## If ``typ`` is a tyRef then its immediate son is returned (which in many ## cases should be a ``tyObject``). ## Otherwise ``typ`` is simply returned as-is. - result = typ - if result.kind == tyRef: - result = result.lastSon + let t = typ.skipTypes({tyAlias, tyGenericInst}) + if t.kind == tyRef: t.lastSon + else: typ proc isException*(t: PType): bool = # check if `y` is object type and it inherits from Exception assert(t != nil) - if t.kind != tyObject: + if t.kind notin {tyObject, tyGenericInst}: return false var base = t |