Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(405)

Delta Between Two Patch Sets: cmd/vet/types.go

Issue 12507043: code review 12507043: cmd/vet: add an "unused" module (Closed)
Left Patch Set: Created 11 years, 8 months ago
Right Patch Set: diff -r 400755f06d55 https://code.google.com/p/go.tools Created 11 years, 7 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
1 // Copyright 2010 The Go Authors. All rights reserved. 1 // Copyright 2010 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // This file contains the pieces of the tool that use typechecking from the go/t ypes package. 5 // This file contains the pieces of the tool that use typechecking from the go/t ypes package.
6 6
7 package main 7 package main
8 8
9 import ( 9 import (
10 "go/ast" 10 "go/ast"
(...skipping 15 matching lines...) Expand all
26 // past the first error. There is no need for that function to do anythi ng. 26 // past the first error. There is no need for that function to do anythi ng.
27 config := types.Config{ 27 config := types.Config{
28 Error: func(error) {}, 28 Error: func(error) {},
29 } 29 }
30 info := &types.Info{ 30 info := &types.Info{
31 Types: pkg.types, 31 Types: pkg.types,
32 Values: pkg.values, 32 Values: pkg.values,
33 Objects: pkg.idents, 33 Objects: pkg.idents,
34 Implicits: pkg.implicits, 34 Implicits: pkg.implicits,
35 } 35 }
36 » _, err := config.Check(pkg.path, fs, astFiles, info) 36 » var err error
37 » pkg.typesPackage, err = config.Check(pkg.path, fs, astFiles, info)
37 // Update spans. 38 // Update spans.
38 for id, obj := range pkg.idents { 39 for id, obj := range pkg.idents {
39 pkg.growSpan(id, obj) 40 pkg.growSpan(id, obj)
40 } 41 }
41 return err 42 return err
42 } 43 }
43 44
44 // isStruct reports whether the composite literal c is a struct. 45 // isStruct reports whether the composite literal c is a struct.
45 // If it is not (probably a struct), it returns a printable form of the type. 46 // If it is not (probably a struct), it returns a printable form of the type.
46 func (pkg *Package) isStruct(c *ast.CompositeLit) (bool, string) { 47 func (pkg *Package) isStruct(c *ast.CompositeLit) (bool, string) {
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 return false 279 return false
279 } 280 }
280 // Finally the real questions. 281 // Finally the real questions.
281 // There must be one result. 282 // There must be one result.
282 if sig.Results().Len() != 1 { 283 if sig.Results().Len() != 1 {
283 return false 284 return false
284 } 285 }
285 // It must have return type "string" from the universe. 286 // It must have return type "string" from the universe.
286 return sig.Results().At(0).Type() == types.Typ[types.String] 287 return sig.Results().At(0).Type() == types.Typ[types.String]
287 } 288 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b