trace = false // turn on for detailed type resolution traces
)
-// If Strict is set, the type-checker enforces additional
+// If forceStrict is set, the type-checker enforces additional
// rules not specified by the Go 1 spec, but which will
// catch guaranteed run-time errors if the respective
// code is executed. In other words, programs passing in
-// Strict mode are Go 1 compliant, but not all Go 1 programs
-// will pass in Strict mode. The additional rules are:
+// strict mode are Go 1 compliant, but not all Go 1 programs
+// will pass in strict mode. The additional rules are:
//
// - A type assertion x.(T) where T is an interface type
// is invalid if any (statically known) method that exists
// for both x and T have different signatures.
//
-const strict = false
+const forceStrict = false
// exprInfo stores information about an untyped expression.
type exprInfo struct {
pkg *Package
*Info
version version // accepted language version
+ nextId uint64 // unique Id for type parameters (first valid Id is 1)
objMap map[Object]*declInfo // maps package-level objects and (non-interface) methods to declaration info
impMap map[importKey]*Package // maps (import path, source directory) to (complete or fake) package
posMap map[*Interface][]token.Pos // maps interface types to lists of embedded interface positions
+ typMap map[string]*Named // maps an instantiated named type hash to a *Named type
pkgCnt map[string]int // counts number of imported packages with a given name (for better error messages)
// information collected during type-checking of a set of package files
pkg: pkg,
Info: info,
version: version,
+ nextId: 1,
objMap: make(map[Object]*declInfo),
impMap: make(map[importKey]*Package),
posMap: make(map[*Interface][]token.Pos),
+ typMap: make(map[string]*Named),
pkgCnt: make(map[string]int),
}
}
check.recordUntyped()
+ if check.Info != nil {
+ sanitizeInfo(check.Info)
+ }
+
check.pkg.complete = true
// TODO(rFindley) There's more memory we should release at this point.
}
}
+func (check *Checker) recordInferred(call ast.Expr, targs []Type, sig *Signature) {
+ assert(call != nil)
+ assert(sig != nil)
+ if m := check.Inferred; m != nil {
+ m[call] = Inferred{targs, sig}
+ }
+}
+
func (check *Checker) recordDef(id *ast.Ident, obj Object) {
assert(id != nil)
if m := check.Defs; m != nil {