You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2021/10/05 15:20:00 UTC
[jira] [Work logged] (LANG-1674) Range construction with
abstract/derived classes
[ https://issues.apache.org/jira/browse/LANG-1674?focusedWorklogId=660384&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-660384 ]
ASF GitHub Bot logged work on LANG-1674:
----------------------------------------
Author: ASF GitHub Bot
Created on: 05/Oct/21 15:19
Start Date: 05/Oct/21 15:19
Worklog Time Spent: 10m
Work Description: singhbaljit opened a new pull request #810:
URL: https://github.com/apache/commons-lang/pull/810
See https://issues.apache.org/jira/browse/LANG-1674.
The constructors for `org.apache.commons.lang3.Range` don't play nicely with abstract/derived classes. Example:
```java
abstract class AbstractComparable implements Comparable<AbstractComparable> {
@Override public int compareTo(AbstractComparable o) {}
}
class DerivedA extends AbstractComparable {}
class DerivedB extends AbstractComparable {}
// compiles, and reasonable since AbstractComparable is the common parent
static final Range<AbstractComparable> RANGE_MIXED = Range.between(new DerivedA(), new DerivedB());
// compiles, but unreasonable to force usage of parent class
static final Range<AbstractComparable> RANGE_SAME_CLASS = Range.between(new DerivedA(), new DerivedA());
// compiler error
static final Range<DerivedA> RANGE_A = Range.between(new DerivedA(), new DerivedA());
// compiler error
static final Range<DerivedB> RANGE_B = Range.is(new DerivedB());
```
This PR will fix the compiler errors.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Issue Time Tracking
-------------------
Worklog Id: (was: 660384)
Remaining Estimate: 0h
Time Spent: 10m
> Range construction with abstract/derived classes
> ------------------------------------------------
>
> Key: LANG-1674
> URL: https://issues.apache.org/jira/browse/LANG-1674
> Project: Commons Lang
> Issue Type: Improvement
> Reporter: Baljit Singh
> Priority: Minor
> Time Spent: 10m
> Remaining Estimate: 0h
>
> The constructors for {{org.apache.commons.lang3.Range}} don't play nicely with abstract/derived classes. Example:
> {quote}
> abstract class AbstractComparable implements Comparable<AbstractComparable> {
> @Override public int compareTo(AbstractComparable o) {}
> }
> class DerivedA extends AbstractComparable {}
> class DerivedB extends AbstractComparable {}
> // compiles, and reasonable since AbstractComparable is the common parent
> static final Range<AbstractComparable> RANGE_MIXED = Range.between(new DerivedA(), new DerivedB());
> // compiles, but unreasonable to force usage of parent class
> static final Range<AbstractComparable> RANGE_SAME_CLASS = Range.between(new DerivedA(), new DerivedA());
> // compiler error
> static final Range<DerivedA> RANGE_A = Range.between(new DerivedA(), new DerivedA());
> // compiler error
> static final Range<DerivedB> RANGE_B = Range.is(new DerivedB());
> {quote}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)