llvm-project/llgo/test/llgoi/import-source.test
Peter Collingbourne 38a7dde1c5 llgoi: Fix type identity for imported binary packages.
go/loader creates a fresh package map for each source package it imports. In
llgoi this caused binary imported packages to be imported anew for every input
line, resulting in spurious type errors and panics in go/ssa when encountering
previously imported types. Fix this by setting types.Config.Packages to our
internal package map.

Differential Revision: http://reviews.llvm.org/D8409

llvm-svn: 232617
2015-03-18 08:34:40 +00:00

31 lines
609 B
Plaintext

// RUN: env GOPATH=%S/Inputs llgoi < %s 2>&1 | FileCheck %s
// make sure user symbols do not conflict with imported source package
Answer := 1
import "foo"
// CHECK: # bar
// CHECK: # foo
// Test that importing binary after source works.
import "strconv"
foo.Answer()
// CHECK: #0 int = 42
strconv.FormatBool(true)
// CHECK: #0 string = true
var v1 strconv.NumError
var v2 strconv.NumError
// v1 and v2 should have the same type identity.
// CHECK-NOT: cannot assign
v1 = v2
// Method lookup relies on v1 having a consistent type.
v1.Error
import "foo_cgo"
// CHECK: foo_cgo: cannot load cgo package