From 59370f29c58b4e64c558d0063517a4a496f89ee5 Mon Sep 17 00:00:00 2001 From: Srujan Gaddam Date: Wed, 19 Feb 2020 20:43:34 +0000 Subject: [PATCH] Fix html methods without returns Several method bodies did not return a value conditionally or at all. Change-Id: I01ca87e2e0501597bacb49bcddd10668b59026b0 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135626 Commit-Queue: Srujan Gaddam Reviewed-by: Sigmund Cherem --- CHANGELOG.md | 4 ++++ pkg/dev_compiler/tool/dart2js_nnbd_sdk_error_golden.txt | 5 +---- pkg/dev_compiler/tool/dartdevc_nnbd_sdk_error_golden.txt | 5 +---- sdk/lib/html/dart2js/html_dart2js.dart | 4 +++- sdk_nnbd/lib/html/dart2js/html_dart2js.dart | 4 +++- tools/dom/nnbd_src/Validators.dart | 1 + tools/dom/src/Validators.dart | 1 + .../html/impl/impl_CanvasRenderingContext2D.darttemplate | 1 + tools/dom/templates/html/impl/impl_Node.darttemplate | 2 +- 9 files changed, 16 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 62aeeed8278..7fc6d6bba5c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,10 @@ used (see Issue [39627][]). [39627]: https://github.com/dart-lang/sdk/issues/39627 +* **Breaking Change**: `Node.insertAllBefore` erroneously had a return type of +`Node`, even though it was not returning anything. This has been corrected to +`void`. + #### `dart:io` * Class `HttpParser` will no longer throw an exception when a HTTP response diff --git a/pkg/dev_compiler/tool/dart2js_nnbd_sdk_error_golden.txt b/pkg/dev_compiler/tool/dart2js_nnbd_sdk_error_golden.txt index 814e04520dd..c20ae4132b8 100644 --- a/pkg/dev_compiler/tool/dart2js_nnbd_sdk_error_golden.txt +++ b/pkg/dev_compiler/tool/dart2js_nnbd_sdk_error_golden.txt @@ -1,9 +1,6 @@ ERROR|COMPILE_TIME_ERROR|BODY_MAY_COMPLETE_NORMALLY|lib/_internal/js_runtime/lib/js_helper.dart|2688|17|17|The body might complete normally, which would cause 'null' to be returned, but the return type is a potentially non-nullable type. ERROR|COMPILE_TIME_ERROR|BODY_MAY_COMPLETE_NORMALLY|lib/_internal/js_runtime/lib/js_helper.dart|3632|5|11|The body might complete normally, which would cause 'null' to be returned, but the return type is a potentially non-nullable type. ERROR|COMPILE_TIME_ERROR|BODY_MAY_COMPLETE_NORMALLY|lib/_internal/js_runtime/lib/js_helper.dart|3660|5|6|The body might complete normally, which would cause 'null' to be returned, but the return type is a potentially non-nullable type. -ERROR|COMPILE_TIME_ERROR|BODY_MAY_COMPLETE_NORMALLY|lib/html/dart2js/html_dart2js.dart|23331|8|15|The body might complete normally, which would cause 'null' to be returned, but the return type is a potentially non-nullable type. -ERROR|COMPILE_TIME_ERROR|BODY_MAY_COMPLETE_NORMALLY|lib/html/dart2js/html_dart2js.dart|2978|13|11|The body might complete normally, which would cause 'null' to be returned, but the return type is a potentially non-nullable type. -ERROR|COMPILE_TIME_ERROR|BODY_MAY_COMPLETE_NORMALLY|lib/html/dart2js/html_dart2js.dart|41436|8|15|The body might complete normally, which would cause 'null' to be returned, but the return type is a potentially non-nullable type. ERROR|COMPILE_TIME_ERROR|INCONSISTENT_INHERITANCE|lib/_internal/js_runtime/lib/interceptors.dart|1637|7|5|Superinterfaces don't have a valid override for '&': int.& (int Function(int)), JSNumber.& (num Function(num)). ERROR|COMPILE_TIME_ERROR|INCONSISTENT_INHERITANCE|lib/_internal/js_runtime/lib/interceptors.dart|1637|7|5|Superinterfaces don't have a valid override for '<<': int.<< (int Function(int)), JSNumber.<< (num Function(num)). ERROR|COMPILE_TIME_ERROR|INCONSISTENT_INHERITANCE|lib/_internal/js_runtime/lib/interceptors.dart|1637|7|5|Superinterfaces don't have a valid override for '>>': int.>> (int Function(int)), JSNumber.>> (num Function(num)). @@ -18,5 +15,5 @@ WARNING|STATIC_WARNING|DEAD_NULL_COALESCE|lib/_http/http.dart|1476|39|5|The left WARNING|STATIC_WARNING|DEAD_NULL_COALESCE|lib/_http/http.dart|8384|60|5|The left operand can't be null, so the right operand is never executed. WARNING|STATIC_WARNING|DEAD_NULL_COALESCE|lib/_http/http.dart|9311|54|5|The left operand can't be null, so the right operand is never executed. WARNING|STATIC_WARNING|DEAD_NULL_COALESCE|lib/developer/developer.dart|315|25|23|The left operand can't be null, so the right operand is never executed. -WARNING|STATIC_WARNING|DEAD_NULL_COALESCE|lib/html/dart2js/html_dart2js.dart|4075|25|2|The left operand can't be null, so the right operand is never executed. +WARNING|STATIC_WARNING|DEAD_NULL_COALESCE|lib/html/dart2js/html_dart2js.dart|4076|25|2|The left operand can't be null, so the right operand is never executed. WARNING|STATIC_WARNING|DEAD_NULL_COALESCE|lib/io/io.dart|9167|16|1|The left operand can't be null, so the right operand is never executed. diff --git a/pkg/dev_compiler/tool/dartdevc_nnbd_sdk_error_golden.txt b/pkg/dev_compiler/tool/dartdevc_nnbd_sdk_error_golden.txt index 13315f41284..ccf9e8ec1f9 100644 --- a/pkg/dev_compiler/tool/dartdevc_nnbd_sdk_error_golden.txt +++ b/pkg/dev_compiler/tool/dartdevc_nnbd_sdk_error_golden.txt @@ -15,13 +15,10 @@ ERROR|COMPILE_TIME_ERROR|BODY_MAY_COMPLETE_NORMALLY|lib/_internal/js_dev_runtime ERROR|COMPILE_TIME_ERROR|BODY_MAY_COMPLETE_NORMALLY|lib/_internal/js_dev_runtime/private/foreign_helper.dart|221|8|37|The body might complete normally, which would cause 'null' to be returned, but the return type is a potentially non-nullable type. ERROR|COMPILE_TIME_ERROR|BODY_MAY_COMPLETE_NORMALLY|lib/_internal/js_dev_runtime/private/foreign_helper.dart|224|8|11|The body might complete normally, which would cause 'null' to be returned, but the return type is a potentially non-nullable type. ERROR|COMPILE_TIME_ERROR|BODY_MAY_COMPLETE_NORMALLY|lib/_internal/js_dev_runtime/private/foreign_helper.dart|228|6|11|The body might complete normally, which would cause 'null' to be returned, but the return type is a potentially non-nullable type. -ERROR|COMPILE_TIME_ERROR|BODY_MAY_COMPLETE_NORMALLY|lib/html/dart2js/html_dart2js.dart|23331|8|15|The body might complete normally, which would cause 'null' to be returned, but the return type is a potentially non-nullable type. -ERROR|COMPILE_TIME_ERROR|BODY_MAY_COMPLETE_NORMALLY|lib/html/dart2js/html_dart2js.dart|2978|13|11|The body might complete normally, which would cause 'null' to be returned, but the return type is a potentially non-nullable type. -ERROR|COMPILE_TIME_ERROR|BODY_MAY_COMPLETE_NORMALLY|lib/html/dart2js/html_dart2js.dart|41436|8|15|The body might complete normally, which would cause 'null' to be returned, but the return type is a potentially non-nullable type. WARNING|STATIC_WARNING|DEAD_NULL_COALESCE|lib/_http/http.dart|1476|39|5|The left operand can't be null, so the right operand is never executed. WARNING|STATIC_WARNING|DEAD_NULL_COALESCE|lib/_http/http.dart|8384|60|5|The left operand can't be null, so the right operand is never executed. WARNING|STATIC_WARNING|DEAD_NULL_COALESCE|lib/_http/http.dart|9311|54|5|The left operand can't be null, so the right operand is never executed. WARNING|STATIC_WARNING|DEAD_NULL_COALESCE|lib/collection/collection.dart|1076|46|13|The left operand can't be null, so the right operand is never executed. WARNING|STATIC_WARNING|DEAD_NULL_COALESCE|lib/developer/developer.dart|332|25|23|The left operand can't be null, so the right operand is never executed. -WARNING|STATIC_WARNING|DEAD_NULL_COALESCE|lib/html/dart2js/html_dart2js.dart|4075|25|2|The left operand can't be null, so the right operand is never executed. +WARNING|STATIC_WARNING|DEAD_NULL_COALESCE|lib/html/dart2js/html_dart2js.dart|4076|25|2|The left operand can't be null, so the right operand is never executed. WARNING|STATIC_WARNING|DEAD_NULL_COALESCE|lib/io/io.dart|9167|16|1|The left operand can't be null, so the right operand is never executed. diff --git a/sdk/lib/html/dart2js/html_dart2js.dart b/sdk/lib/html/dart2js/html_dart2js.dart index c0143a8dad3..e07517dae1a 100644 --- a/sdk/lib/html/dart2js/html_dart2js.dart +++ b/sdk/lib/html/dart2js/html_dart2js.dart @@ -2687,6 +2687,7 @@ class CanvasRenderingContext2D extends Interceptor } else if (JS('bool', '!!#.webkitLineDash', this)) { return JS('List', '#.webkitLineDash', this); } + return []; } @SupportedBrowser(SupportedBrowser.CHROME) @@ -22116,7 +22117,7 @@ class Node extends EventTarget { * * * [insertBefore] */ - Node insertAllBefore(Iterable newNodes, Node refChild) { + void insertAllBefore(Iterable newNodes, Node refChild) { if (newNodes is _ChildNodeListLazy) { _ChildNodeListLazy otherList = newNodes; if (identical(otherList._this, this)) { @@ -39349,6 +39350,7 @@ class _ThrowsNodeValidator implements NodeValidator { throw new ArgumentError( '${Element._safeTagName(element)}[$attributeName="$value"]'); } + return true; } } diff --git a/sdk_nnbd/lib/html/dart2js/html_dart2js.dart b/sdk_nnbd/lib/html/dart2js/html_dart2js.dart index 8613b694f8f..3aebd68711e 100644 --- a/sdk_nnbd/lib/html/dart2js/html_dart2js.dart +++ b/sdk_nnbd/lib/html/dart2js/html_dart2js.dart @@ -2983,6 +2983,7 @@ class CanvasRenderingContext2D extends Interceptor } else if (JS('bool', '!!#.webkitLineDash', this)) { return JS('List', '#.webkitLineDash', this); } + return []; } @SupportedBrowser(SupportedBrowser.CHROME) @@ -23328,7 +23329,7 @@ class Node extends EventTarget { * * * [insertBefore] */ - Node insertAllBefore(Iterable newNodes, Node refChild) { + void insertAllBefore(Iterable newNodes, Node refChild) { if (newNodes is _ChildNodeListLazy) { _ChildNodeListLazy otherList = newNodes; if (identical(otherList._this, this)) { @@ -41438,6 +41439,7 @@ class _ThrowsNodeValidator implements NodeValidator { throw new ArgumentError( '${Element._safeTagName(element)}[$attributeName="$value"]'); } + return true; } } diff --git a/tools/dom/nnbd_src/Validators.dart b/tools/dom/nnbd_src/Validators.dart index 01569af71b6..aca5628a9b4 100644 --- a/tools/dom/nnbd_src/Validators.dart +++ b/tools/dom/nnbd_src/Validators.dart @@ -147,6 +147,7 @@ class _ThrowsNodeValidator implements NodeValidator { throw new ArgumentError( '${Element._safeTagName(element)}[$attributeName="$value"]'); } + return true; } } diff --git a/tools/dom/src/Validators.dart b/tools/dom/src/Validators.dart index ac0663d5377..ceb69689672 100644 --- a/tools/dom/src/Validators.dart +++ b/tools/dom/src/Validators.dart @@ -147,6 +147,7 @@ class _ThrowsNodeValidator implements NodeValidator { throw new ArgumentError( '${Element._safeTagName(element)}[$attributeName="$value"]'); } + return true; } } diff --git a/tools/dom/templates/html/impl/impl_CanvasRenderingContext2D.darttemplate b/tools/dom/templates/html/impl/impl_CanvasRenderingContext2D.darttemplate index 7bd1134c1de..2e9ba259a8f 100644 --- a/tools/dom/templates/html/impl/impl_CanvasRenderingContext2D.darttemplate +++ b/tools/dom/templates/html/impl/impl_CanvasRenderingContext2D.darttemplate @@ -250,6 +250,7 @@ $!MEMBERS } else if (JS('bool', '!!#.webkitLineDash', this)) { return JS('List', '#.webkitLineDash', this); } + return []; } @SupportedBrowser(SupportedBrowser.CHROME) diff --git a/tools/dom/templates/html/impl/impl_Node.darttemplate b/tools/dom/templates/html/impl/impl_Node.darttemplate index 8a4c1cee72c..b95204eef94 100644 --- a/tools/dom/templates/html/impl/impl_Node.darttemplate +++ b/tools/dom/templates/html/impl/impl_Node.darttemplate @@ -226,7 +226,7 @@ $(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS * * * [insertBefore] */ - Node insertAllBefore(Iterable newNodes, Node refChild) { + void insertAllBefore(Iterable newNodes, Node refChild) { if (newNodes is _ChildNodeListLazy) { _ChildNodeListLazy otherList = newNodes; if (identical(otherList._this, this)) {