Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 355940 - Xtend2 - Incompatible types
Summary: Xtend2 - Incompatible types
Status: CLOSED FIXED
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 major (vote)
Target Milestone: SR2   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-26 08:17 EDT by Amit Mendapara CLA
Modified: 2017-09-19 17:27 EDT (History)
3 users (show)

See Also:
sebastian.zarnekow: indigo+


Attachments
test project (1.59 KB, application/x-gzip)
2011-08-26 08:20 EDT, Amit Mendapara CLA
no flags Details
screenshot (24.43 KB, image/png)
2011-08-26 08:27 EDT, Amit Mendapara CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Amit Mendapara CLA 2011-08-26 08:17:53 EDT
Build Identifier: I20110613-1736

Xtend2 reports a strange `incompatible types` error within an Xtend class method if we pass instance of that class to some external method defined in pure Java. Let's see an example.

The `Hello.xtend` is:

---------------------
package com.my.hello

class Hello {
	
	String message
	
	def setMessage(String message) {
		this.message = message
	}
	
	override toString() {
		return message
	}
}
---------------------

The `HelloService.java` is:

---------------------
package com.my.hello;

public class HelloService {

	public void say(Hello hello) {
		System.err.println(hello);
	}
}
---------------------

The `Test.xtend` is:

---------------------
package com.my.hello

class Test {
	
	def test() {
		val helloService = new HelloService()
		val hello = new Hello()
		
		hello.message = 'Hello World!'
		
		helloService.say(hello)
	}
}
---------------------

In the `Test.xtend` I am seeing following error at line: 11

Incompatible types. Expected com.my.hello.Hello but was com.my.hello.Hello

I have tested with xtext 2.0.0 as well as 2.0.1

This so critical that we are unable to move ahead with our projects.

Reproducible: Always

Steps to Reproduce:
1. Create a Java project with plugin & xtext nature
2. Add plugin dependency to org.eclipse.xtext.xbase.lib
3. Add plugin dependency to org.eclipse.xtext.xtend2.lib
4. Create all the three files listed in the discription
Comment 1 Amit Mendapara CLA 2011-08-26 08:20:42 EDT
Created attachment 202220 [details]
test project

Here is the test project to reproduce the same error.
Comment 2 Amit Mendapara CLA 2011-08-26 08:27:24 EDT
Created attachment 202223 [details]
screenshot

Here is a screenshot showing the error.
Comment 3 Sven Efftinge CLA 2011-09-06 03:43:14 EDT
We need to make sure that the JVM types use the global scope, i.e. link to shadowing JVMTypes from Xtext's index.
Comment 4 Sebastian Zarnekow CLA 2011-09-14 10:32:07 EDT
Pushed to master.
Comment 5 Karsten Thoms CLA 2017-09-19 17:16:26 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 6 Karsten Thoms CLA 2017-09-19 17:27:52 EDT
Closing all bugs that were set to RESOLVED before Neon.0