Skip to content

Commit

Permalink
Enable syntax-only support for generic functions by default, take 2.
Browse files Browse the repository at this point in the history
Fixed some status entries since the first land-revert of this CL.

This addresses #27501.

[email protected]

Review URL: https://codereview.chromium.org/2520293002 .
  • Loading branch information
eernstg committed Nov 22, 2016
1 parent 3e969cf commit 9bf3b95
Show file tree
Hide file tree
Showing 12 changed files with 17 additions and 26 deletions.
21 changes: 16 additions & 5 deletions pkg/compiler/lib/src/commandline_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,30 @@ class Flags {

static const String conditionalDirectives = '--conditional-directives';

// Experimental flags.

// Considerations about this feature (esp. locations where generalizations
// or changes are required for full support of generic methods) are marked
// with 'GENERIC_METHODS'. The approach taken is to parse generic methods,
// The syntax-only level of support for generic methods is included in the
// 1.50 milestone for Dart. It is not experimental, but also not permanent:
// a full implementation is expected in the future. Hence, the
// 'GENERIC_METHODS' comments which were added when this feature was
// experimental have been preserved, such that it will be easy to find the
// relevant locations to update when generic methods are implemented fully.
//
// The option is still accepted, but it has no effect: The feature is enabled
// by default and it cannot be disabled.
//
// The approach taken in the implementation is to parse generic methods,
// introduce AST nodes for them, generate corresponding types (such that
// front end treatment is consistent with the code that programmers wrote),
// but considering all method type variables to have bound `dynamic` no
// matter which bound they have syntactically (such that their value as types
// is unchecked), and then replacing method type variables by a `DynamicType`
// (such that the backend does not need to take method type arguments into
// account).
//
// The feature has an informal specification which is available at
// https://gist.github.com/eernstg/4353d7b4f669745bed3a5423e04a453c.
static const String genericMethodSyntax = '--generic-method-syntax';

// Experimental flags.
static const String resolveOnly = '--resolve-only';
static const String initializingFormalAccess = '--initializing-formal-access';
}
Expand Down
2 changes: 0 additions & 2 deletions pkg/compiler/lib/src/diagnostics/messages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1221,7 +1221,6 @@ void main() => new C().m(null);
MessageKind.TYPE_VARIABLE_FROM_METHOD_NOT_REIFIED: const MessageTemplate(
MessageKind.TYPE_VARIABLE_FROM_METHOD_NOT_REIFIED,
"Method type variables do not have a runtime value.",
options: const ["--generic-method-syntax"],
howToFix: "Try using the upper bound of the type variable, "
"or refactor the code to avoid needing this runtime value.",
examples: const [
Expand All @@ -1243,7 +1242,6 @@ main() => f<int>(42);
const MessageTemplate(
MessageKind.TYPE_VARIABLE_FROM_METHOD_CONSIDERED_DYNAMIC,
"Method type variables are treated as `dynamic` in `as` expressions.",
options: const ["--generic-method-syntax"],
howToFix: "Try using the upper bound of the type variable, or check "
"that the blind success of the test does not introduce bugs.",
examples: const [
Expand Down
2 changes: 1 addition & 1 deletion pkg/compiler/lib/src/options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ class CompilerOptions implements DiagnosticOptions, ParserOptions {
dumpInfo: _hasOption(options, Flags.dumpInfo),
enableAssertMessage: _hasOption(options, Flags.enableAssertMessage),
enableGenericMethodSyntax:
_hasOption(options, Flags.genericMethodSyntax),
true, // No check for `Flags.genericMethodSyntax`: always enabled.
enableInitializingFormalAccess:
_hasOption(options, Flags.initializingFormalAccess),
enableExperimentalMirrors:
Expand Down
1 change: 0 additions & 1 deletion tests/language/generic_functions_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// 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.
//
// DartOptions=--generic-method-syntax
// VMOptions=--generic-method-syntax

/// Dart test verifying that the parser can handle type parameterization of
Expand Down
1 change: 0 additions & 1 deletion tests/language/generic_local_functions_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// 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.
//
// DartOptions=--generic-method-syntax
// VMOptions=--generic-method-syntax

/// Dart test verifying that the parser can handle type parameterization of
Expand Down
1 change: 0 additions & 1 deletion tests/language/generic_methods_function_type_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// 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.
//
// DartOptions=--generic-method-syntax
// VMOptions=--generic-method-syntax

/// Dart test on the usage of method type arguments in a function typed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// 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.
//
// DartOptions=--generic-method-syntax
// VMOptions=--generic-method-syntax

import "package:expect/expect.dart";
Expand Down
1 change: 0 additions & 1 deletion tests/language/generic_methods_new_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// 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.
//
// DartOptions=--generic-method-syntax
// VMOptions=--generic-method-syntax

/// Dart test on the usage of method type arguments in object creation. With
Expand Down
1 change: 0 additions & 1 deletion tests/language/generic_methods_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// 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.
//
// DartOptions=--generic-method-syntax
// VMOptions=--generic-method-syntax

/// Dart test verifying that the parser can handle type parameterization of
Expand Down
1 change: 0 additions & 1 deletion tests/language/generic_methods_type_expression_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// 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.
//
// DartOptions=--generic-method-syntax
// VMOptions=--generic-method-syntax

/// Dart test on the usage of method type arguments in type expressions. With
Expand Down
1 change: 0 additions & 1 deletion tests/language/generic_sends_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// 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.
//
// DartOptions=--generic-method-syntax
// VMOptions=--generic-method-syntax

/// Dart test verifying that the parser can handle certain cases where
Expand Down
10 changes: 0 additions & 10 deletions tests/language/language_dart2js.status
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,6 @@ async_star_no_cancel2_test: RuntimeError # Need triage
[ $compiler == dart2js && $browser ]
config_import_test: Fail # Test flag is not passed to the compiler.

# Experimental feature: Syntactic support for generic methods.
generic_functions_test: CompileTimeError # DartOptions not passed to compiler.
generic_local_functions_test: CompileTimeError # DartOptions not passed to compiler.
generic_methods_test: CompileTimeError # DartOptions not passed to compiler.
generic_sends_test: CompileTimeError # DartOptions not passed to compiler.
generic_methods_new_test: CompileTimeError # DartOptions not passed to compiler.
generic_methods_function_type_test: CompileTimeError # DartOptions not passed to compiler.
generic_methods_type_expression_test: CompileTimeError # DartOptions not passed to compiler.
generic_methods_generic_function_parameter_test: CompileTimeError # DartOptions not passed to compiler.

# Experimental feature: Use initializing formals in initializers and constructor body.
initializing_formal_access_test: CompileTimeError # DartOptions not passed to compiler.
initializing_formal_capture_test: CompileTimeError # DartOptions not passed to compiler.
Expand Down

0 comments on commit 9bf3b95

Please sign in to comment.