]> Cypherpunks repositories - gostls13.git/commit
go/types: initial framework for marking-based cycle detection
authorRobert Griesemer <gri@golang.org>
Thu, 24 May 2018 22:39:21 +0000 (15:39 -0700)
committerRobert Griesemer <gri@golang.org>
Thu, 31 May 2018 18:21:18 +0000 (18:21 +0000)
commite57cdd81e25a8351a868679d0d7252928b6e5be4
treedd53ae7d2afb5b2888701b85adb0ec8ea92b8e0e
parent57d40f1b27c0e0a4ca491895a68efc40c7c7d435
go/types: initial framework for marking-based cycle detection

The existing code explicitly passes a (type name) path around
to determine cycles; it also restarts the path for types that
"break" a cycle (such as a pointer, function, etc.). This does
not work for alias types (whose cycles are broken in a different
way). Furthermore, because the path is not passed through all
type checker functions that need it, we can't see the path or
use it for detection of some cycles (e.g. cycles involving array
lengths), which required ad-hoc solutions in those cases.

This change introduces an explicit marking scheme for any kind
of object; an object is painted in various colors indicating
its state. It also introduces an object path (a stack) main-
tained with the Checker state, which is available in all type
checker functions that need access to it.

The change only introduces these mechanisms and exercises the
basic functionality, with no effect on the existing code for
now.

For #25141.

Change-Id: I7c28714bdafe6c8d9afedf12a8a887554237337c
Reviewed-on: https://go-review.googlesource.com/114517
Reviewed-by: Alan Donovan <adonovan@google.com>
src/go/types/check.go
src/go/types/decl.go
src/go/types/object.go
src/go/types/universe.go