Last active
June 21, 2023 08:59
-
-
Save gabrielgarciagava/61a4d13af42ac7e6749333728587fa08 to your computer and use it in GitHub Desktop.
Generics infer issue
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
void main() { | |
// This works fine | |
// final Base myImpl = Impl(); | |
// This creates a compilation error in line 10 | |
final myImpl = Impl(); | |
final myGenerics = buildGenerics(myImpl); | |
print(myGenerics.value == myImpl); | |
print(foo(myGenerics, myImpl)); | |
} | |
Generics<Base> buildGenerics(Base s) => Generics(s); | |
bool foo<G extends Generics<V>, V>(G g, V v) { | |
return g.value == v; | |
} | |
class Generics<T> { | |
Generics(this.value); | |
T value; | |
} | |
class Base {} | |
class Impl implements Base { | |
const Impl(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment