Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 342021 - [xbase][typeconformance] TypeConformanceComputer could expose helpful conversion information
Summary: [xbase][typeconformance] TypeConformanceComputer could expose helpful convers...
Status: CLOSED FIXED
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: 2.0.0   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: M6   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 376037
Blocks:
  Show dependency tree
 
Reported: 2011-04-06 09:24 EDT by Sebastian Zarnekow CLA
Modified: 2017-10-31 11:24 EDT (History)
1 user (show)

See Also:
sebastian.zarnekow: kepler+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sebastian Zarnekow CLA 2011-04-06 09:24:21 EDT
TypeConformanceComputer#isConformant(TypeRef left, TypeRef right) may use lot of information to determine, whether the right reference is conformant to the left. It may query the synonym types provider or infer a function type from an interface that defines exactly one method. However, this information is only used and known internally to #isConformant.

There are several use cases that would benefit from something like

TypeConformanceComputer#findConformantType(TypeRef left, TypeRef actualRightType): TypeRef

e.g. type inference for branches or parameterized operations could leverage the expected type in a more advanced fashion.

//==========
val Iterable<Object> closure = [|<Object>newArrayList('a').iterator] // OK
val Iterable<Object> array = newArrayList('a').toArray // OK 
//==========
val Iterable<Object> branch = 
  if (true) 
    [|<Object>newArrayList().iterator]
  else
    newArrayList('a').toArray

The latter is a valid expression but the current inference algorithm will provide 'Object' as the type of the if-expression since it does not know about the applicable conversions for the closure and the array.

The same happens for inference of operation type arguments if a type parameter is used more than once and conversion is necessary to find a compatible type for all occurrences.

Important note:

Please search for a simple workaround for the var args problem in relation to primitives in the TypeArgumentContextProvider. The code is marked with the URL of this ticket.
Comment 1 Dennis Huebner CLA 2013-02-13 02:58:31 EST
Still valid with new TS
Comment 2 Sebastian Zarnekow CLA 2013-03-12 15:01:24 EDT
Pushed to review
Comment 3 Sebastian Zarnekow CLA 2013-03-12 18:25:50 EDT
The change broke the build. If it turns out to be serious issue, this has to be reverted for M6. We have to make sure that a proper error marker is created, though.
Comment 4 Sebastian Zarnekow CLA 2013-03-13 11:01:32 EDT
Merged into master
Comment 5 Eclipse Webmaster CLA 2017-10-31 11:24:25 EDT
Requested via bug 522520.

-M.