]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.typealias] go/types: remove some more vestiges of prior alias implementation
authorRobert Griesemer <gri@golang.org>
Thu, 22 Dec 2016 17:48:43 +0000 (09:48 -0800)
committerRobert Griesemer <gri@golang.org>
Tue, 10 Jan 2017 20:30:21 +0000 (20:30 +0000)
For #18130.

Change-Id: Ibec8efd158d32746978242910dc71e5ed23e9d91
Reviewed-on: https://go-review.googlesource.com/35092
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
src/go/types/api_test.go
src/go/types/call.go

index 1208eb8b3a1641af38c7558ed4c3a118acb7ef90..92c6d75e704fbefd5fa69433672365746171da8d 100644 (file)
@@ -1295,155 +1295,3 @@ func f(x int) { y := x; print(y) }
                }
        }
 }
-
-// Alias-related code. Keep for now.
-/*
-func TestAliases(t *testing.T) {
-       testenv.MustHaveGoBuild(t)
-
-       const src = `
-package b
-
-import (
-       "./testdata/alias"
-       a "./testdata/alias"
-       "math"
-)
-
-const (
-       c1 = alias.Pi1
-       c2 => a.Pi1
-       c3 => a.Pi2
-       c4 => math.Pi
-)
-
-var (
-       v1 => alias.Default
-       v2 => a.Default
-       v3 = f1
-)
-
-type (
-       t1 => alias.Context
-       t2 => a.Context
-)
-
-func f1 => alias.Sin
-func f2 => a.Sin
-
-func _() {
-       assert(c1 == alias.Pi1 && c2 == a.Pi1 && c3 == a.Pi2 && c4 == math.Pi)
-       assert(c2 == c2 && c2 == c3 && c3 == c4)
-       v1 = v2 // must be assignable
-       var _ *t1 = new(t2) // must be assignable
-       var _ t2 = alias.Default
-       f1(1) // must be callable
-       f2(1)
-       _ = alias.Sin(1)
-       _ = a.Sin(1)
-}
-`
-
-       if out := compile(t, "testdata", "alias.go"); out != "" {
-               defer os.Remove(out)
-       }
-
-       DefPredeclaredTestFuncs() // declare assert built-in for testing
-       mustTypecheck(t, "Aliases", src, nil)
-}
-
-func compile(t *testing.T, dirname, filename string) string {
-       cmd := exec.Command(testenv.GoToolPath(t), "tool", "compile", filename)
-       cmd.Dir = dirname
-       out, err := cmd.CombinedOutput()
-       if err != nil {
-               t.Logf("%s", out)
-               t.Fatalf("go tool compile %s failed: %s", filename, err)
-       }
-       // filename should end with ".go"
-       return filepath.Join(dirname, filename[:len(filename)-2]+"o")
-}
-
-func TestAliasDefUses(t *testing.T) {
-       testenv.MustHaveGoBuild(t)
-
-       const src = `
-package p
-
-import(
-       "go/build"
-       "go/types"
-)
-
-// Defs
-const Invalid => types.Invalid
-type Struct => types.Struct
-var Default => build.Default
-func Implements => types.Implements
-
-// Uses
-const _ = Invalid
-var _ types.Struct = Struct{} // types must be identical
-var _ build.Context = Default
-var _ = Implements(nil, nil)
-`
-
-       info := Info{
-               Defs: make(map[*ast.Ident]Object),
-               Uses: make(map[*ast.Ident]Object),
-       }
-       mustTypecheck(t, "TestAliasDefUses", src, &info)
-
-       // verify Defs
-       defs := map[string]string{
-               "Invalid":    "types.Invalid",
-               "Struct":     "types.Struct",
-               "Default":    "build.Default",
-               "Implements": "types.Implements",
-       }
-
-       for ident, obj := range info.Defs {
-               if alias, ok := obj.(*Alias); ok {
-                       if want := defs[ident.Name]; want != "" {
-                               orig := alias.Orig()
-                               if got := orig.Pkg().Name() + "." + orig.Name(); got != want {
-                                       t.Errorf("%v: got %v, want %v", ident, got, want)
-                               }
-                               delete(defs, ident.Name) // mark as found
-                       } else {
-                               t.Errorf("unexpected alias def of %v", ident)
-                       }
-               }
-       }
-
-       if len(defs) != 0 {
-               t.Errorf("missing aliases: %v", defs)
-       }
-
-       // verify Uses
-       uses := map[string]string{
-               "Invalid":    "types.Invalid",
-               "Struct":     "types.Struct",
-               "Default":    "build.Default",
-               "Implements": "types.Implements",
-       }
-
-       for ident, obj := range info.Uses {
-               if alias, ok := obj.(*Alias); ok {
-                       if want := uses[ident.Name]; want != "" {
-                               orig := alias.Orig()
-                               if got := orig.Pkg().Name() + "." + orig.Name(); got != want {
-                                       t.Errorf("%v: got %v, want %v", ident, got, want)
-                               }
-                               delete(uses, ident.Name) // mark as found
-                       } else {
-                               t.Errorf("unexpected alias use of %v", ident)
-                       }
-               }
-       }
-
-       if len(uses) != 0 {
-               t.Errorf("missing aliases: %v", defs)
-       }
-}
-*/
index 194b1fea10d7c903ddbaeb6bf5431dceb0fd89a6..7f5823c8295c1aba77f26df51a92e2d4f656994c 100644 (file)
@@ -295,11 +295,6 @@ func (check *Checker) selector(x *operand, e *ast.SelectorExpr) {
                        }
                        check.recordUse(e.Sel, exp)
 
-                       // avoid further errors if the imported object is an alias that's broken
-                       if exp == nil {
-                               goto Error
-                       }
-
                        // Simplified version of the code for *ast.Idents:
                        // - imported objects are always fully initialized
                        switch exp := exp.(type) {