Bug 463672 - [xtend][aa] Consider support of abstract classes by Delegate AA
Summary: [xtend][aa] Consider support of abstract classes by Delegate AA
Status: NEW
Alias: None
Product: Xtend
Classification: Tools
Component: Core (show other bugs)
Version: 2.9.0   Edit
Hardware: PC Mac OS X
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-04-01 08:14 EDT by Anton Kosyakov CLA
Modified: 2015-04-01 09:33 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Anton Kosyakov CLA 2015-04-01 08:14:10 EDT

    
Comment 1 Sebastian Zarnekow CLA 2015-04-01 08:22:40 EDT
Abstract classes may have state which introduces some more complexity when it comes to the decision: override an existing method and delegate, or keep it as inherited. Could you give an example on your usecase?
Comment 2 Anton Kosyakov CLA 2015-04-01 09:33:18 EDT
It is not related only to abstract classes but to wrapping any type in general.

Consider the following case with current logic:
interface Foo {
  def void setValue(String value)
}

class FooImpl implements Foo {
  String value
  def void setValue(String value) {
    this.value = value
  }  
  def getValue() {
    value
  }
}

class Bar extends FooImpl {
  @Delegate
  FooImpl foo
}

In such case one get exactly the same issue which you described:
1. Bar#setValue changes a state of the delegate;
2. Bar.getValue reads a local state.

I was really confused by it when tried to wrap JavaIoFileSystemAccess for Intellij and ended up subclassing. It is not totally correct because if somebody has their own subclass of JavaIoFileSystemAccess, they won't get it in Intellij but rather which I created.

Also sometimes you cannot subclass or extract an interface, for example if an instance is created by some framework, but still want to add new behavior by delegating.

Maybe having some checks will be better than limiting to interfaces?