Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 363621 - [Xtend 2.1] cannot access object methods for interface types
Summary: [Xtend 2.1] cannot access object methods for interface types
Status: CLOSED FIXED
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: 2.1.0   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: M4   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-11 15:44 EST by Edwin Park CLA
Modified: 2017-09-19 18:12 EDT (History)
2 users (show)

See Also:
sven.efftinge: juno+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Edwin Park CLA 2011-11-11 15:44:01 EST
If you have a value whose type is an interface, you cannot access its Object methods. For instance, the following will result in the error "Couldn't resolve reference to JVMIdentifiableElement 'class'" when attempting to resolve the getClass() method on foo, whose type is the interface List:

	val List foo = new ArrayList()
	foo.^class

However, if the type of the variable is a concrete type (ArrayList in this case), then there is no error:

	val bar = new ArrayList()
	bar.^class

This is a regression in Xtend 2.1; both of the above cases worked without errors in Xtend 2.0.
Comment 1 Sebastian Zarnekow CLA 2011-11-12 09:10:38 EST
This works for me:

val List<String> l = null
l.^class 

Please provide more information and reopen the ticket if the problem persists.
Comment 2 Edwin Park CLA 2011-11-14 15:15:28 EST
Hi Sebastian,

I did some more investigation, and found out that the problem exists only in some rather particular circumstances. If I just have a simple Xtend file with a single method that has any of the code snippets above in it, it works fine. BUT if I introduce another method that appends values to a collection, the error appears. Try the following Xtend class - you should see an error in methodTwo on the ^class accessor:


package foo

import java.util.List
import java.util.HashSet

class Foo {
	
	def methodOne() {
		val strings = new HashSet<String>()
		strings += "a"
	}
	
	def methodTwo() {
		val List<String> l = null
		l.^class
	}
}
Comment 3 Sebastian Zarnekow CLA 2011-11-17 09:17:06 EST
Pushed to master.
Comment 4 Karsten Thoms CLA 2017-09-19 18:02:34 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 5 Karsten Thoms CLA 2017-09-19 18:12:48 EDT
Closing all bugs that were set to RESOLVED before Neon.0