From 5f24f721db49662eda7bc88fda574ce7d2557d87 Mon Sep 17 00:00:00 2001 From: David Morgan Date: Thu, 3 Nov 2016 17:53:38 +0100 Subject: [PATCH] Fix generation when a method is called "request". --- lib/service_generator.dart | 3 ++- test/file_generator_test.dart | 2 +- test/service_generator_test.dart | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/service_generator.dart b/lib/service_generator.dart index 811def232..e061240df 100644 --- a/lib/service_generator.dart +++ b/lib/service_generator.dart @@ -166,7 +166,8 @@ class ServiceGenerator { out.addBlock("switch (method) {", "}", () { for (MethodDescriptorProto m in _methodDescriptors) { var methodName = _methodName(m.name); - out.println("case '${m.name}': return $methodName(ctx, request);"); + out.println( + "case '${m.name}': return this.$methodName(ctx, request);"); } out.println("default: " "throw new ArgumentError('Unknown method: \$method');"); diff --git a/test/file_generator_test.dart b/test/file_generator_test.dart index 01ac8eed8..0a9dbfdf4 100644 --- a/test/file_generator_test.dart +++ b/test/file_generator_test.dart @@ -371,7 +371,7 @@ abstract class TestServiceBase extends GeneratedService { Future handleCall(ServerContext ctx, String method, GeneratedMessage request) { switch (method) { - case 'Ping': return ping(ctx, request); + case 'Ping': return this.ping(ctx, request); default: throw new ArgumentError('Unknown method: $method'); } } diff --git a/test/service_generator_test.dart b/test/service_generator_test.dart index e26f9b9f3..a1c773e10 100644 --- a/test/service_generator_test.dart +++ b/test/service_generator_test.dart @@ -28,8 +28,8 @@ abstract class TestServiceBase extends GeneratedService { Future handleCall(ServerContext ctx, String method, GeneratedMessage request) { switch (method) { - case 'AMethod': return aMethod(ctx, request); - case 'AnotherMethod': return anotherMethod(ctx, request); + case 'AMethod': return this.aMethod(ctx, request); + case 'AnotherMethod': return this.anotherMethod(ctx, request); default: throw new ArgumentError('Unknown method: $method'); } }