diff options
Diffstat (limited to 'compiler/isolation_check.nim')
-rw-r--r-- | compiler/isolation_check.nim | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/compiler/isolation_check.nim b/compiler/isolation_check.nim index 5fd1b8d51..17fbde29e 100644 --- a/compiler/isolation_check.nim +++ b/compiler/isolation_check.nim @@ -11,7 +11,9 @@ ## https://github.com/nim-lang/RFCs/issues/244 for more details. import - ast, types, renderer, intsets + ast, types, renderer + +import std/intsets when defined(nimPreviewSlimSystem): import std/assertions @@ -52,18 +54,18 @@ proc canAlias(arg, ret: PType; marker: var IntSet): bool = of tyObject: if isFinal(ret): result = canAliasN(arg, ret.n, marker) - if not result and ret.len > 0 and ret[0] != nil: - result = canAlias(arg, ret[0], marker) + if not result and ret.baseClass != nil: + result = canAlias(arg, ret.baseClass, marker) else: result = true of tyTuple: result = false - for i in 0..<ret.len: - result = canAlias(arg, ret[i], marker) + for r in ret.kids: + result = canAlias(arg, r, marker) if result: break of tyArray, tySequence, tyDistinct, tyGenericInst, tyAlias, tyInferred, tySink, tyLent, tyOwned, tyRef: - result = canAlias(arg, ret.lastSon, marker) + result = canAlias(arg, ret.skipModifier, marker) of tyProc: result = ret.callConv == ccClosure else: @@ -117,14 +119,16 @@ proc containsDangerousRefAux(t: PType; marker: var IntSet): SearchResult = if result != NotFound: return result case t.kind of tyObject: - if t[0] != nil: - result = containsDangerousRefAux(t[0].skipTypes(skipPtrs), marker) + if t.baseClass != nil: + result = containsDangerousRefAux(t.baseClass.skipTypes(skipPtrs), marker) if result == NotFound: result = containsDangerousRefAux(t.n, marker) of tyGenericInst, tyDistinct, tyAlias, tySink: - result = containsDangerousRefAux(lastSon(t), marker) - of tyArray, tySet, tyTuple, tySequence: - for i in 0..<t.len: - result = containsDangerousRefAux(t[i], marker) + result = containsDangerousRefAux(skipModifier(t), marker) + of tyArray, tySet, tySequence: + result = containsDangerousRefAux(t.elementType, marker) + of tyTuple: + for a in t.kids: + result = containsDangerousRefAux(a, marker) if result == Found: return result else: discard |