Commit f540c978 authored by Phil Quitslund's avatar Phil Quitslund

Merge pull request #3333 from pq/optional_type_args

Adding `@optionalTypeArgs`.
parents a2b704b8 de25ea22
......@@ -10,6 +10,7 @@ import 'debug.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
import 'package:meta/meta.dart';
export 'dart:ui' show hashValues, hashList;
export 'package:flutter/rendering.dart' show RenderObject, RenderBox, debugPrint;
......@@ -112,6 +113,7 @@ typedef void GlobalKeyRemoveListener(GlobalKey key);
/// GlobalKeys are relatively expensive. If you don't need any of the features
/// listed above, consider using a [Key], [ValueKey], [ObjectKey], or
/// [UniqueKey] instead.
@optionalTypeArgs
abstract class GlobalKey<T extends State<StatefulWidget>> extends Key {
/// Constructs a LabeledGlobalKey, which is a GlobalKey with a label used for debugging.
/// The label is not used for comparing the identity of the key.
......@@ -253,6 +255,7 @@ class GlobalObjectKey extends GlobalKey {
}
/// This class is a work-around for the "is" operator not accepting a variable value as its right operand
@optionalTypeArgs
class TypeMatcher<T> {
const TypeMatcher();
bool check(dynamic object) => object is T;
......@@ -346,6 +349,7 @@ enum _StateLifecycle {
typedef void StateSetter(VoidCallback fn);
/// The logic and internal state for a [StatefulWidget].
@optionalTypeArgs
abstract class State<T extends StatefulWidget> {
/// The current configuration (an instance of the corresponding
/// [StatefulWidget] class).
......
......@@ -8,6 +8,7 @@ import 'dart:ui' as ui show window;
import 'package:newton/newton.dart';
import 'package:flutter/gestures.dart';
import 'package:meta/meta.dart';
import 'basic.dart';
import 'framework.dart';
......@@ -217,6 +218,7 @@ abstract class Scrollable extends StatefulWidget {
/// along the [config.scrollDirection] axis and are implemented in
/// terms of the [pixelOffsetToScrollOffset] and
/// [scrollOffsetToPixelOffset] methods.
@optionalTypeArgs
abstract class ScrollableState<T extends Scrollable> extends State<T> {
@override
void initState() {
......
......@@ -12,6 +12,8 @@ dependencies:
# We need to pin crypto because archive can't handle larger numbers.
crypto: 0.9.2
meta: ^0.12.0
sky_engine:
path: ../../bin/cache/pkg/sky_engine
sky_services:
......
......@@ -357,7 +357,6 @@ class AnalyzeCommand extends FlutterCommand {
];
RegExp generalPattern = new RegExp(r'^\[(error|warning|hint|lint)\] (.+) \(([^(),]+), line ([0-9]+), col ([0-9]+)\)$');
RegExp classesWithOptionalTypeArgumentsPattern = new RegExp(r'\b(GlobalKey|State|ScrollableState|Element|StatelessElement|TypeMatcher)\b');
RegExp conflictingNamesPattern = new RegExp('^The imported libraries \'([^\']+)\' and \'([^\']+)\' cannot have the same name \'([^\']+)\'\$');
RegExp missingFilePattern = new RegExp('^Target of URI does not exist: \'([^\')]+)\'\$');
RegExp documentAllMembersPattern = new RegExp('^Document all public members\$');
......@@ -419,11 +418,6 @@ class AnalyzeCommand extends FlutterCommand {
} else if (sourceLines.first.startsWith('// DO NOT EDIT. This is code generated')) {
// autogenerated code - TODO(ianh): Fix the intl package resource generator
shouldIgnore = true;
} else if (level == 'lint' && errorMessage == 'Specify type annotations.') {
// we want the type annotations on certain classes to be optional.
// see https://github.com/dart-lang/linter/issues/196
if (classesWithOptionalTypeArgumentsPattern.matchAsPrefix(sourceLine, colNumber-1) != null)
shouldIgnore = true;
}
if (shouldIgnore)
continue;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment