-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Update inline class syntax tests, add one missing test
- Loading branch information
Showing
30 changed files
with
881 additions
and
118 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,10 +2,16 @@ | |
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
/// @description Helper library for testing inline classes | ||
/// @author [email protected] | ||
// SharedOptions=--enable-experiment=inline-class | ||
|
||
library inline_class_lib; | ||
|
||
int x = 42; | ||
|
||
final inline class FinalInlineClass { | ||
final int x; | ||
const FinalInlineClass([this.x = 0]); | ||
} |
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
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 |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/// along with some rules for elements used in inline class declarations: | ||
/// | ||
/// <inlineClassDeclaration> ::= | ||
/// 'inline' 'class' <typeIdentifier> <typeParameters>? <interfaces>? | ||
/// 'final'? 'inline' 'class' <typeIdentifier> <typeParameters>? <interfaces>? | ||
/// '{' | ||
/// (<metadata> <inlineMemberDeclaration>)* | ||
/// '}' | ||
|
@@ -15,7 +15,6 @@ | |
/// | ||
/// @description Checks that an inline class declaration may contain different | ||
/// constructors | ||
/// | ||
/// @author [email protected] | ||
// SharedOptions=--enable-experiment=inline-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 |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/// along with some rules for elements used in inline class declarations: | ||
/// | ||
/// <inlineClassDeclaration> ::= | ||
/// 'inline' 'class' <typeIdentifier> <typeParameters>? <interfaces>? | ||
/// 'final'? 'inline' 'class' <typeIdentifier> <typeParameters>? <interfaces>? | ||
/// '{' | ||
/// (<metadata> <inlineMemberDeclaration>)* | ||
/// '}' | ||
|
@@ -15,7 +15,6 @@ | |
/// | ||
/// @description Checks that an inline class declaration may contain different | ||
/// constructors with optional parameters | ||
/// | ||
/// @author [email protected] | ||
// SharedOptions=--enable-experiment=inline-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
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 |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/// along with some rules for elements used in inline class declarations: | ||
/// | ||
/// <inlineClassDeclaration> ::= | ||
/// 'inline' 'class' <typeIdentifier> <typeParameters>? <interfaces>? | ||
/// 'final'? 'inline' 'class' <typeIdentifier> <typeParameters>? <interfaces>? | ||
/// '{' | ||
/// (<metadata> <inlineMemberDeclaration>)* | ||
/// '}' | ||
|
@@ -15,7 +15,6 @@ | |
/// | ||
/// @description Checks that an inline class declaration may contain factory | ||
/// constructors | ||
/// | ||
/// @author [email protected] | ||
// SharedOptions=--enable-experiment=inline-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 |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/// along with some rules for elements used in inline class declarations: | ||
/// | ||
/// <inlineClassDeclaration> ::= | ||
/// 'inline' 'class' <typeIdentifier> <typeParameters>? <interfaces>? | ||
/// 'final'? 'inline' 'class' <typeIdentifier> <typeParameters>? <interfaces>? | ||
/// '{' | ||
/// (<metadata> <inlineMemberDeclaration>)* | ||
/// '}' | ||
|
@@ -15,7 +15,6 @@ | |
/// | ||
/// @description Checks that an inline class declaration may contain constant | ||
/// constructors | ||
/// | ||
/// @author [email protected] | ||
// SharedOptions=--enable-experiment=inline-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 |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/// along with some rules for elements used in inline class declarations: | ||
/// | ||
/// <inlineClassDeclaration> ::= | ||
/// 'inline' 'class' <typeIdentifier> <typeParameters>? <interfaces>? | ||
/// 'final'? 'inline' 'class' <typeIdentifier> <typeParameters>? <interfaces>? | ||
/// '{' | ||
/// (<metadata> <inlineMemberDeclaration>)* | ||
/// '}' | ||
|
@@ -15,7 +15,6 @@ | |
/// | ||
/// @description Checks that it is a compile-time error if constant constructor | ||
/// of an inline class is called with not a potentially constant expression | ||
/// | ||
/// @author [email protected] | ||
// SharedOptions=--enable-experiment=inline-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,30 @@ | ||
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
/// @assertion A rule for <inlineClassDeclaration> is added to the grammar, | ||
/// along with some rules for elements used in inline class declarations: | ||
/// | ||
/// <inlineClassDeclaration> ::= | ||
/// 'final'? 'inline' 'class' <typeIdentifier> <typeParameters>? <interfaces>? | ||
/// '{' | ||
/// (<metadata> <inlineMemberDeclaration>)* | ||
/// '}' | ||
/// | ||
/// <inlineMemberDeclaration> ::= <classMemberDefinition> | ||
/// | ||
/// @description Checks that an inline class can be declared as `final` | ||
/// @author [email protected] | ||
// SharedOptions=--enable-experiment=inline-class | ||
|
||
import "../../Utils/expect.dart"; | ||
|
||
final inline class FIC { | ||
final int id; | ||
const FIC(this.id); | ||
} | ||
|
||
main() { | ||
Expect.equals(1, FIC(1).id); | ||
} |
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,119 @@ | ||
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
/// @assertion A rule for <inlineClassDeclaration> is added to the grammar, | ||
/// along with some rules for elements used in inline class declarations: | ||
/// | ||
/// <inlineClassDeclaration> ::= | ||
/// 'final'? 'inline' 'class' <typeIdentifier> <typeParameters>? <interfaces>? | ||
/// '{' | ||
/// (<metadata> <inlineMemberDeclaration>)* | ||
/// '}' | ||
/// | ||
/// <inlineMemberDeclaration> ::= <classMemberDefinition> | ||
/// | ||
/// @description Checks that it is a compile-time error to extend, implement (by | ||
/// non-inline class) or declare a mixin on a `final inline` class even in the | ||
/// same library where it is defined | ||
/// @author [email protected] | ||
// SharedOptions=--enable-experiment=inline-class | ||
|
||
final inline class FinalInlineClass { | ||
final int x; | ||
const FinalInlineClass([this.x = 0]); | ||
} | ||
|
||
class ClassExtendsFinal extends FinalInlineClass {} | ||
// ^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
base class BaseClassExtendsFinal extends FinalInlineClass {} | ||
// ^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
interface class InterfaceClassExtendsFinal extends FinalInlineClass {} | ||
// ^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
final class FinalClassExtendsFinal extends FinalInlineClass {} | ||
// ^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
sealed class SealedClassExtendsFinal extends FinalInlineClass {} | ||
// ^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified const SC(int id): super(id); | ||
|
||
abstract class AbstractClassExtendsFinal extends FinalInlineClass {} | ||
// ^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
abstract base class AbstractBaseClassExtendsFinal extends FinalInlineClass {} | ||
// ^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
abstract interface class AbstractInterfaceClassExtendsFinal extends FinalInlineClass {} | ||
// ^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
abstract final class AbstractFinalClassExtendsFinal extends FinalInlineClass {} | ||
// ^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
mixin class MixinClassExtendsFinal extends FinalInlineClass {} | ||
// ^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
base mixin class BaseMixinClassExtendsFinal extends FinalInlineClass {} | ||
// ^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
abstract mixin class AbstractMixinClassExtendsFinal extends FinalInlineClass {} | ||
// ^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
abstract base mixin class AbstractBaseMixinClassExtendsFinal extends FinalInlineClass {} | ||
// ^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
mixin Mixin on FinalInlineClass {} | ||
// ^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
base mixin BaseMixin on FinalInlineClass {} | ||
// ^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
main() { | ||
print(ClassExtendsFinal); | ||
print(BaseClassExtendsFinal); | ||
print(InterfaceClassExtendsFinal); | ||
print(FinalClassExtendsFinal); | ||
print(SealedClassExtendsFinal); | ||
print(AbstractClassExtendsFinal); | ||
print(AbstractBaseClassExtendsFinal); | ||
print(AbstractInterfaceClassExtendsFinal); | ||
print(AbstractFinalClassExtendsFinal); | ||
print(MixinClassExtendsFinal); | ||
print(BaseMixinClassExtendsFinal); | ||
print(AbstractMixinClassExtendsFinal); | ||
print(AbstractBaseMixinClassExtendsFinal); | ||
print(Mixin); | ||
print(BaseMixin); | ||
} |
Oops, something went wrong.