Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(199)

Unified Diff: mojom/mojom_parser/mojom/types.go

Issue 1515343002: New Mojom Parser: Validate the use of '&' and '?' (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Revert accidental commit. Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | mojom/mojom_parser/parser/resolution_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojom/mojom_parser/mojom/types.go
diff --git a/mojom/mojom_parser/mojom/types.go b/mojom/mojom_parser/mojom/types.go
index 83cc4f747c1872ac978ae300605535931b4405a7..f723b08eaf548b0d2ea906a4bf06ae1aba0c1694 100644
--- a/mojom/mojom_parser/mojom/types.go
+++ b/mojom/mojom_parser/mojom/types.go
@@ -813,6 +813,21 @@ func (ref *UserTypeRef) validateAfterResolution() error {
if ref.scope != nil && ref.scope.file != nil {
file = ref.scope.file
}
+
+ if ref.IsInterfaceRequest() && ref.resolvedType.Kind() != UserDefinedTypeKindInterface {
+ message := fmt.Sprintf("Invalid interface request specification: %s. %s is not an interface type.",
+ ref.TypeName(), ref.ResolvedType().FullyQualifiedName())
+ message = UserErrorMessage(file, ref.token, message)
+ return fmt.Errorf(message)
+ }
+
+ if ref.Nullable() && ref.resolvedType.Kind() == UserDefinedTypeKindEnum {
+ message := fmt.Sprintf("The type %s is invalid because %s is an enum type and these may not be made nullable.",
+ ref.TypeName(), ref.ResolvedType().FullyQualifiedName())
+ message = UserErrorMessage(file, ref.token, message)
+ return fmt.Errorf(message)
+ }
+
if ref.resolvedType.Kind() != UserDefinedTypeKindEnum {
// A type ref has resolved to a non-enum type. Make sure it is not
// being used as either a map key or a constant declaration. Also
« no previous file with comments | « no previous file | mojom/mojom_parser/parser/resolution_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698