question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Covariance / Contravariance for generics?

See original GitHub issue

Seems it doesn’t support in hegel?

class Base {}
class Foo extends Base {}

const fooArr: Array<Foo> = [new Foo()];
const baseArr: Array<Base> = fooArr;

playground

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

7reactions
raveclassiccommented, Jun 12, 2020

It would be so great if Hegel supported explicit variance annotations like it’s done in Scala: https://docs.scala-lang.org/tour/variances.html

1reaction
thecotnecommented, Aug 14, 2020

@leunam217 immutability should be part of type system and should not leak artifacts to production code

you have introduced wrapper class but it is only used for type checking

Read more comments on GitHub >

github_iconTop Results From Across the Web

Understanding Covariance and Contravariance of Generic ...
In this article, we will examine what covariant and contravariant generic types are. We will explain what it means for a generic type...
Read more >
Covariance and Contravariance In Java - DZone
The solution consists in learning how to use two powerful features of Java generics known as covariance and contravariance.
Read more >
Covariance and Contravariance in C# Explained - NDepend
Contravariance is enforced in relation to a particular generic type using in the generic modifier. Contravariance applies to generic parameters type used as ......
Read more >
Scala Generics II: Covariance and Contravariance - Apiumhub
A generic class covariant over its abstract type can receive a parameter type of that type or subtypes of that type. ... The...
Read more >
An introduction to generic types in Java: covariance and ...
Covariance and contravariance produce some interesting outcomes. Covariant types are read-only, while contravariant types are write-only.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found