]> Cypherpunks repositories - gostls13.git/commitdiff
go/types, types2: add isTypeLit predicate
authorRobert Griesemer <gri@golang.org>
Thu, 23 Feb 2023 23:47:44 +0000 (15:47 -0800)
committerGopher Robot <gobot@golang.org>
Sat, 25 Feb 2023 20:14:38 +0000 (20:14 +0000)
Preparation for next CL.

Change-Id: I5ef170a04577d8aea10255e304357bdbea4935a7
Reviewed-on: https://go-review.googlesource.com/c/go/+/470919
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>

src/cmd/compile/internal/types2/predicates.go
src/go/types/predicates.go

index 2e6067652b9ccc8ba26119435bedd60775666dcc..c92c1dc292cf6b39e1f0f04adb4d320310ae9ece 100644 (file)
@@ -64,6 +64,17 @@ func hasName(t Type) bool {
        return false
 }
 
+// isTypeLit reports whether t is a type literal.
+// This includes all non-defined types, but also basic types.
+// isTypeLit may be called with types that are not fully set up.
+func isTypeLit(t Type) bool {
+       switch t.(type) {
+       case *Named, *TypeParam:
+               return false
+       }
+       return true
+}
+
 // isTyped reports whether t is typed; i.e., not an untyped
 // constant or boolean. isTyped may be called with types that
 // are not fully set up.
index 903b1445e99b1cf0f698ebe08ca1f66cdec90b18..cf02a8cab536b819c5f2012604a62aba129fcda0 100644 (file)
@@ -66,6 +66,17 @@ func hasName(t Type) bool {
        return false
 }
 
+// isTypeLit reports whether t is a type literal.
+// This includes all non-defined types, but also basic types.
+// isTypeLit may be called with types that are not fully set up.
+func isTypeLit(t Type) bool {
+       switch t.(type) {
+       case *Named, *TypeParam:
+               return false
+       }
+       return true
+}
+
 // isTyped reports whether t is typed; i.e., not an untyped
 // constant or boolean. isTyped may be called with types that
 // are not fully set up.