cmd/vet: do not check print-like functions with unknown type

Fixes #15787

Change-Id: I559ba886527b474dbdd44fe884c78973b3012377
Reviewed-on: https://go-review.googlesource.com/23351
Run-TryBot: Rob Pike <r@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
diff --git a/src/cmd/vet/print.go b/src/cmd/vet/print.go
index 07499e6..f4b985c 100644
--- a/src/cmd/vet/print.go
+++ b/src/cmd/vet/print.go
@@ -587,22 +587,24 @@
 func (f *File) checkPrint(call *ast.CallExpr, name string) {
 	firstArg := 0
 	typ := f.pkg.types[call.Fun].Type
-	if typ != nil {
-		if sig, ok := typ.(*types.Signature); ok {
-			if !sig.Variadic() {
-				// Skip checking non-variadic functions.
-				return
-			}
-			params := sig.Params()
-			firstArg = params.Len() - 1
+	if typ == nil {
+		// Skip checking functions with unknown type.
+		return
+	}
+	if sig, ok := typ.(*types.Signature); ok {
+		if !sig.Variadic() {
+			// Skip checking non-variadic functions.
+			return
+		}
+		params := sig.Params()
+		firstArg = params.Len() - 1
 
-			typ := params.At(firstArg).Type()
-			typ = typ.(*types.Slice).Elem()
-			it, ok := typ.(*types.Interface)
-			if !ok || !it.Empty() {
-				// Skip variadic functions accepting non-interface{} args.
-				return
-			}
+		typ := params.At(firstArg).Type()
+		typ = typ.(*types.Slice).Elem()
+		it, ok := typ.(*types.Interface)
+		if !ok || !it.Empty() {
+			// Skip variadic functions accepting non-interface{} args.
+			return
 		}
 	}
 	args := call.Args