-
Notifications
You must be signed in to change notification settings - Fork 471
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Solve identical comparison with call-site variance
- Loading branch information
1 parent
322de33
commit 01e5828
Showing
5 changed files
with
75 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Bug10697; | ||
|
||
/** @template T */ | ||
abstract class HelloWorld | ||
{ | ||
public static function foo(): void | ||
{ | ||
if (self::class === static::class) {} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Bug11161; | ||
|
||
/** @template ItemType */ | ||
interface Collection | ||
{ | ||
/** @param ItemType $item */ | ||
public function add(mixed $item): void; | ||
|
||
/** @return ItemType|null */ | ||
public function get(int $index): mixed; | ||
} | ||
|
||
class Comparator | ||
{ | ||
/** | ||
* @param Collection<object> $foo1 | ||
* @param Collection<covariant object> $foo2 | ||
*/ | ||
public static function compare(Collection $foo1, Collection $foo2): bool | ||
{ | ||
return $foo1 === $foo2; | ||
} | ||
} | ||
|
||
/** | ||
* @param Collection<object> $collection | ||
*/ | ||
function test(Collection $collection): bool | ||
{ | ||
return Comparator::compare($collection, $collection); | ||
} |