ORC: improvements (#17993)

* ORC: improvements
* ORC: fix .acyclic annotation for ref objects
This commit is contained in:
Andreas Rumpf 2021-05-12 07:15:05 +02:00 • committed by GitHub
commit 39ad9a69a9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 18 additions and 12 deletions

View file

@ -854,7 +854,7 @@ proc addInheritedFields(c: PContext, check: var IntSet, pos: var int,
addInheritedFields(c, check, pos, obj[0].skipGenericInvocation)
addInheritedFieldsAux(c, check, pos, obj.n)
proc semObjectNode(c: PContext, n: PNode, prev: PType; isInheritable: bool): PType =
proc semObjectNode(c: PContext, n: PNode, prev: PType; flags: TTypeFlags): PType =
if n.len == 0:
return newConstraint(c, tyObject)
var check = initIntSet()
@ -890,8 +890,9 @@ proc semObjectNode(c: PContext, n: PNode, prev: PType; isInheritable: bool): PTy
if n.kind != nkObjectTy: internalError(c.config, n.info, "semObjectNode")
result = newOrPrevType(tyObject, prev, c)
rawAddSon(result, realBase)
if realBase == nil and isInheritable:
if realBase == nil and tfInheritable in flags:
result.flags.incl tfInheritable
if tfAcyclic in flags: result.flags.incl tfAcyclic
if result.n.isNil:
result.n = newNodeI(nkRecList, n.info)
else:
@ -916,8 +917,8 @@ proc semAnyRef(c: PContext; n: PNode; kind: TTypeKind; prev: PType): PType =
let n = if n[0].kind == nkBracket: n[0] else: n
checkMinSonsLen(n, 1, c.config)
let body = n.lastSon
var t = if prev != nil and body.kind == nkObjectTy and tfInheritable in prev.flags:
semObjectNode(c, body, nil, isInheritable=true)
var t = if prev != nil and body.kind == nkObjectTy:
semObjectNode(c, body, nil, prev.flags)
else:
semTypeNode(c, body, nil)
if t.kind == tyTypeDesc and tfUnresolved notin t.flags:
@ -1957,7 +1958,7 @@ proc semTypeNode(c: PContext, n: PNode, prev: PType): PType =
localError(c.config, n.info, "type expected, but got symbol '$1' of kind '$2'" %
[s.name.s, s.kind.toHumanStr])
result = newOrPrevType(tyError, prev, c)
of nkObjectTy: result = semObjectNode(c, n, prev, isInheritable=false)
of nkObjectTy: result = semObjectNode(c, n, prev, {})
of nkTupleTy: result = semTuple(c, n, prev)
of nkTupleClassTy: result = newConstraint(c, tyTuple)
of nkTypeClassTy: result = semTypeClass(c, n, prev)