Skip to content

Commit

Permalink
Fix Invariant<Out<In<K>>> returns variance checking
Browse files Browse the repository at this point in the history
  • Loading branch information
autaut03 committed Jul 11, 2022
1 parent fd5fa82 commit 3d7710a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/Type/Generic/TemplateTypeVariance.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ public function compose(self $other): self
return self::createInvariant();
}

if ($this->invariant()) {
return self::createInvariant();
}

return $other;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public function testRule(): void
152,
],
[
'Template type K is declared as covariant, but occurs in contravariant position in parameter l of method MethodSignatureVariance\C::a().',
'Template type K is declared as covariant, but occurs in invariant position in parameter l of method MethodSignatureVariance\C::a().',
152,
],
[
Expand Down Expand Up @@ -158,11 +158,11 @@ public function testRule(): void
182,
],
[
'Template type K is declared as covariant, but occurs in contravariant position in return type of method MethodSignatureVariance\C::l().',
'Template type K is declared as covariant, but occurs in invariant position in return type of method MethodSignatureVariance\C::l().',
185,
],
[
'Template type K is declared as covariant, but occurs in contravariant position in return type of method MethodSignatureVariance\C::m().',
'Template type K is declared as covariant, but occurs in invariant position in return type of method MethodSignatureVariance\C::m().',
188,
],
]);
Expand Down

0 comments on commit 3d7710a

Please sign in to comment.