Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 355940

Summary: Xtend2 - Incompatible types
Product: [Modeling] TMF Reporter: Amit Mendapara <mendapara.amit>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: CLOSED FIXED QA Contact:
Severity: major    
Priority: P3 CC: Holger.Schill, sebastian.zarnekow, sven.efftinge
Version: unspecifiedFlags: sebastian.zarnekow: indigo+
Target Milestone: SR2   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
test project
none
screenshot none

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