@@ -453,6 +453,13 @@ func (b *typeCheckBatch) getImportPackage(ctx context.Context, id PackageID) (pk
453
453
}
454
454
455
455
ph := b .handles [id ]
456
+
457
+ // Do a second check for "unsafe" defensively, due to golang/go#60890.
458
+ if ph .m .PkgPath == "unsafe" {
459
+ bug .Reportf ("encountered \" unsafe\" as %s (golang/go#60890)" , id )
460
+ return types .Unsafe , nil
461
+ }
462
+
456
463
data , err := filecache .Get (exportDataKind , ph .key )
457
464
if err == filecache .ErrNotFound {
458
465
// No cached export data: type-check as fast as possible.
@@ -632,13 +639,17 @@ func (b *typeCheckBatch) checkPackage(ctx context.Context, ph *packageHandle) (*
632
639
diagnosticsKind : encodeDiagnostics (pkg .diagnostics ),
633
640
}
634
641
635
- if ph .m .ID != "unsafe" { // unsafe cannot be exported
642
+ if ph .m .PkgPath != "unsafe" { // unsafe cannot be exported
636
643
exportData , err := gcimporter .IExportShallow (pkg .fset , pkg .types )
637
644
if err != nil {
638
645
bug .Reportf ("exporting package %v: %v" , ph .m .ID , err )
639
646
} else {
640
647
toCache [exportDataKind ] = exportData
641
648
}
649
+ } else if ph .m .ID != "unsafe" {
650
+ // golang/go#60890: we should only ever see one variant of the "unsafe"
651
+ // package.
652
+ bug .Reportf ("encountered \" unsafe\" as %s (golang/go#60890)" , ph .m .ID )
642
653
}
643
654
644
655
for kind , data := range toCache {
0 commit comments