You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It passes with analyzer and throws a compile error with dart:
$> dart --enable-experiment=non-nullable test.dart
test.dart:4:39: Error: The required named parameter 'i' in method 'A.test_default' is not required in overridden method 'LEGACY_REQUIRED_ARGS.test_default'.
void test_default ({required int? i}) { print(i); }
^
test_out_lib.dart:3:8: Context: This is the overridden method ('test_default').
void test_default ({int i = 1}) {}
^
test.dart:5:39: Error: The required named parameter 'i' in method 'A.test_nondefault' is not required in overridden method 'LEGACY_REQUIRED_ARGS.test_nondefault'.
void test_nondefault({required int? i}) { print(i); }
^
test_out_lib.dart:4:8: Context: This is the overridden method ('test_nondefault').
void test_nondefault({int i }) {}
^
$> dartanalyzer --enable-experiment=non-nullable test.dart
Analyzing test.dart...
No issues found!
Seems like dart should not throw error here too.
At least, both tools should behave similarly.
The text was updated successfully, but these errors were encountered:
It was concluded in dart-lang/language#812 that subtyping is adjusted such that a required named parameter can match a legacy named parameter. For example, void Function({required int i}) <: void* Function({int* i}). So in this case the CFE should accept the program.
eernstg
added
area-front-end
Use area-front-end for front end / CFE / kernel format related issues.
and removed
area-front-end
Use area-front-end for front end / CFE / kernel format related issues.
labels
Apr 16, 2020
Dart VM version: 2.8.0-dev.20.0 (dev) (Fri Apr 3 10:19:55 2020 +0200) on "windows_x64"
In the following source code example method with nullable required parameter override legacy one:
test_out_lib.dart:
test.dart:
It passes with analyzer and throws a compile error with dart:
Seems like dart should not throw error here too.
At least, both tools should behave similarly.
The text was updated successfully, but these errors were encountered: