From a14d1eef68e6e4db841ff529d5eff0036158037d Mon Sep 17 00:00:00 2001 From: NatashaWso2 Date: Mon, 4 Mar 2019 13:54:55 +0530 Subject: [PATCH 1/2] Remove the check added to validate if Client objects have at least one remote method --- .../org/ballerinalang/util/diagnostic/DiagnosticCode.java | 1 - .../compiler/semantics/analyzer/CodeAnalyzer.java | 4 ---- .../ballerina-lang/src/main/resources/compiler.properties | 3 --- 3 files changed, 8 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/org/ballerinalang/util/diagnostic/DiagnosticCode.java b/compiler/ballerina-lang/src/main/java/org/ballerinalang/util/diagnostic/DiagnosticCode.java index 3f59c2365e5c..047c8f7ba8df 100644 --- a/compiler/ballerina-lang/src/main/java/org/ballerinalang/util/diagnostic/DiagnosticCode.java +++ b/compiler/ballerina-lang/src/main/java/org/ballerinalang/util/diagnostic/DiagnosticCode.java @@ -137,7 +137,6 @@ public enum DiagnosticCode { ENDPOINT_INVALID_TYPE_NO_FUNCTION("endpoint.invalid.type.no.function"), ENDPOINT_SPI_INVALID_FUNCTION("endpoint.spi.invalid.function"), - CLIENT_HAS_NO_REMOTE_FUNCTION("client.has.no.remote.function"), REMOTE_FUNCTION_IN_NON_CLIENT_OBJECT("remote.function.in.non.client.object"), RESOURCE_FUNCTION_IN_NON_SERVICE_OBJECT("resource.function.in.non.service.object"), REMOTE_IN_NON_OBJECT_FUNCTION("remote.in.non.object.function"), diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/CodeAnalyzer.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/CodeAnalyzer.java index 762948956293..926e466b56f4 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/CodeAnalyzer.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/CodeAnalyzer.java @@ -954,10 +954,6 @@ public void visit(BLangObjectTypeNode objectTypeNode) { objectTypeNode.fields.forEach(field -> analyzeNode(field, objectEnv)); } objectTypeNode.functions.forEach(e -> this.analyzeNode(e, objectEnv)); - if (Symbols.isFlagOn(objectTypeNode.symbol.flags, Flags.CLIENT) && objectTypeNode.functions.stream() - .noneMatch(func -> Symbols.isFlagOn(func.symbol.flags, Flags.REMOTE))) { - this.dlog.error(objectTypeNode.pos, DiagnosticCode.CLIENT_HAS_NO_REMOTE_FUNCTION); - } } private void analyseType(BType type, DiagnosticPos pos) { diff --git a/compiler/ballerina-lang/src/main/resources/compiler.properties b/compiler/ballerina-lang/src/main/resources/compiler.properties index 0f7fb39dffdb..10e144d23110 100644 --- a/compiler/ballerina-lang/src/main/resources/compiler.properties +++ b/compiler/ballerina-lang/src/main/resources/compiler.properties @@ -503,9 +503,6 @@ error.service.invalid.endpoint.type=\ error.service.service.type.required.anonymous=\ cannot infer type of the anonymous endpoint, requires a valid service type for service {0} -error.client.has.no.remote.function=\ - client objects requires at least one remote function - error.remote.function.in.non.client.object=\ a remote function in a non client object From 8af7ae8db6d304d45fa4186abc5ee1917c6e0a12 Mon Sep 17 00:00:00 2001 From: NatashaWso2 Date: Mon, 4 Mar 2019 13:59:18 +0530 Subject: [PATCH 2/2] Remove invalid test case --- .../test/endpoint/ClientObjectTest.java | 3 --- .../test-src/endpoint/new/remote_basic_negative.bal | 12 ------------ 2 files changed, 15 deletions(-) diff --git a/tests/ballerina-unit-test/src/test/java/org/ballerinalang/test/endpoint/ClientObjectTest.java b/tests/ballerina-unit-test/src/test/java/org/ballerinalang/test/endpoint/ClientObjectTest.java index bb51ba81c493..dc38fc52c64b 100644 --- a/tests/ballerina-unit-test/src/test/java/org/ballerinalang/test/endpoint/ClientObjectTest.java +++ b/tests/ballerina-unit-test/src/test/java/org/ballerinalang/test/endpoint/ClientObjectTest.java @@ -126,9 +126,6 @@ public void testRemoteBasicsNegative() { BAssertUtil.validateError(compileResult, errIdx++, "a remote function in a non client object", 154, 5); BAssertUtil.validateError(compileResult, errIdx++, "a remote function in a non client object", 163, 5); - BAssertUtil - .validateError(compileResult, errIdx++, "client objects requires at least one remote function", 170, 5); - Assert.assertEquals(compileResult.getErrorCount(), errIdx); } } diff --git a/tests/ballerina-unit-test/src/test/resources/test-src/endpoint/new/remote_basic_negative.bal b/tests/ballerina-unit-test/src/test/resources/test-src/endpoint/new/remote_basic_negative.bal index cc23111e97d0..3a8fa6ea0b3a 100644 --- a/tests/ballerina-unit-test/src/test/resources/test-src/endpoint/new/remote_basic_negative.bal +++ b/tests/ballerina-unit-test/src/test/resources/test-src/endpoint/new/remote_basic_negative.bal @@ -164,18 +164,6 @@ type Baz object { } }; -// client objects requires at least one remote function -type Bax client object { - - function nonAction1(float f) returns string { - return "done"; - } - - function nonAction2(float f) returns string { - return "done"; - } -}; - type dummy object { Foo ff = new;