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

Bug 357392

Summary: JavaTypeImpl with clazz=java.lang.String doesn't match StringTypeImpl
Product: [Modeling] M2T Reporter: Ali AKAR <ali.akar82>
Component: XpandAssignee: Karsten Thoms <karsten.thoms>
Status: CLOSED FIXED QA Contact:
Severity: major    
Priority: P3 CC: karsten.thoms, r.sezestre, stephaneberle9, sven.efftinge
Version: 1.1.0Flags: karsten.thoms: juno+
Target Milestone: M2   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Attachments:
Description Flags
patch for bug 357392 sven.efftinge: iplog+

Description Ali AKAR CLA 2011-09-12 10:57:34 EDT
From the xtend/xpand file the type of my feature is StringTypeImpl and from the Ecore it's a JavaTypeImpl where the clazz attribute is a java.lang.String. In my Ecore the type of the feature is not an EString, but an Identifier with the instanceclassname is a java.lang.String. 

That's why features are not found when compiling an xtend file.

I have modified JavaTypeImpl#internalIsAssignableFrom(final Type t) to the code below:

@Override
    protected boolean internalIsAssignableFrom(final Type t) {
        if (t instanceof JavaTypeImpl){
            return clazz.isAssignableFrom(((JavaTypeImpl) t).clazz);
        }else if (t instanceof StringTypeImpl){
        	return clazz.isAssignableFrom(String.class);
        }else if(t instanceof BooleanTypeImpl){
        	return clazz.isAssignableFrom(Boolean.class);
        }else if(t instanceof IntegerTypeImpl){
        	return clazz.isAssignableFrom(Integer.class);
        }else if(t instanceof RealTypeImpl){
        	return clazz.isAssignableFrom(Double.class) || clazz.isAssignableFrom(Float.class);
        }
        return false;
    }

This code resolve my problem but I don't know if it's a good idea to do this at this level.
Comment 1 Sven Efftinge CLA 2011-09-19 04:44:39 EDT
could you please provide a small sample project to reproduce the issue?
Comment 2 Benedikt Niehues CLA 2011-09-26 07:45:35 EDT
Created attachment 204008 [details]
patch for bug 357392

this patches the bug 357392
Comment 3 Ali AKAR CLA 2011-09-26 09:22:25 EDT
OK for the patch !
Comment 4 Karsten Thoms CLA 2011-09-26 11:15:27 EDT
Applied and reviewed the patch. Thanks for submitting.
Comment 5 Karsten Thoms CLA 2013-02-21 08:13:30 EST
Bug resolved before Xpand 1.2 release date => Closing