Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Type parameter as type of both attribute and reference
Type parameter as type of both attribute and reference [message #1709701] Wed, 30 September 2015 13:31 Go to next message
Hallvard Traetteberg is currently offline Hallvard TraettebergFriend
Messages: 673
Registered: July 2009
Location: Trondheim, Norway
Senior Member
I have a student who's trying to understand how generics works, and to
test possible limitations we created an EClass with a type paramter T
(Gen<T>) and two features:
- an EAttribute of type T
- an EReference of type T
The EClass validated!

Then we created another EClass wil a feature of type Gen<AnEClass>.
This class also validated, although the type of the feature could not
possibly have an attribute of type AnEClass. We also created a subclass
of Gen specialized to AnEClass (Spec extends Gen<AnEClass>) i.e. Same
story, it validated, but couldn't work, since it needed to have an
attribute of EClass type.

Should this be considered a bug?

Hallvard
--
Hallvard Trætteberg (hal@xxxxxxxx.no)
Associate Professor, IS group, Dept. of Computer and Information
Science at the
Norwegian Univ. of Science and Technology
Re: Type parameter as type of both attribute and reference [message #1710088 is a reply to message #1709701] Sun, 04 October 2015 07:38 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Hallvard,

Comments below.

On 30/09/2015 3:31 PM, Hallvard Trætteberg wrote:
> I have a student who's trying to understand how generics works, and to
> test possible limitations we created an EClass with a type paramter T
> (Gen<T>) and two features:
> - an EAttribute of type T
> - an EReference of type T
> The EClass validated!
I suppose something should check that some type argument could be
provided that would result in a consistent interpretation.
>
> Then we created another EClass wil a feature of type Gen<AnEClass>.
I suppose something should at least check that the actual arguments
result in a consistent interpretation.
> This class also validated, although the type of the feature could not
> possibly have an attribute of type AnEClass. We also created a
> subclass of Gen specialized to AnEClass (Spec extends Gen<AnEClass>)
> i.e. Same story, it validated, but couldn't work, since it needed to
> have an attribute of EClass type.
Likewise for this.

I wonder what's generated and what fails at runtime instead...
>
> Should this be considered a bug?
It sounds like something that could/should be detected earlier.
>
> Hallvard


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Is in-memory output possible with ATL/EMFTVM ?
Next Topic:Renaming a Resource opened in Editor
Goto Forum:
  


Current Time: Thu Mar 28 16:49:12 GMT 2024

Powered by FUDForum. Page generated in 0.02615 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top