Skip to content

Commit dcfea5c

Browse files
jamesjwufacebook-github-bot
authored andcommitted
Create OngoingRelease status for preview features, set diamond trait reuse to ongoingrelase
Summary: This diff adds a new OngoingRelease enum in preview features that turns on unstable feature checking in rust_parser_errors for the runtime but not the typechecker. Once you have a feature in this state, the typechecker will still enforce it. After HHVM is released, you can then remove any use of `check_can_use_feature` for your feature. This will turn off typechecker enforcement. After that, be warned that there may still be file attributes left in www from previewing. Feature implementers will need to clean those up in www first before removing their feature from the UnstableFeatures enum altogether. Reviewed By: francesco-zappa-nardelli Differential Revision: D40182173 fbshipit-source-id: cbdeaa9aefde948d78054d461192ac40712bd25d
1 parent 7e52b43 commit dcfea5c

17 files changed

+42
-14
lines changed

hphp/hack/src/parser/rust_parser_errors.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ enum FeatureStatus {
7373
Preview,
7474
Migration,
7575
Deprecated,
76+
OngoingRelease,
7677
// TODO: add other modes like "Advanced" or "Deprecated" if necessary.
7778
// Those are just variants of "Preview" for the runtime's sake, though,
7879
// and likely only need to be distinguished in the lint rule rather than here
@@ -121,7 +122,7 @@ impl UnstableFeatures {
121122
UnstableFeatures::TypeConstSuperBound => Unstable,
122123
UnstableFeatures::ClassConstDefault => Migration,
123124
UnstableFeatures::TypeRefinements => Unstable,
124-
UnstableFeatures::MethodTraitDiamond => Preview,
125+
UnstableFeatures::MethodTraitDiamond => OngoingRelease,
125126
UnstableFeatures::UpcastExpression => Unstable,
126127
UnstableFeatures::RequireClass => Preview,
127128
UnstableFeatures::EnumClassTypeConstants => Unstable,
@@ -1251,7 +1252,12 @@ impl<'a, State: 'a + Clone> ParserErrors<'a, State> {
12511252
}
12521253

12531254
_ => false,
1254-
} || self.env.context.active_unstable_features.contains(feature);
1255+
} || self.env.context.active_unstable_features.contains(feature)
1256+
// Preview features with an ongoing release should be allowed by the
1257+
// runtime, but not the typechecker
1258+
|| (feature.get_feature_status() == FeatureStatus::OngoingRelease
1259+
&& self.env.codegen);
1260+
12551261
if !enabled {
12561262
self.errors.push(make_error_from_node(
12571263
node,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
File "trait_diamond_no_attribute.php", line 15, characters 1-30:
2+
Cannot use unstable feature: `method_trait_diamond` (Parsing[1002])
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?hh
2+
<<file:__EnableUnstableFeatures('method_trait_diamond')>>
3+
4+
trait MyTrait1 {
5+
public function testFun(): void {}
6+
}
7+
trait MyTrait2 {
8+
use MyTrait1;
9+
}
10+
11+
<<__EnableMethodTraitDiamond>>
12+
class MyClass {
13+
use MyTrait1;
14+
use MyTrait2;
15+
}
16+
17+
<<__EntryPoint>>
18+
function foo(): void {
19+
echo "Done!\n";
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Done!

hphp/test/slow/traits/diamond_use/diamond_use1.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?hh
22
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
33

4-
<<file:__EnableUnstableFeatures('method_trait_diamond')>>
4+
55

66
trait T {
77
public function foo() : void {

hphp/test/slow/traits/diamond_use/diamond_use2.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?hh
22
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
33

4-
<<file:__EnableUnstableFeatures('method_trait_diamond')>>
4+
55

66
trait T {
77
public function foo() : void {

hphp/test/slow/traits/diamond_use/diamond_use3.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?hh
22
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
33

4-
<<file:__EnableUnstableFeatures('method_trait_diamond')>>
4+
55

66
trait T {
77
public function foo() : void {

hphp/test/slow/traits/diamond_use/diamond_use4.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?hh
22
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
33

4-
<<file:__EnableUnstableFeatures('method_trait_diamond')>>
4+
55

66
trait T {
77
public function foo() : void {

hphp/test/slow/traits/diamond_use/diamond_use5.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?hh
22
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
33

4-
<<file:__EnableUnstableFeatures('method_trait_diamond')>>
4+
55

66
trait T {
77
public function foo() : void {

hphp/test/slow/traits/diamond_use/diamond_use6.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?hh
22
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
33

4-
<<file:__EnableUnstableFeatures('method_trait_diamond')>>
4+
55

66
trait T {
77
public function foo() : void {

hphp/test/slow/traits/diamond_use/diamond_use7.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?hh
22
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
33

4-
<<file:__EnableUnstableFeatures('method_trait_diamond')>>
4+
55

66
trait T {
77
public function foo() : void {

hphp/test/slow/traits/diamond_use/diamond_use_const.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?hh
22
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
33

4-
<<file:__EnableUnstableFeatures('method_trait_diamond')>>
4+
55

66
class C {
77
const int X = 1;

hphp/test/slow/traits/diamond_use/diamond_use_final1.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?hh
22
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
33

4-
<<file:__EnableUnstableFeatures('method_trait_diamond')>>
4+
55

66
trait T {
77
public final function foo() : void {

hphp/test/slow/traits/diamond_use/diamond_use_final2.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?hh
22
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
33

4-
<<file:__EnableUnstableFeatures('method_trait_diamond')>>
4+
55

66
trait T {
77
public final function foo() : void {

hphp/test/slow/traits/diamond_use/diamond_use_no_attribute_2.php.expectf

-1
This file was deleted.

hphp/test/slow/traits/diamond_use/diamond_use_static1.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?hh
22
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
33

4-
<<file:__EnableUnstableFeatures('method_trait_diamond')>>
4+
55

66
trait T {
77
public static function foo() : void {

0 commit comments

Comments
 (0)