No error on use of `unsafe_cast`
[hiphop-php.git] / hphp / hack / test / typecheck / this_datatype1.php
blob5c39beed1f94862525f0dfb9e6b5b6ff4eccbc64
1 <?hh // strict
2 /**
3 * Copyright (c) 2014, Facebook, Inc.
4 * All rights reserved.
6 * This source code is licensed under the MIT license found in the
7 * LICENSE file in the "hack" directory of this source tree.
12 interface DataTypeImplProvider<Timpl> {
13 public function impl(): Timpl;
16 interface DataType<Tk, Tv, Timpl>
17 extends DataTypeImplProvider<Timpl> {
19 public function get(Tk $id): Tv;
22 abstract class AbstractDataType<Tk, Tv> implements DataTypeImplProvider<this> {
23 final static public function at(): DataType<Tk, Tv, this> {
24 invariant_violation('');
27 final public function impl(): this {
28 return $this;
32 class MyThingDataType extends AbstractDataType<int, string> {
33 public function get(int $v): string {
34 return (string)$v;
37 public function customMethod(): void {
41 function myFunc(): string {
42 MyThingDataType::at()->impl()->customMethod();
43 return MyThingDataType::at()->get(1);