Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolution of methods with list parameters not working #20

Closed
pjeanjean opened this issue May 18, 2019 · 3 comments
Closed

Resolution of methods with list parameters not working #20

pjeanjean opened this issue May 18, 2019 · 3 comments
Assignees

Comments

@pjeanjean
Copy link
Member

When using lists (or sequences in ALE) as parameters for a method, the engine is unable to resolve the right method to use.

For example, the following minimal behavior file:

behavior testale_behavior;

open class ClassA {
	def int mysum(Sequence(Integer) list) {
		result := list->sum();
	}
	
	@main
	def void run() {
		Sequence(Integer) list := Sequence{1, 2, 3};
		self.mysum(list).log();
	}
}

Returns the following output:

Couldn't find the 'mysum(EClassifier=ClassA,java.util.ArrayList)' service
@dvojtise
Copy link
Contributor

Not only the method cannot be called, but internally, the parameter cannot be used properly.
various error occurs

some example:

image

@dvojtise
Copy link
Contributor

or
image

@echebbi echebbi added affect: interpreter affect: validators Related to Xtext validators labels Oct 9, 2019
@echebbi echebbi self-assigned this Oct 14, 2019
@echebbi
Copy link
Collaborator

echebbi commented Oct 14, 2019

It looks like the issue only occurs when the Sequence is declared within an operation. e.g. the following code is correctly checked & interpreted:

behavior helloworld;

open class HelloWorld {
	
    Sequence(Integer) list;
	
    def int mysum(Sequence(Integer) list) {
        result := list->sum();
    }
	
    @main
    def void run() {
        self.list := Sequence{1, 2, 3};
        self.mysum(self.list).log();
    }
}

Note: The assignation result := list->sum() is not handled by the TypeChecker(Expected [ecore::EInt] but was [Nothing(Sum can only be used on a collection of numbers.)), but that seems to be another bug.

echebbi added a commit that referenced this issue Oct 14, 2019
Because:
 - Sequences declared in operations could not be used as arguments of
   other operations (that was causing an error at runtime).

How:
 - Sequences in extension (e.g. Sequence{1, 2, 3}) are evaluated by AQL
   as ArrayList instances. Hence, sequences declared in operations with
   the extension syntax were assigned an ArrayList value, whereas they
   are expecting to hold an EList instance.
echebbi added a commit that referenced this issue Nov 22, 2019
Why:
 - unable to call a method taking a Sequence as parameters
 - unable to use a parameter of type Sequence within an operation

How:
 - store method parameters' generic type when building the AST
 - turn signature of methods expecting Sequence into 'foo(Sequence<T>)' instead of 'foo(EList<T>)'

Signed-off-by: Emmanuel Chebbi <emmanuel.chebbi@outlook.fr>
echebbi added a commit that referenced this issue Nov 22, 2019
Why:
 - unable to call a method taking a Sequence as parameters
 - unable to use a parameter of type Sequence within an operation

How:
 - store method parameters' generic type when building the AST
 - turn signature of methods expecting Sequence into 'foo(Sequence<T>)' instead of 'foo(EList<T>)'

Signed-off-by: Emmanuel Chebbi <emmanuel.chebbi@outlook.fr>
dvojtise pushed a commit that referenced this issue Dec 6, 2019
Why:
 - unable to call a method taking a Sequence as parameters
 - unable to use a parameter of type Sequence within an operation

How:
 - store method parameters' generic type when building the AST
 - turn signature of methods expecting Sequence into 'foo(Sequence<T>)' instead of 'foo(EList<T>)'

Signed-off-by: Emmanuel Chebbi <emmanuel.chebbi@outlook.fr>
@echebbi echebbi closed this as completed Dec 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants