Permalink
Browse files

Implementations of abstract methods can have supertype parameter types

Summary:
Currently the case if `force_hh` is on. Make it true for any subclasses in Hack, rather than PHP.

Going to put up a separate diff RE this only applying to abstract functions.

refs #8256

Reviewed By: swtaarrs

Differential Revision: D8868379

fbshipit-source-id: 83f749139c610e6b0546695b6090f0970bf302b5
  • Loading branch information...
fredemmott committed Jul 17, 2018
1 parent 46e5dff commit 2e1ded3341a9298de688bdc9a9f73065373523f9
@@ -188,7 +188,8 @@ bool TypeConstraint::compat(const TypeConstraint& other) const {
const Class* cls = Unit::lookupClass(m_typeName);
const Class* otherCls = Unit::lookupClass(other.m_typeName);
return cls && otherCls && cls == otherCls;
return cls && otherCls && (isHHType() ? otherCls->classof(cls)
: cls == otherCls);
}
return false;
@@ -0,0 +1,22 @@
<?hh // strict
class ParamBase {
}
class ParamSub extends ParamBase {
}
abstract class ImplBase {
abstract public function doStuff(ParamSub $_): void;
}
class ImplSub extends ImplBase {
public function doStuff(ParamBase $_): void {
}
}
function main(): void {
(new ImplSub())->doStuff(new ParamSub());
}
main();

0 comments on commit 2e1ded3

Please sign in to comment.