From 38a7dde1c5dfcbb69f90ee961e6b2583f0928257 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Wed, 18 Mar 2015 08:34:40 +0000 Subject: 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 --- llgo/irgen/compiler.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'llgo/irgen/compiler.go') diff --git a/llgo/irgen/compiler.go b/llgo/irgen/compiler.go index 36d35b78ce2..16769216a0f 100644 --- a/llgo/irgen/compiler.go +++ b/llgo/irgen/compiler.go @@ -102,6 +102,9 @@ type CompilerOptions struct { // DisableUnusedImportCheck disables the unused import check performed // by go/types if set to true. DisableUnusedImportCheck bool + + // Packages is used by go/types as the imported package map if non-nil. + Packages map[string]*types.Package } type Compiler struct { @@ -208,8 +211,9 @@ func (compiler *compiler) compile(fset *token.FileSet, astFiles []*ast.File, imp impcfg := &loader.Config{ Fset: fset, TypeChecker: types.Config{ - Import: compiler.Importer, - Sizes: compiler.llvmtypes, + Packages: compiler.Packages, + Import: compiler.Importer, + Sizes: compiler.llvmtypes, DisableUnusedImportCheck: compiler.DisableUnusedImportCheck, }, Build: &buildctx.Context, -- cgit v1.2.3