Created
May 28, 2020 09:12
-
-
Save huafu/8237ab5e8b4ca46add5bf5625693c5ec to your computer and use it in GitHub Desktop.
inheritance issues
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract class IQuery {} | |
abstract class IDocument {} | |
abstract class IModel { | |
IQuery buildQuery({ | |
IDocument from, // putting dynamic here doesn't fix the issue | |
int Function(IDocument, IDocument) clientSort, | |
// ... | |
}); | |
} | |
class Query<D extends IDocument> implements IQuery {} | |
abstract class DocumentBase<M extends ModelBase<DocumentBase<M>>> | |
implements IDocument {} | |
abstract class ModelBase<D extends DocumentBase<ModelBase<D>>> | |
implements IModel { | |
Query<D> buildQuery({ | |
D from, | |
int Function(D, D) clientSort, | |
}); | |
} | |
// Without defining it in the base model class: | |
abstract class DocumentBase2<M extends ModelBase2<DocumentBase2<M>>> | |
implements IDocument {} | |
abstract class ModelBase2<D extends DocumentBase2<ModelBase2<D>>> | |
implements IModel {} | |
class User extends DocumentBase2<UserModel> {} | |
class UserModel extends ModelBase2<User> { | |
Query<User> buildQuery({ | |
User from, | |
int Function(User, User) clientSort, | |
}) => null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment