From 4b7a1fd88be04ab09898293749c32c22be415571 Mon Sep 17 00:00:00 2001 From: Dmitry Stefantsov Date: Fri, 30 Jul 2021 10:08:44 +0000 Subject: [PATCH 1/2] [cfe] Add initial tests for show/hide subfeature of extension types Change-Id: Idc0a72445295ca2e99ffcfd699d1d65d4b7f466a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208403 Commit-Queue: Dmitry Stefantsov Reviewed-by: Johnni Winther --- .../test/spell_checking_list_code.txt | 1 + .../extension_types/simple_show_hide.dart | 41 +++ .../simple_show_hide.dart.strong.expect | 256 ++++++++++++++++++ ...mple_show_hide.dart.textual_outline.expect | 15 + .../simple_show_hide.dart.weak.expect | 256 ++++++++++++++++++ .../simple_show_hide.dart.weak.outline.expect | 126 +++++++++ .../simple_show_hide_conflicts.dart | 20 ++ ...ple_show_hide_conflicts.dart.strong.expect | 141 ++++++++++ ...e_conflicts.dart.strong.transformed.expect | 141 ++++++++++ ...hide_conflicts.dart.textual_outline.expect | 13 + ...licts.dart.textual_outline_modelled.expect | 11 + ...imple_show_hide_conflicts.dart.weak.expect | 141 ++++++++++ ...ow_hide_conflicts.dart.weak.outline.expect | 78 ++++++ ...ide_conflicts.dart.weak.transformed.expect | 141 ++++++++++ pkg/front_end/testcases/outline.status | 1 + pkg/front_end/testcases/strong.status | 1 + .../testcases/text_serialization.status | 1 + .../testcases/textual_outline.status | 1 + pkg/front_end/testcases/weak.status | 1 + 19 files changed, 1386 insertions(+) create mode 100644 pkg/front_end/testcases/extension_types/simple_show_hide.dart create mode 100644 pkg/front_end/testcases/extension_types/simple_show_hide.dart.strong.expect create mode 100644 pkg/front_end/testcases/extension_types/simple_show_hide.dart.textual_outline.expect create mode 100644 pkg/front_end/testcases/extension_types/simple_show_hide.dart.weak.expect create mode 100644 pkg/front_end/testcases/extension_types/simple_show_hide.dart.weak.outline.expect create mode 100644 pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart create mode 100644 pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart.strong.expect create mode 100644 pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart.strong.transformed.expect create mode 100644 pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart.textual_outline.expect create mode 100644 pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart.textual_outline_modelled.expect create mode 100644 pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart.weak.expect create mode 100644 pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart.weak.outline.expect create mode 100644 pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart.weak.transformed.expect diff --git a/pkg/front_end/test/spell_checking_list_code.txt b/pkg/front_end/test/spell_checking_list_code.txt index f8df10f098e31..ec72c29227e57 100644 --- a/pkg/front_end/test/spell_checking_list_code.txt +++ b/pkg/front_end/test/spell_checking_list_code.txt @@ -167,6 +167,7 @@ casted casts categorized ce +ceil cfe ch channel diff --git a/pkg/front_end/testcases/extension_types/simple_show_hide.dart b/pkg/front_end/testcases/extension_types/simple_show_hide.dart new file mode 100644 index 0000000000000..e64df54e63486 --- /dev/null +++ b/pkg/front_end/testcases/extension_types/simple_show_hide.dart @@ -0,0 +1,41 @@ +// Copyright (c) 2021, 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. + +extension E1 on int show num {} + +test1(E1 e1) { + e1.ceil(); // Ok. + e2.floor(); // Ok. + e1.isEven; // Error. +} + +extension E2 on int show num hide ceil {} + +test2(E2 e2) { + e2.ceil(); // Error. + e2.floor(); // Ok. + e2.isEven; // Error. +} + +extension E3 on int hide isEven {} + +test3(E3 e3) { + e3.isOdd; // Ok. + e3.isEven; // Error. +} + +extension type MyInt on int show num, isEven hide floor { + int get twice => 2 * this; +} + +test() { + MyInt m = 42; + m.twice; // OK, in the extension type. + m.isEven; // OK, a shown instance member. + m.ceil(); // OK, a shown instance member. + m.toString(); // OK, an `Object` member. + m.floor(); // Error, hidden. +} + +main() {} diff --git a/pkg/front_end/testcases/extension_types/simple_show_hide.dart.strong.expect b/pkg/front_end/testcases/extension_types/simple_show_hide.dart.strong.expect new file mode 100644 index 0000000000000..d246aca4f3f5e --- /dev/null +++ b/pkg/front_end/testcases/extension_types/simple_show_hide.dart.strong.expect @@ -0,0 +1,256 @@ +library /*isNonNullableByDefault*/; +// +// Problems in library: +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:5:17: Error: A extension declaration must have a body, even if it is empty. +// Try adding an empty body. +// extension E1 on int show num {} +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:5:26: Error: A function declaration needs an explicit list of parameters. +// Try adding a parameter list to the function declaration. +// extension E1 on int show num {} +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:13:17: Error: A extension declaration must have a body, even if it is empty. +// Try adding an empty body. +// extension E2 on int show num hide ceil {} +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:13:26: Error: Expected ';' after this. +// extension E2 on int show num hide ceil {} +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:13:26: Error: 'num' is already declared in this scope. +// extension E2 on int show num hide ceil {} +// ^^^ +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:5:26: Context: Previous declaration of 'num'. +// extension E1 on int show num {} +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:13:35: Error: A function declaration needs an explicit list of parameters. +// Try adding a parameter list to the function declaration. +// extension E2 on int show num hide ceil {} +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:21:17: Error: A extension declaration must have a body, even if it is empty. +// Try adding an empty body. +// extension E3 on int hide isEven {} +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:21:26: Error: A function declaration needs an explicit list of parameters. +// Try adding a parameter list to the function declaration. +// extension E3 on int hide isEven {} +// ^^^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:28:25: Error: A extension declaration must have a body, even if it is empty. +// Try adding an empty body. +// extension type MyInt on int show num, isEven hide floor { +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:28:39: Error: Expected ';' after this. +// extension type MyInt on int show num, isEven hide floor { +// ^^^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:28:34: Error: 'num' is already declared in this scope. +// extension type MyInt on int show num, isEven hide floor { +// ^^^ +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:13:26: Context: Previous declaration of 'num'. +// extension E2 on int show num hide ceil {} +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:28:39: Error: 'isEven' is already declared in this scope. +// extension type MyInt on int show num, isEven hide floor { +// ^^^^^^ +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:21:26: Context: Previous declaration of 'isEven'. +// extension E3 on int hide isEven {} +// ^^^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:28:51: Error: A function declaration needs an explicit list of parameters. +// Try adding a parameter list to the function declaration. +// extension type MyInt on int show num, isEven hide floor { +// ^^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:5:21: Error: Type 'show' not found. +// extension E1 on int show num {} +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:13:21: Error: Type 'show' not found. +// extension E2 on int show num hide ceil {} +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:13:30: Error: Type 'hide' not found. +// extension E2 on int show num hide ceil {} +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:21:21: Error: Type 'hide' not found. +// extension E3 on int hide isEven {} +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:28:29: Error: Type 'show' not found. +// extension type MyInt on int show num, isEven hide floor { +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:28:46: Error: Type 'hide' not found. +// extension type MyInt on int show num, isEven hide floor { +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:9:3: Error: Getter not found: 'e2'. +// e2.floor(); // Ok. +// ^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:8:6: Error: The method 'ceil' isn't defined for the extension 'E1'. +// Try correcting the name to the name of an existing method, or defining a method name 'ceil'. +// e1.ceil(); // Ok. +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:10:6: Error: The getter 'isEven' isn't defined for the extension 'E1'. +// Try correcting the name to the name of an existing getter, or defining a getter or field named 'isEven'. +// e1.isEven; // Error. +// ^^^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:13:21: Error: 'show' isn't a type. +// extension E2 on int show num hide ceil {} +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:16:6: Error: The method 'ceil' isn't defined for the extension 'E2'. +// Try correcting the name to the name of an existing method, or defining a method name 'ceil'. +// e2.ceil(); // Error. +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:17:6: Error: The method 'floor' isn't defined for the extension 'E2'. +// Try correcting the name to the name of an existing method, or defining a method name 'floor'. +// e2.floor(); // Ok. +// ^^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:18:6: Error: The getter 'isEven' isn't defined for the extension 'E2'. +// Try correcting the name to the name of an existing getter, or defining a getter or field named 'isEven'. +// e2.isEven; // Error. +// ^^^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:24:6: Error: The getter 'isOdd' isn't defined for the extension 'E3'. +// Try correcting the name to the name of an existing getter, or defining a getter or field named 'isOdd'. +// e3.isOdd; // Ok. +// ^^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:25:6: Error: The getter 'isEven' isn't defined for the extension 'E3'. +// Try correcting the name to the name of an existing getter, or defining a getter or field named 'isEven'. +// e3.isEven; // Error. +// ^^^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:28:29: Error: 'show' isn't a type. +// extension type MyInt on int show num, isEven hide floor { +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:29:7: Error: Expected ';' after this. +// int get twice => 2 * this; +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:29:17: Error: A function declaration needs an explicit list of parameters. +// Try adding a parameter list to the function declaration. +// int get twice => 2 * this; +// ^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:29:24: Error: Expected identifier, but got 'this'. +// int get twice => 2 * this; +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:34:5: Error: The getter 'twice' isn't defined for the extension 'MyInt'. +// Try correcting the name to the name of an existing getter, or defining a getter or field named 'twice'. +// m.twice; // OK, in the extension type. +// ^^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:35:5: Error: The getter 'isEven' isn't defined for the extension 'MyInt'. +// Try correcting the name to the name of an existing getter, or defining a getter or field named 'isEven'. +// m.isEven; // OK, a shown instance member. +// ^^^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:36:5: Error: The method 'ceil' isn't defined for the extension 'MyInt'. +// Try correcting the name to the name of an existing method, or defining a method name 'ceil'. +// m.ceil(); // OK, a shown instance member. +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:38:5: Error: The method 'floor' isn't defined for the extension 'MyInt'. +// Try correcting the name to the name of an existing method, or defining a method name 'floor'. +// m.floor(); // Error, hidden. +// ^^^^^ +// +import self as self; +import "dart:core" as core; + +extension E1 on core::int { +} +extension E2 on core::int { +} +extension E3 on core::int { +} +extension type MyInt on core::int { +} +static method num() → invalid-type {} +static method test1(self::E1 e1) → dynamic { + invalid-expression "pkg/front_end/testcases/extension_types/simple_show_hide.dart:8:6: Error: The method 'ceil' isn't defined for the extension 'E1'. +Try correcting the name to the name of an existing method, or defining a method name 'ceil'. + e1.ceil(); // Ok. + ^^^^"; + invalid-expression "pkg/front_end/testcases/extension_types/simple_show_hide.dart:9:3: Error: Getter not found: 'e2'. + e2.floor(); // Ok. + ^^"{dynamic}.floor(); + invalid-expression "pkg/front_end/testcases/extension_types/simple_show_hide.dart:10:6: Error: The getter 'isEven' isn't defined for the extension 'E1'. +Try correcting the name to the name of an existing getter, or defining a getter or field named 'isEven'. + e1.isEven; // Error. + ^^^^^^"; +} +static method ceil() → invalid-type {} +static method test2(self::E2 e2) → dynamic { + invalid-expression "pkg/front_end/testcases/extension_types/simple_show_hide.dart:16:6: Error: The method 'ceil' isn't defined for the extension 'E2'. +Try correcting the name to the name of an existing method, or defining a method name 'ceil'. + e2.ceil(); // Error. + ^^^^"; + invalid-expression "pkg/front_end/testcases/extension_types/simple_show_hide.dart:17:6: Error: The method 'floor' isn't defined for the extension 'E2'. +Try correcting the name to the name of an existing method, or defining a method name 'floor'. + e2.floor(); // Ok. + ^^^^^"; + invalid-expression "pkg/front_end/testcases/extension_types/simple_show_hide.dart:18:6: Error: The getter 'isEven' isn't defined for the extension 'E2'. +Try correcting the name to the name of an existing getter, or defining a getter or field named 'isEven'. + e2.isEven; // Error. + ^^^^^^"; +} +static method isEven() → invalid-type {} +static method test3(self::E3 e3) → dynamic { + invalid-expression "pkg/front_end/testcases/extension_types/simple_show_hide.dart:24:6: Error: The getter 'isOdd' isn't defined for the extension 'E3'. +Try correcting the name to the name of an existing getter, or defining a getter or field named 'isOdd'. + e3.isOdd; // Ok. + ^^^^^"; + invalid-expression "pkg/front_end/testcases/extension_types/simple_show_hide.dart:25:6: Error: The getter 'isEven' isn't defined for the extension 'E3'. +Try correcting the name to the name of an existing getter, or defining a getter or field named 'isEven'. + e3.isEven; // Error. + ^^^^^^"; +} +static method floor() → invalid-type { + core::int get; + function twice() → core::num + return 2.{core::num::*}(invalid-expression "pkg/front_end/testcases/extension_types/simple_show_hide.dart:29:24: Error: Expected identifier, but got 'this'. + int get twice => 2 * this; + ^^^^" as{TypeError,ForDynamic,ForNonNullableByDefault} core::num){(core::num) → core::num}; +} +static method test() → dynamic { + self::MyInt m = 42; + invalid-expression "pkg/front_end/testcases/extension_types/simple_show_hide.dart:34:5: Error: The getter 'twice' isn't defined for the extension 'MyInt'. +Try correcting the name to the name of an existing getter, or defining a getter or field named 'twice'. + m.twice; // OK, in the extension type. + ^^^^^"; + invalid-expression "pkg/front_end/testcases/extension_types/simple_show_hide.dart:35:5: Error: The getter 'isEven' isn't defined for the extension 'MyInt'. +Try correcting the name to the name of an existing getter, or defining a getter or field named 'isEven'. + m.isEven; // OK, a shown instance member. + ^^^^^^"; + invalid-expression "pkg/front_end/testcases/extension_types/simple_show_hide.dart:36:5: Error: The method 'ceil' isn't defined for the extension 'MyInt'. +Try correcting the name to the name of an existing method, or defining a method name 'ceil'. + m.ceil(); // OK, a shown instance member. + ^^^^"; + m.{core::Object::toString}(){() → core::String}; + invalid-expression "pkg/front_end/testcases/extension_types/simple_show_hide.dart:38:5: Error: The method 'floor' isn't defined for the extension 'MyInt'. +Try correcting the name to the name of an existing method, or defining a method name 'floor'. + m.floor(); // Error, hidden. + ^^^^^"; +} +static method main() → dynamic {} diff --git a/pkg/front_end/testcases/extension_types/simple_show_hide.dart.textual_outline.expect b/pkg/front_end/testcases/extension_types/simple_show_hide.dart.textual_outline.expect new file mode 100644 index 0000000000000..629647688bfdb --- /dev/null +++ b/pkg/front_end/testcases/extension_types/simple_show_hide.dart.textual_outline.expect @@ -0,0 +1,15 @@ +extension E1 on int {} +show num (){} +test1(E1 e1) {} +extension E2 on int {} +show num ; +hide ceil (){} +test2(E2 e2) {} +extension E3 on int {} +hide isEven (){} +test3(E3 e3) {} +extension type MyInt on int {} +show num, isEven ; +hide floor (){} +test() {} +main() {} diff --git a/pkg/front_end/testcases/extension_types/simple_show_hide.dart.weak.expect b/pkg/front_end/testcases/extension_types/simple_show_hide.dart.weak.expect new file mode 100644 index 0000000000000..d246aca4f3f5e --- /dev/null +++ b/pkg/front_end/testcases/extension_types/simple_show_hide.dart.weak.expect @@ -0,0 +1,256 @@ +library /*isNonNullableByDefault*/; +// +// Problems in library: +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:5:17: Error: A extension declaration must have a body, even if it is empty. +// Try adding an empty body. +// extension E1 on int show num {} +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:5:26: Error: A function declaration needs an explicit list of parameters. +// Try adding a parameter list to the function declaration. +// extension E1 on int show num {} +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:13:17: Error: A extension declaration must have a body, even if it is empty. +// Try adding an empty body. +// extension E2 on int show num hide ceil {} +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:13:26: Error: Expected ';' after this. +// extension E2 on int show num hide ceil {} +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:13:26: Error: 'num' is already declared in this scope. +// extension E2 on int show num hide ceil {} +// ^^^ +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:5:26: Context: Previous declaration of 'num'. +// extension E1 on int show num {} +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:13:35: Error: A function declaration needs an explicit list of parameters. +// Try adding a parameter list to the function declaration. +// extension E2 on int show num hide ceil {} +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:21:17: Error: A extension declaration must have a body, even if it is empty. +// Try adding an empty body. +// extension E3 on int hide isEven {} +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:21:26: Error: A function declaration needs an explicit list of parameters. +// Try adding a parameter list to the function declaration. +// extension E3 on int hide isEven {} +// ^^^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:28:25: Error: A extension declaration must have a body, even if it is empty. +// Try adding an empty body. +// extension type MyInt on int show num, isEven hide floor { +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:28:39: Error: Expected ';' after this. +// extension type MyInt on int show num, isEven hide floor { +// ^^^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:28:34: Error: 'num' is already declared in this scope. +// extension type MyInt on int show num, isEven hide floor { +// ^^^ +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:13:26: Context: Previous declaration of 'num'. +// extension E2 on int show num hide ceil {} +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:28:39: Error: 'isEven' is already declared in this scope. +// extension type MyInt on int show num, isEven hide floor { +// ^^^^^^ +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:21:26: Context: Previous declaration of 'isEven'. +// extension E3 on int hide isEven {} +// ^^^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:28:51: Error: A function declaration needs an explicit list of parameters. +// Try adding a parameter list to the function declaration. +// extension type MyInt on int show num, isEven hide floor { +// ^^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:5:21: Error: Type 'show' not found. +// extension E1 on int show num {} +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:13:21: Error: Type 'show' not found. +// extension E2 on int show num hide ceil {} +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:13:30: Error: Type 'hide' not found. +// extension E2 on int show num hide ceil {} +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:21:21: Error: Type 'hide' not found. +// extension E3 on int hide isEven {} +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:28:29: Error: Type 'show' not found. +// extension type MyInt on int show num, isEven hide floor { +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:28:46: Error: Type 'hide' not found. +// extension type MyInt on int show num, isEven hide floor { +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:9:3: Error: Getter not found: 'e2'. +// e2.floor(); // Ok. +// ^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:8:6: Error: The method 'ceil' isn't defined for the extension 'E1'. +// Try correcting the name to the name of an existing method, or defining a method name 'ceil'. +// e1.ceil(); // Ok. +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:10:6: Error: The getter 'isEven' isn't defined for the extension 'E1'. +// Try correcting the name to the name of an existing getter, or defining a getter or field named 'isEven'. +// e1.isEven; // Error. +// ^^^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:13:21: Error: 'show' isn't a type. +// extension E2 on int show num hide ceil {} +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:16:6: Error: The method 'ceil' isn't defined for the extension 'E2'. +// Try correcting the name to the name of an existing method, or defining a method name 'ceil'. +// e2.ceil(); // Error. +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:17:6: Error: The method 'floor' isn't defined for the extension 'E2'. +// Try correcting the name to the name of an existing method, or defining a method name 'floor'. +// e2.floor(); // Ok. +// ^^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:18:6: Error: The getter 'isEven' isn't defined for the extension 'E2'. +// Try correcting the name to the name of an existing getter, or defining a getter or field named 'isEven'. +// e2.isEven; // Error. +// ^^^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:24:6: Error: The getter 'isOdd' isn't defined for the extension 'E3'. +// Try correcting the name to the name of an existing getter, or defining a getter or field named 'isOdd'. +// e3.isOdd; // Ok. +// ^^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:25:6: Error: The getter 'isEven' isn't defined for the extension 'E3'. +// Try correcting the name to the name of an existing getter, or defining a getter or field named 'isEven'. +// e3.isEven; // Error. +// ^^^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:28:29: Error: 'show' isn't a type. +// extension type MyInt on int show num, isEven hide floor { +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:29:7: Error: Expected ';' after this. +// int get twice => 2 * this; +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:29:17: Error: A function declaration needs an explicit list of parameters. +// Try adding a parameter list to the function declaration. +// int get twice => 2 * this; +// ^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:29:24: Error: Expected identifier, but got 'this'. +// int get twice => 2 * this; +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:34:5: Error: The getter 'twice' isn't defined for the extension 'MyInt'. +// Try correcting the name to the name of an existing getter, or defining a getter or field named 'twice'. +// m.twice; // OK, in the extension type. +// ^^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:35:5: Error: The getter 'isEven' isn't defined for the extension 'MyInt'. +// Try correcting the name to the name of an existing getter, or defining a getter or field named 'isEven'. +// m.isEven; // OK, a shown instance member. +// ^^^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:36:5: Error: The method 'ceil' isn't defined for the extension 'MyInt'. +// Try correcting the name to the name of an existing method, or defining a method name 'ceil'. +// m.ceil(); // OK, a shown instance member. +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:38:5: Error: The method 'floor' isn't defined for the extension 'MyInt'. +// Try correcting the name to the name of an existing method, or defining a method name 'floor'. +// m.floor(); // Error, hidden. +// ^^^^^ +// +import self as self; +import "dart:core" as core; + +extension E1 on core::int { +} +extension E2 on core::int { +} +extension E3 on core::int { +} +extension type MyInt on core::int { +} +static method num() → invalid-type {} +static method test1(self::E1 e1) → dynamic { + invalid-expression "pkg/front_end/testcases/extension_types/simple_show_hide.dart:8:6: Error: The method 'ceil' isn't defined for the extension 'E1'. +Try correcting the name to the name of an existing method, or defining a method name 'ceil'. + e1.ceil(); // Ok. + ^^^^"; + invalid-expression "pkg/front_end/testcases/extension_types/simple_show_hide.dart:9:3: Error: Getter not found: 'e2'. + e2.floor(); // Ok. + ^^"{dynamic}.floor(); + invalid-expression "pkg/front_end/testcases/extension_types/simple_show_hide.dart:10:6: Error: The getter 'isEven' isn't defined for the extension 'E1'. +Try correcting the name to the name of an existing getter, or defining a getter or field named 'isEven'. + e1.isEven; // Error. + ^^^^^^"; +} +static method ceil() → invalid-type {} +static method test2(self::E2 e2) → dynamic { + invalid-expression "pkg/front_end/testcases/extension_types/simple_show_hide.dart:16:6: Error: The method 'ceil' isn't defined for the extension 'E2'. +Try correcting the name to the name of an existing method, or defining a method name 'ceil'. + e2.ceil(); // Error. + ^^^^"; + invalid-expression "pkg/front_end/testcases/extension_types/simple_show_hide.dart:17:6: Error: The method 'floor' isn't defined for the extension 'E2'. +Try correcting the name to the name of an existing method, or defining a method name 'floor'. + e2.floor(); // Ok. + ^^^^^"; + invalid-expression "pkg/front_end/testcases/extension_types/simple_show_hide.dart:18:6: Error: The getter 'isEven' isn't defined for the extension 'E2'. +Try correcting the name to the name of an existing getter, or defining a getter or field named 'isEven'. + e2.isEven; // Error. + ^^^^^^"; +} +static method isEven() → invalid-type {} +static method test3(self::E3 e3) → dynamic { + invalid-expression "pkg/front_end/testcases/extension_types/simple_show_hide.dart:24:6: Error: The getter 'isOdd' isn't defined for the extension 'E3'. +Try correcting the name to the name of an existing getter, or defining a getter or field named 'isOdd'. + e3.isOdd; // Ok. + ^^^^^"; + invalid-expression "pkg/front_end/testcases/extension_types/simple_show_hide.dart:25:6: Error: The getter 'isEven' isn't defined for the extension 'E3'. +Try correcting the name to the name of an existing getter, or defining a getter or field named 'isEven'. + e3.isEven; // Error. + ^^^^^^"; +} +static method floor() → invalid-type { + core::int get; + function twice() → core::num + return 2.{core::num::*}(invalid-expression "pkg/front_end/testcases/extension_types/simple_show_hide.dart:29:24: Error: Expected identifier, but got 'this'. + int get twice => 2 * this; + ^^^^" as{TypeError,ForDynamic,ForNonNullableByDefault} core::num){(core::num) → core::num}; +} +static method test() → dynamic { + self::MyInt m = 42; + invalid-expression "pkg/front_end/testcases/extension_types/simple_show_hide.dart:34:5: Error: The getter 'twice' isn't defined for the extension 'MyInt'. +Try correcting the name to the name of an existing getter, or defining a getter or field named 'twice'. + m.twice; // OK, in the extension type. + ^^^^^"; + invalid-expression "pkg/front_end/testcases/extension_types/simple_show_hide.dart:35:5: Error: The getter 'isEven' isn't defined for the extension 'MyInt'. +Try correcting the name to the name of an existing getter, or defining a getter or field named 'isEven'. + m.isEven; // OK, a shown instance member. + ^^^^^^"; + invalid-expression "pkg/front_end/testcases/extension_types/simple_show_hide.dart:36:5: Error: The method 'ceil' isn't defined for the extension 'MyInt'. +Try correcting the name to the name of an existing method, or defining a method name 'ceil'. + m.ceil(); // OK, a shown instance member. + ^^^^"; + m.{core::Object::toString}(){() → core::String}; + invalid-expression "pkg/front_end/testcases/extension_types/simple_show_hide.dart:38:5: Error: The method 'floor' isn't defined for the extension 'MyInt'. +Try correcting the name to the name of an existing method, or defining a method name 'floor'. + m.floor(); // Error, hidden. + ^^^^^"; +} +static method main() → dynamic {} diff --git a/pkg/front_end/testcases/extension_types/simple_show_hide.dart.weak.outline.expect b/pkg/front_end/testcases/extension_types/simple_show_hide.dart.weak.outline.expect new file mode 100644 index 0000000000000..7a2b050208bac --- /dev/null +++ b/pkg/front_end/testcases/extension_types/simple_show_hide.dart.weak.outline.expect @@ -0,0 +1,126 @@ +library /*isNonNullableByDefault*/; +// +// Problems in library: +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:5:17: Error: A extension declaration must have a body, even if it is empty. +// Try adding an empty body. +// extension E1 on int show num {} +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:5:26: Error: A function declaration needs an explicit list of parameters. +// Try adding a parameter list to the function declaration. +// extension E1 on int show num {} +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:13:17: Error: A extension declaration must have a body, even if it is empty. +// Try adding an empty body. +// extension E2 on int show num hide ceil {} +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:13:26: Error: Expected ';' after this. +// extension E2 on int show num hide ceil {} +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:13:26: Error: 'num' is already declared in this scope. +// extension E2 on int show num hide ceil {} +// ^^^ +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:5:26: Context: Previous declaration of 'num'. +// extension E1 on int show num {} +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:13:35: Error: A function declaration needs an explicit list of parameters. +// Try adding a parameter list to the function declaration. +// extension E2 on int show num hide ceil {} +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:21:17: Error: A extension declaration must have a body, even if it is empty. +// Try adding an empty body. +// extension E3 on int hide isEven {} +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:21:26: Error: A function declaration needs an explicit list of parameters. +// Try adding a parameter list to the function declaration. +// extension E3 on int hide isEven {} +// ^^^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:28:25: Error: A extension declaration must have a body, even if it is empty. +// Try adding an empty body. +// extension type MyInt on int show num, isEven hide floor { +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:28:39: Error: Expected ';' after this. +// extension type MyInt on int show num, isEven hide floor { +// ^^^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:28:34: Error: 'num' is already declared in this scope. +// extension type MyInt on int show num, isEven hide floor { +// ^^^ +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:13:26: Context: Previous declaration of 'num'. +// extension E2 on int show num hide ceil {} +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:28:39: Error: 'isEven' is already declared in this scope. +// extension type MyInt on int show num, isEven hide floor { +// ^^^^^^ +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:21:26: Context: Previous declaration of 'isEven'. +// extension E3 on int hide isEven {} +// ^^^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:28:51: Error: A function declaration needs an explicit list of parameters. +// Try adding a parameter list to the function declaration. +// extension type MyInt on int show num, isEven hide floor { +// ^^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:5:21: Error: Type 'show' not found. +// extension E1 on int show num {} +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:13:21: Error: Type 'show' not found. +// extension E2 on int show num hide ceil {} +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:13:30: Error: Type 'hide' not found. +// extension E2 on int show num hide ceil {} +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:21:21: Error: Type 'hide' not found. +// extension E3 on int hide isEven {} +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:28:29: Error: Type 'show' not found. +// extension type MyInt on int show num, isEven hide floor { +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide.dart:28:46: Error: Type 'hide' not found. +// extension type MyInt on int show num, isEven hide floor { +// ^^^^ +// +import self as self; +import "dart:core" as core; + +extension E1 on core::int { +} +extension E2 on core::int { +} +extension E3 on core::int { +} +extension type MyInt on core::int { +} +static method num() → invalid-type + ; +static method test1(self::E1 e1) → dynamic + ; +static method ceil() → invalid-type + ; +static method test2(self::E2 e2) → dynamic + ; +static method isEven() → invalid-type + ; +static method test3(self::E3 e3) → dynamic + ; +static method floor() → invalid-type + ; +static method test() → dynamic + ; +static method main() → dynamic + ; diff --git a/pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart b/pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart new file mode 100644 index 0000000000000..7f5ac0d738552 --- /dev/null +++ b/pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart @@ -0,0 +1,20 @@ +// Copyright (c) 2021, 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. + +extension E1 on int show num { + int ceil() {} // Error. +} + +extension E2 on int show num hide ceil { + int ceil() {} // Ok. + int floor() {} // Error. +} + +extension E3 on int hide isEven { + // `on int hide isEven` means `on int show int hide isEven`. + bool get isOdd => throw 42; // Error. + bool get isEven => throw 42; // Ok. +} + +main() {} diff --git a/pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart.strong.expect b/pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart.strong.expect new file mode 100644 index 0000000000000..6d6816022c995 --- /dev/null +++ b/pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart.strong.expect @@ -0,0 +1,141 @@ +library /*isNonNullableByDefault*/; +// +// Problems in library: +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:5:17: Error: A extension declaration must have a body, even if it is empty. +// Try adding an empty body. +// extension E1 on int show num { +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:5:26: Error: A function declaration needs an explicit list of parameters. +// Try adding a parameter list to the function declaration. +// extension E1 on int show num { +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:9:17: Error: A extension declaration must have a body, even if it is empty. +// Try adding an empty body. +// extension E2 on int show num hide ceil { +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:9:26: Error: Expected ';' after this. +// extension E2 on int show num hide ceil { +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:9:26: Error: 'num' is already declared in this scope. +// extension E2 on int show num hide ceil { +// ^^^ +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:5:26: Context: Previous declaration of 'num'. +// extension E1 on int show num { +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:9:35: Error: A function declaration needs an explicit list of parameters. +// Try adding a parameter list to the function declaration. +// extension E2 on int show num hide ceil { +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:14:17: Error: A extension declaration must have a body, even if it is empty. +// Try adding an empty body. +// extension E3 on int hide isEven { +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:14:26: Error: A function declaration needs an explicit list of parameters. +// Try adding a parameter list to the function declaration. +// extension E3 on int hide isEven { +// ^^^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:5:21: Error: Type 'show' not found. +// extension E1 on int show num { +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:9:21: Error: Type 'show' not found. +// extension E2 on int show num hide ceil { +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:9:30: Error: Type 'hide' not found. +// extension E2 on int show num hide ceil { +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:14:21: Error: Type 'hide' not found. +// extension E3 on int hide isEven { +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:6:3: Error: A non-null value must be returned since the return type 'int' doesn't allow null. +// int ceil() {} // Error. +// ^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:9:21: Error: 'show' isn't a type. +// extension E2 on int show num hide ceil { +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:10:3: Error: A non-null value must be returned since the return type 'int' doesn't allow null. +// int ceil() {} // Ok. +// ^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:11:3: Error: A non-null value must be returned since the return type 'int' doesn't allow null. +// int floor() {} // Error. +// ^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:16:8: Error: Expected ';' after this. +// bool get isOdd => throw 42; // Error. +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:16:18: Error: A function declaration needs an explicit list of parameters. +// Try adding a parameter list to the function declaration. +// bool get isOdd => throw 42; // Error. +// ^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:17:8: Error: 'get' is already declared in this scope. +// bool get isEven => throw 42; // Ok. +// ^^^ +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:16:8: Context: Previous declaration of 'get'. +// bool get isOdd => throw 42; // Error. +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:17:8: Error: Expected ';' after this. +// bool get isEven => throw 42; // Ok. +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:17:19: Error: A function declaration needs an explicit list of parameters. +// Try adding a parameter list to the function declaration. +// bool get isEven => throw 42; // Ok. +// ^^ +// +import self as self; +import "dart:core" as core; + +extension E1 on core::int { +} +extension E2 on core::int { +} +extension E3 on core::int { +} +static method num() → invalid-type { + function ceil() → core::int { + return let final Never #t1 = invalid-expression "pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:6:3: Error: A non-null value must be returned since the return type 'int' doesn't allow null. + int ceil() {} // Error. + ^" in null; + } +} +static method ceil() → invalid-type { + function ceil() → core::int { + return let final Never #t2 = invalid-expression "pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:10:3: Error: A non-null value must be returned since the return type 'int' doesn't allow null. + int ceil() {} // Ok. + ^" in null; + } + function floor() → core::int { + return let final Never #t3 = invalid-expression "pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:11:3: Error: A non-null value must be returned since the return type 'int' doesn't allow null. + int floor() {} // Error. + ^" in null; + } +} +static method isEven() → invalid-type { + core::bool get; + function isOdd() → Never + return throw 42; + core::bool get = invalid-expression "pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:17:8: Error: 'get' is already declared in this scope. + bool get isEven => throw 42; // Ok. + ^^^" as{TypeError,ForDynamic,ForNonNullableByDefault} core::bool; + function isEven() → Never + return throw 42; +} +static method main() → dynamic {} diff --git a/pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart.strong.transformed.expect b/pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart.strong.transformed.expect new file mode 100644 index 0000000000000..9fe722e4caac2 --- /dev/null +++ b/pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart.strong.transformed.expect @@ -0,0 +1,141 @@ +library /*isNonNullableByDefault*/; +// +// Problems in library: +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:5:17: Error: A extension declaration must have a body, even if it is empty. +// Try adding an empty body. +// extension E1 on int show num { +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:5:26: Error: A function declaration needs an explicit list of parameters. +// Try adding a parameter list to the function declaration. +// extension E1 on int show num { +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:9:17: Error: A extension declaration must have a body, even if it is empty. +// Try adding an empty body. +// extension E2 on int show num hide ceil { +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:9:26: Error: Expected ';' after this. +// extension E2 on int show num hide ceil { +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:9:26: Error: 'num' is already declared in this scope. +// extension E2 on int show num hide ceil { +// ^^^ +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:5:26: Context: Previous declaration of 'num'. +// extension E1 on int show num { +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:9:35: Error: A function declaration needs an explicit list of parameters. +// Try adding a parameter list to the function declaration. +// extension E2 on int show num hide ceil { +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:14:17: Error: A extension declaration must have a body, even if it is empty. +// Try adding an empty body. +// extension E3 on int hide isEven { +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:14:26: Error: A function declaration needs an explicit list of parameters. +// Try adding a parameter list to the function declaration. +// extension E3 on int hide isEven { +// ^^^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:5:21: Error: Type 'show' not found. +// extension E1 on int show num { +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:9:21: Error: Type 'show' not found. +// extension E2 on int show num hide ceil { +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:9:30: Error: Type 'hide' not found. +// extension E2 on int show num hide ceil { +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:14:21: Error: Type 'hide' not found. +// extension E3 on int hide isEven { +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:6:3: Error: A non-null value must be returned since the return type 'int' doesn't allow null. +// int ceil() {} // Error. +// ^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:9:21: Error: 'show' isn't a type. +// extension E2 on int show num hide ceil { +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:10:3: Error: A non-null value must be returned since the return type 'int' doesn't allow null. +// int ceil() {} // Ok. +// ^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:11:3: Error: A non-null value must be returned since the return type 'int' doesn't allow null. +// int floor() {} // Error. +// ^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:16:8: Error: Expected ';' after this. +// bool get isOdd => throw 42; // Error. +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:16:18: Error: A function declaration needs an explicit list of parameters. +// Try adding a parameter list to the function declaration. +// bool get isOdd => throw 42; // Error. +// ^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:17:8: Error: 'get' is already declared in this scope. +// bool get isEven => throw 42; // Ok. +// ^^^ +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:16:8: Context: Previous declaration of 'get'. +// bool get isOdd => throw 42; // Error. +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:17:8: Error: Expected ';' after this. +// bool get isEven => throw 42; // Ok. +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:17:19: Error: A function declaration needs an explicit list of parameters. +// Try adding a parameter list to the function declaration. +// bool get isEven => throw 42; // Ok. +// ^^ +// +import self as self; +import "dart:core" as core; + +extension E1 on core::int { +} +extension E2 on core::int { +} +extension E3 on core::int { +} +static method num() → invalid-type { + function ceil() → core::int { + return let final Never #t1 = invalid-expression "pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:6:3: Error: A non-null value must be returned since the return type 'int' doesn't allow null. + int ceil() {} // Error. + ^" in null; + } +} +static method ceil() → invalid-type { + function ceil() → core::int { + return let final Never #t2 = invalid-expression "pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:10:3: Error: A non-null value must be returned since the return type 'int' doesn't allow null. + int ceil() {} // Ok. + ^" in null; + } + function floor() → core::int { + return let final Never #t3 = invalid-expression "pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:11:3: Error: A non-null value must be returned since the return type 'int' doesn't allow null. + int floor() {} // Error. + ^" in null; + } +} +static method isEven() → invalid-type { + core::bool get; + function isOdd() → Never + return throw 42; + core::bool get = invalid-expression "pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:17:8: Error: 'get' is already declared in this scope. + bool get isEven => throw 42; // Ok. + ^^^"; + function isEven() → Never + return throw 42; +} +static method main() → dynamic {} diff --git a/pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart.textual_outline.expect b/pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart.textual_outline.expect new file mode 100644 index 0000000000000..b92215ce9e06d --- /dev/null +++ b/pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart.textual_outline.expect @@ -0,0 +1,13 @@ +extension E1 on int {} + +show num() {} + +extension E2 on int {} + +show num; +hide ceil() {} + +extension E3 on int {} + +hide isEven() {} +main() {} diff --git a/pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart.textual_outline_modelled.expect new file mode 100644 index 0000000000000..4d9e4897340a2 --- /dev/null +++ b/pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart.textual_outline_modelled.expect @@ -0,0 +1,11 @@ +extension E1 on int {} + +extension E2 on int {} + +extension E3 on int {} + +hide ceil() {} +hide isEven() {} +main() {} +show num() {} +show num; diff --git a/pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart.weak.expect b/pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart.weak.expect new file mode 100644 index 0000000000000..6d6816022c995 --- /dev/null +++ b/pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart.weak.expect @@ -0,0 +1,141 @@ +library /*isNonNullableByDefault*/; +// +// Problems in library: +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:5:17: Error: A extension declaration must have a body, even if it is empty. +// Try adding an empty body. +// extension E1 on int show num { +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:5:26: Error: A function declaration needs an explicit list of parameters. +// Try adding a parameter list to the function declaration. +// extension E1 on int show num { +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:9:17: Error: A extension declaration must have a body, even if it is empty. +// Try adding an empty body. +// extension E2 on int show num hide ceil { +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:9:26: Error: Expected ';' after this. +// extension E2 on int show num hide ceil { +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:9:26: Error: 'num' is already declared in this scope. +// extension E2 on int show num hide ceil { +// ^^^ +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:5:26: Context: Previous declaration of 'num'. +// extension E1 on int show num { +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:9:35: Error: A function declaration needs an explicit list of parameters. +// Try adding a parameter list to the function declaration. +// extension E2 on int show num hide ceil { +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:14:17: Error: A extension declaration must have a body, even if it is empty. +// Try adding an empty body. +// extension E3 on int hide isEven { +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:14:26: Error: A function declaration needs an explicit list of parameters. +// Try adding a parameter list to the function declaration. +// extension E3 on int hide isEven { +// ^^^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:5:21: Error: Type 'show' not found. +// extension E1 on int show num { +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:9:21: Error: Type 'show' not found. +// extension E2 on int show num hide ceil { +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:9:30: Error: Type 'hide' not found. +// extension E2 on int show num hide ceil { +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:14:21: Error: Type 'hide' not found. +// extension E3 on int hide isEven { +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:6:3: Error: A non-null value must be returned since the return type 'int' doesn't allow null. +// int ceil() {} // Error. +// ^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:9:21: Error: 'show' isn't a type. +// extension E2 on int show num hide ceil { +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:10:3: Error: A non-null value must be returned since the return type 'int' doesn't allow null. +// int ceil() {} // Ok. +// ^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:11:3: Error: A non-null value must be returned since the return type 'int' doesn't allow null. +// int floor() {} // Error. +// ^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:16:8: Error: Expected ';' after this. +// bool get isOdd => throw 42; // Error. +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:16:18: Error: A function declaration needs an explicit list of parameters. +// Try adding a parameter list to the function declaration. +// bool get isOdd => throw 42; // Error. +// ^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:17:8: Error: 'get' is already declared in this scope. +// bool get isEven => throw 42; // Ok. +// ^^^ +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:16:8: Context: Previous declaration of 'get'. +// bool get isOdd => throw 42; // Error. +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:17:8: Error: Expected ';' after this. +// bool get isEven => throw 42; // Ok. +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:17:19: Error: A function declaration needs an explicit list of parameters. +// Try adding a parameter list to the function declaration. +// bool get isEven => throw 42; // Ok. +// ^^ +// +import self as self; +import "dart:core" as core; + +extension E1 on core::int { +} +extension E2 on core::int { +} +extension E3 on core::int { +} +static method num() → invalid-type { + function ceil() → core::int { + return let final Never #t1 = invalid-expression "pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:6:3: Error: A non-null value must be returned since the return type 'int' doesn't allow null. + int ceil() {} // Error. + ^" in null; + } +} +static method ceil() → invalid-type { + function ceil() → core::int { + return let final Never #t2 = invalid-expression "pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:10:3: Error: A non-null value must be returned since the return type 'int' doesn't allow null. + int ceil() {} // Ok. + ^" in null; + } + function floor() → core::int { + return let final Never #t3 = invalid-expression "pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:11:3: Error: A non-null value must be returned since the return type 'int' doesn't allow null. + int floor() {} // Error. + ^" in null; + } +} +static method isEven() → invalid-type { + core::bool get; + function isOdd() → Never + return throw 42; + core::bool get = invalid-expression "pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:17:8: Error: 'get' is already declared in this scope. + bool get isEven => throw 42; // Ok. + ^^^" as{TypeError,ForDynamic,ForNonNullableByDefault} core::bool; + function isEven() → Never + return throw 42; +} +static method main() → dynamic {} diff --git a/pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart.weak.outline.expect b/pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart.weak.outline.expect new file mode 100644 index 0000000000000..5c680711d20d5 --- /dev/null +++ b/pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart.weak.outline.expect @@ -0,0 +1,78 @@ +library /*isNonNullableByDefault*/; +// +// Problems in library: +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:5:17: Error: A extension declaration must have a body, even if it is empty. +// Try adding an empty body. +// extension E1 on int show num { +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:5:26: Error: A function declaration needs an explicit list of parameters. +// Try adding a parameter list to the function declaration. +// extension E1 on int show num { +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:9:17: Error: A extension declaration must have a body, even if it is empty. +// Try adding an empty body. +// extension E2 on int show num hide ceil { +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:9:26: Error: Expected ';' after this. +// extension E2 on int show num hide ceil { +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:9:26: Error: 'num' is already declared in this scope. +// extension E2 on int show num hide ceil { +// ^^^ +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:5:26: Context: Previous declaration of 'num'. +// extension E1 on int show num { +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:9:35: Error: A function declaration needs an explicit list of parameters. +// Try adding a parameter list to the function declaration. +// extension E2 on int show num hide ceil { +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:14:17: Error: A extension declaration must have a body, even if it is empty. +// Try adding an empty body. +// extension E3 on int hide isEven { +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:14:26: Error: A function declaration needs an explicit list of parameters. +// Try adding a parameter list to the function declaration. +// extension E3 on int hide isEven { +// ^^^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:5:21: Error: Type 'show' not found. +// extension E1 on int show num { +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:9:21: Error: Type 'show' not found. +// extension E2 on int show num hide ceil { +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:9:30: Error: Type 'hide' not found. +// extension E2 on int show num hide ceil { +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:14:21: Error: Type 'hide' not found. +// extension E3 on int hide isEven { +// ^^^^ +// +import self as self; +import "dart:core" as core; + +extension E1 on core::int { +} +extension E2 on core::int { +} +extension E3 on core::int { +} +static method num() → invalid-type + ; +static method ceil() → invalid-type + ; +static method isEven() → invalid-type + ; +static method main() → dynamic + ; diff --git a/pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart.weak.transformed.expect b/pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart.weak.transformed.expect new file mode 100644 index 0000000000000..9fe722e4caac2 --- /dev/null +++ b/pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart.weak.transformed.expect @@ -0,0 +1,141 @@ +library /*isNonNullableByDefault*/; +// +// Problems in library: +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:5:17: Error: A extension declaration must have a body, even if it is empty. +// Try adding an empty body. +// extension E1 on int show num { +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:5:26: Error: A function declaration needs an explicit list of parameters. +// Try adding a parameter list to the function declaration. +// extension E1 on int show num { +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:9:17: Error: A extension declaration must have a body, even if it is empty. +// Try adding an empty body. +// extension E2 on int show num hide ceil { +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:9:26: Error: Expected ';' after this. +// extension E2 on int show num hide ceil { +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:9:26: Error: 'num' is already declared in this scope. +// extension E2 on int show num hide ceil { +// ^^^ +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:5:26: Context: Previous declaration of 'num'. +// extension E1 on int show num { +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:9:35: Error: A function declaration needs an explicit list of parameters. +// Try adding a parameter list to the function declaration. +// extension E2 on int show num hide ceil { +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:14:17: Error: A extension declaration must have a body, even if it is empty. +// Try adding an empty body. +// extension E3 on int hide isEven { +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:14:26: Error: A function declaration needs an explicit list of parameters. +// Try adding a parameter list to the function declaration. +// extension E3 on int hide isEven { +// ^^^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:5:21: Error: Type 'show' not found. +// extension E1 on int show num { +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:9:21: Error: Type 'show' not found. +// extension E2 on int show num hide ceil { +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:9:30: Error: Type 'hide' not found. +// extension E2 on int show num hide ceil { +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:14:21: Error: Type 'hide' not found. +// extension E3 on int hide isEven { +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:6:3: Error: A non-null value must be returned since the return type 'int' doesn't allow null. +// int ceil() {} // Error. +// ^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:9:21: Error: 'show' isn't a type. +// extension E2 on int show num hide ceil { +// ^^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:10:3: Error: A non-null value must be returned since the return type 'int' doesn't allow null. +// int ceil() {} // Ok. +// ^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:11:3: Error: A non-null value must be returned since the return type 'int' doesn't allow null. +// int floor() {} // Error. +// ^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:16:8: Error: Expected ';' after this. +// bool get isOdd => throw 42; // Error. +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:16:18: Error: A function declaration needs an explicit list of parameters. +// Try adding a parameter list to the function declaration. +// bool get isOdd => throw 42; // Error. +// ^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:17:8: Error: 'get' is already declared in this scope. +// bool get isEven => throw 42; // Ok. +// ^^^ +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:16:8: Context: Previous declaration of 'get'. +// bool get isOdd => throw 42; // Error. +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:17:8: Error: Expected ';' after this. +// bool get isEven => throw 42; // Ok. +// ^^^ +// +// pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:17:19: Error: A function declaration needs an explicit list of parameters. +// Try adding a parameter list to the function declaration. +// bool get isEven => throw 42; // Ok. +// ^^ +// +import self as self; +import "dart:core" as core; + +extension E1 on core::int { +} +extension E2 on core::int { +} +extension E3 on core::int { +} +static method num() → invalid-type { + function ceil() → core::int { + return let final Never #t1 = invalid-expression "pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:6:3: Error: A non-null value must be returned since the return type 'int' doesn't allow null. + int ceil() {} // Error. + ^" in null; + } +} +static method ceil() → invalid-type { + function ceil() → core::int { + return let final Never #t2 = invalid-expression "pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:10:3: Error: A non-null value must be returned since the return type 'int' doesn't allow null. + int ceil() {} // Ok. + ^" in null; + } + function floor() → core::int { + return let final Never #t3 = invalid-expression "pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:11:3: Error: A non-null value must be returned since the return type 'int' doesn't allow null. + int floor() {} // Error. + ^" in null; + } +} +static method isEven() → invalid-type { + core::bool get; + function isOdd() → Never + return throw 42; + core::bool get = invalid-expression "pkg/front_end/testcases/extension_types/simple_show_hide_conflicts.dart:17:8: Error: 'get' is already declared in this scope. + bool get isEven => throw 42; // Ok. + ^^^"; + function isEven() → Never + return throw 42; +} +static method main() → dynamic {} diff --git a/pkg/front_end/testcases/outline.status b/pkg/front_end/testcases/outline.status index 4f83215f7df8e..a59e9fd676086 100644 --- a/pkg/front_end/testcases/outline.status +++ b/pkg/front_end/testcases/outline.status @@ -9,6 +9,7 @@ extension_types/simple_getter_resolution: ExpectationFileMismatchSerialized extension_types/simple_method_resolution: ExpectationFileMismatchSerialized extension_types/simple_operator_resolution: ExpectationFileMismatchSerialized extension_types/simple_setter_resolution: ExpectationFileMismatchSerialized +extension_types/simple_show_hide: ExpectationFileMismatchSerialized # Expected. general/abstract_members: TypeCheckError general/bug30695: TypeCheckError general/covariant_field: TypeCheckError diff --git a/pkg/front_end/testcases/strong.status b/pkg/front_end/testcases/strong.status index 130bcfbda15c0..7c958cedde1bd 100644 --- a/pkg/front_end/testcases/strong.status +++ b/pkg/front_end/testcases/strong.status @@ -21,6 +21,7 @@ extension_types/simple_getter_resolution: ExpectationFileMismatchSerialized # Ex extension_types/simple_method_resolution: ExpectationFileMismatchSerialized # Expected. extension_types/simple_operator_resolution: ExpectationFileMismatchSerialized # Expected. extension_types/simple_setter_resolution: ExpectationFileMismatchSerialized # Expected. +extension_types/simple_show_hide: ExpectationFileMismatchSerialized # Expected. late_lowering/covariant_late_field: TypeCheckError nnbd/covariant_late_field: TypeCheckError nnbd/getter_vs_setter_type: TypeCheckError diff --git a/pkg/front_end/testcases/text_serialization.status b/pkg/front_end/testcases/text_serialization.status index bf8ca1a77ef2d..9f5f24a5ba119 100644 --- a/pkg/front_end/testcases/text_serialization.status +++ b/pkg/front_end/testcases/text_serialization.status @@ -19,6 +19,7 @@ extension_types/simple_getter_resolution: ExpectationFileMismatchSerialized # Ex extension_types/simple_method_resolution: ExpectationFileMismatchSerialized # Expected. extension_types/simple_operator_resolution: ExpectationFileMismatchSerialized # Expected. extension_types/simple_setter_resolution: ExpectationFileMismatchSerialized # Expected. +extension_types/simple_show_hide: ExpectationFileMismatchSerialized # Expected. extensions/extension_setter_error: TypeCheckError extensions/instance_access_of_static: RuntimeError extensions/invalid_explicit_access: RuntimeError diff --git a/pkg/front_end/testcases/textual_outline.status b/pkg/front_end/testcases/textual_outline.status index 2029725e7f717..ed0e7e4c7a7e9 100644 --- a/pkg/front_end/testcases/textual_outline.status +++ b/pkg/front_end/testcases/textual_outline.status @@ -52,6 +52,7 @@ extension_types/simple_getter_resolution: FormatterCrash extension_types/simple_method_resolution: FormatterCrash extension_types/simple_operator_resolution: FormatterCrash extension_types/simple_setter_resolution: FormatterCrash +extension_types/simple_show_hide: FormatterCrash extensions/extension_constructor: FormatterCrash extensions/extension_field_with_type_parameter_usage: FormatterCrash extensions/issue38600: FormatterCrash diff --git a/pkg/front_end/testcases/weak.status b/pkg/front_end/testcases/weak.status index f6c24b7edba09..803d18f70e1ee 100644 --- a/pkg/front_end/testcases/weak.status +++ b/pkg/front_end/testcases/weak.status @@ -24,6 +24,7 @@ extension_types/simple_getter_resolution: ExpectationFileMismatchSerialized # Ex extension_types/simple_method_resolution: ExpectationFileMismatchSerialized # Expected. extension_types/simple_operator_resolution: ExpectationFileMismatchSerialized # Expected. extension_types/simple_setter_resolution: ExpectationFileMismatchSerialized # Expected. +extension_types/simple_show_hide: ExpectationFileMismatchSerialized # Expected. extensions/extension_setter_error: TypeCheckError extensions/instance_access_of_static: RuntimeError extensions/invalid_explicit_access: RuntimeError From b05892efa124ed8325b2537e16aefb1c0e8a396b Mon Sep 17 00:00:00 2001 From: Johnni Winther Date: Fri, 30 Jul 2021 11:28:04 +0000 Subject: [PATCH 2/2] [cfe] Report compile time error on evaluation of const external constructors Closes #46123 Change-Id: I91e9b789683b2bd6acb3b4f559ecce6e70f18afc Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/207001 Reviewed-by: Dmitry Stefantsov Commit-Queue: Johnni Winther --- .../lib/src/messages/codes_generated.dart | 19 +++++++ .../compute_platform_binaries_location.dart | 12 ++++- .../fasta/builder/constructor_builder.dart | 24 +++++++-- .../src/fasta/builder/factory_builder.dart | 47 ++++++++++++----- .../lib/src/fasta/incremental_compiler.dart | 2 +- .../src/fasta/kernel/constant_evaluator.dart | 51 +++++++++++-------- .../src/fasta/kernel/kernel_constants.dart | 11 ++++ pkg/front_end/lib/src/fasta/loader.dart | 12 +++++ pkg/front_end/messages.status | 4 ++ pkg/front_end/messages.yaml | 6 +++ .../test/spell_checking_list_code.txt | 1 + .../test/spell_checking_list_tests.txt | 1 + pkg/front_end/testcases/dartdevc/symbol.dart | 5 ++ .../dartdevc/symbol.dart.strong.expect | 10 ++++ .../symbol.dart.strong.transformed.expect | 10 ++++ .../symbol.dart.textual_outline.expect | 1 + ...ymbol.dart.textual_outline_modelled.expect | 1 + .../dartdevc/symbol.dart.weak.expect | 10 ++++ .../dartdevc/symbol.dart.weak.outline.expect | 5 ++ .../symbol.dart.weak.transformed.expect | 10 ++++ .../constants/js_semantics/issue46123.dart | 15 ++++++ .../issue46123.dart.textual_outline.expect | 10 ++++ ...46123.dart.textual_outline_modelled.expect | 10 ++++ .../js_semantics/issue46123.dart.weak.expect | 37 ++++++++++++++ .../issue46123.dart.weak.outline.expect | 22 ++++++++ .../issue46123.dart.weak.transformed.expect | 37 ++++++++++++++ .../constants/js_semantics/issue46123b.dart | 15 ++++++ .../issue46123b.dart.textual_outline.expect | 10 ++++ ...6123b.dart.textual_outline_modelled.expect | 10 ++++ .../js_semantics/issue46123b.dart.weak.expect | 39 ++++++++++++++ .../issue46123b.dart.weak.outline.expect | 24 +++++++++ .../issue46123b.dart.weak.transformed.expect | 39 ++++++++++++++ .../general/constructor_patch/libraries.json | 12 +++++ .../general/constructor_patch/main.dart | 10 ++++ .../main.dart.textual_outline.expect | 3 ++ .../main.dart.textual_outline_modelled.expect | 3 ++ .../constructor_patch/main.dart.weak.expect | 42 +++++++++++++++ .../main.dart.weak.outline.expect | 33 ++++++++++++ .../main.dart.weak.transformed.expect | 42 +++++++++++++++ .../general/constructor_patch/origin_lib.dart | 8 +++ .../general/constructor_patch/patch_lib.dart | 17 +++++++ .../factory_patch/main.dart.weak.expect | 12 +++++ .../main.dart.weak.outline.expect | 7 ++- .../main.dart.weak.transformed.expect | 12 +++++ .../general/factory_patch/origin_lib.dart | 2 +- .../general/factory_patch/patch_lib.dart | 5 +- .../issue45101/main.dart.weak.outline.expect | 4 +- pkg/front_end/tool/dart_doctest_impl.dart | 2 +- 48 files changed, 674 insertions(+), 50 deletions(-) create mode 100644 pkg/front_end/testcases/dartdevc/symbol.dart create mode 100644 pkg/front_end/testcases/dartdevc/symbol.dart.strong.expect create mode 100644 pkg/front_end/testcases/dartdevc/symbol.dart.strong.transformed.expect create mode 100644 pkg/front_end/testcases/dartdevc/symbol.dart.textual_outline.expect create mode 100644 pkg/front_end/testcases/dartdevc/symbol.dart.textual_outline_modelled.expect create mode 100644 pkg/front_end/testcases/dartdevc/symbol.dart.weak.expect create mode 100644 pkg/front_end/testcases/dartdevc/symbol.dart.weak.outline.expect create mode 100644 pkg/front_end/testcases/dartdevc/symbol.dart.weak.transformed.expect create mode 100644 pkg/front_end/testcases/general/constants/js_semantics/issue46123.dart create mode 100644 pkg/front_end/testcases/general/constants/js_semantics/issue46123.dart.textual_outline.expect create mode 100644 pkg/front_end/testcases/general/constants/js_semantics/issue46123.dart.textual_outline_modelled.expect create mode 100644 pkg/front_end/testcases/general/constants/js_semantics/issue46123.dart.weak.expect create mode 100644 pkg/front_end/testcases/general/constants/js_semantics/issue46123.dart.weak.outline.expect create mode 100644 pkg/front_end/testcases/general/constants/js_semantics/issue46123.dart.weak.transformed.expect create mode 100644 pkg/front_end/testcases/general/constants/js_semantics/issue46123b.dart create mode 100644 pkg/front_end/testcases/general/constants/js_semantics/issue46123b.dart.textual_outline.expect create mode 100644 pkg/front_end/testcases/general/constants/js_semantics/issue46123b.dart.textual_outline_modelled.expect create mode 100644 pkg/front_end/testcases/general/constants/js_semantics/issue46123b.dart.weak.expect create mode 100644 pkg/front_end/testcases/general/constants/js_semantics/issue46123b.dart.weak.outline.expect create mode 100644 pkg/front_end/testcases/general/constants/js_semantics/issue46123b.dart.weak.transformed.expect create mode 100644 pkg/front_end/testcases/general/constructor_patch/libraries.json create mode 100644 pkg/front_end/testcases/general/constructor_patch/main.dart create mode 100644 pkg/front_end/testcases/general/constructor_patch/main.dart.textual_outline.expect create mode 100644 pkg/front_end/testcases/general/constructor_patch/main.dart.textual_outline_modelled.expect create mode 100644 pkg/front_end/testcases/general/constructor_patch/main.dart.weak.expect create mode 100644 pkg/front_end/testcases/general/constructor_patch/main.dart.weak.outline.expect create mode 100644 pkg/front_end/testcases/general/constructor_patch/main.dart.weak.transformed.expect create mode 100644 pkg/front_end/testcases/general/constructor_patch/origin_lib.dart create mode 100644 pkg/front_end/testcases/general/constructor_patch/patch_lib.dart diff --git a/pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart b/pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart index 5be60d4799746..2ccb2992d06d8 100644 --- a/pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart +++ b/pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart @@ -1327,6 +1327,25 @@ const MessageCode messageConstEvalExtension = const MessageCode( message: r"""Extension operations can't be used in constant expressions."""); +// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. +const Code codeConstEvalExternalConstructor = + messageConstEvalExternalConstructor; + +// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. +const MessageCode messageConstEvalExternalConstructor = const MessageCode( + "ConstEvalExternalConstructor", + message: + r"""External constructors can't be evaluated in constant expressions."""); + +// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. +const Code codeConstEvalExternalFactory = messageConstEvalExternalFactory; + +// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. +const MessageCode messageConstEvalExternalFactory = const MessageCode( + "ConstEvalExternalFactory", + message: + r"""External factory constructors can't be evaluated in constant expressions."""); + // DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. const Code codeConstEvalFailedAssertion = messageConstEvalFailedAssertion; diff --git a/pkg/front_end/lib/src/compute_platform_binaries_location.dart b/pkg/front_end/lib/src/compute_platform_binaries_location.dart index 0ecacc073fbb1..96039c47d956d 100644 --- a/pkg/front_end/lib/src/compute_platform_binaries_location.dart +++ b/pkg/front_end/lib/src/compute_platform_binaries_location.dart @@ -23,9 +23,17 @@ String? computePlatformDillName( case 'dartdevc': switch (nnbdMode) { case NnbdMode.Strong: - return 'ddc_platform_sound.dill'; + // DDC is always compiled against the outline so we use it here by + // default. + return 'ddc_outline_sound.dill'; + //TODO(johnniwinther): Support using the full dill. + //return 'ddc_platform_sound.dill'; case NnbdMode.Weak: - return 'ddc_platform.dill'; + // DDC is always compiled against the outline so we use it here by + // default. + return 'ddc_outline.dill'; + //TODO(johnniwinther): Support using the full dill. + //return 'ddc_platform.dill'; case NnbdMode.Agnostic: break; } diff --git a/pkg/front_end/lib/src/fasta/builder/constructor_builder.dart b/pkg/front_end/lib/src/fasta/builder/constructor_builder.dart index 98068cb5022d6..4d0f32a411964 100644 --- a/pkg/front_end/lib/src/fasta/builder/constructor_builder.dart +++ b/pkg/front_end/lib/src/fasta/builder/constructor_builder.dart @@ -247,12 +247,19 @@ class ConstructorBuilderImpl extends FunctionBuilderImpl } } + bool _hasBuiltOutlines = false; + @override void buildOutlineExpressions( SourceLibraryBuilder library, CoreTypes coreTypes, List delayedActionPerformers, List synthesizedFunctionNodes) { + if (_hasBuiltOutlines) return; + if (isConst && isPatch) { + origin.buildOutlineExpressions(library, coreTypes, + delayedActionPerformers, synthesizedFunctionNodes); + } super.buildOutlineExpressions( library, coreTypes, delayedActionPerformers, synthesizedFunctionNodes); @@ -267,6 +274,10 @@ class ConstructorBuilderImpl extends FunctionBuilderImpl bodyBuilder.resolveRedirectingFactoryTargets(); } beginInitializers = null; + if (isConst && isPatch) { + _finishPatch(); + } + _hasBuiltOutlines = true; } @override @@ -388,10 +399,7 @@ class ConstructorBuilderImpl extends FunctionBuilderImpl return null; } - @override - int finishPatch() { - if (!isPatch) return 0; - + void _finishPatch() { // TODO(ahe): restore file-offset once we track both origin and patch file // URIs. See https://github.com/dart-lang/sdk/issues/31579 origin.constructor.fileUri = fileUri; @@ -406,6 +414,12 @@ class ConstructorBuilderImpl extends FunctionBuilderImpl origin.constructor.function.parent = origin.constructor; origin.constructor.initializers = _constructor.initializers; setParents(origin.constructor.initializers, origin.constructor); + } + + @override + int finishPatch() { + if (!isPatch) return 0; + _finishPatch(); return 1; } @@ -438,7 +452,7 @@ class ConstructorBuilderImpl extends FunctionBuilderImpl // compile), and so we also clear them. // Note: this method clears both initializers from the target Kernel node // and internal state associated with parsing initializers. - _constructor.initializers.length = 0; + _constructor.initializers = []; redirectingInitializer = null; superInitializer = null; hasMovedSuperInitializer = false; diff --git a/pkg/front_end/lib/src/fasta/builder/factory_builder.dart b/pkg/front_end/lib/src/fasta/builder/factory_builder.dart index 8b6c13eae1bf4..22e54cbb676fd 100644 --- a/pkg/front_end/lib/src/fasta/builder/factory_builder.dart +++ b/pkg/front_end/lib/src/fasta/builder/factory_builder.dart @@ -160,6 +160,20 @@ class SourceFactoryBuilder extends FunctionBuilderImpl { return _procedureInternal; } + bool _hasBuiltOutlines = false; + + @override + void buildOutlineExpressions( + SourceLibraryBuilder library, + CoreTypes coreTypes, + List delayedActionPerformers, + List synthesizedFunctionNodes) { + if (_hasBuiltOutlines) return; + super.buildOutlineExpressions( + library, coreTypes, delayedActionPerformers, synthesizedFunctionNodes); + _hasBuiltOutlines = true; + } + @override VariableDeclaration? getTearOffParameter(int index) { if (_factoryTearOff != null) { @@ -213,10 +227,7 @@ class SourceFactoryBuilder extends FunctionBuilderImpl { } } - @override - int finishPatch() { - if (!isPatch) return 0; - + void _finishPatch() { // TODO(ahe): restore file-offset once we track both origin and patch file // URIs. See https://github.com/dart-lang/sdk/issues/31579 origin._procedure.fileUri = fileUri; @@ -232,6 +243,12 @@ class SourceFactoryBuilder extends FunctionBuilderImpl { origin._procedure.function.parent = origin._procedure; origin._procedure.isRedirectingFactory = _procedureInternal.isRedirectingFactory; + } + + @override + int finishPatch() { + if (!isPatch) return 0; + _finishPatch(); return 1; } } @@ -347,16 +364,23 @@ class RedirectingFactoryBuilder extends SourceFactoryBuilder { return _procedureInternal; } + bool _hasBuiltOutlines = false; + @override void buildOutlineExpressions( SourceLibraryBuilder library, CoreTypes coreTypes, List delayedActionPerformers, List synthesizedFunctionNodes) { + if (_hasBuiltOutlines) return; + if (isConst && isPatch) { + origin.buildOutlineExpressions(library, coreTypes, + delayedActionPerformers, synthesizedFunctionNodes); + } super.buildOutlineExpressions( library, coreTypes, delayedActionPerformers, synthesizedFunctionNodes); RedirectingFactoryBody redirectingFactoryBody = - _procedure.function.body as RedirectingFactoryBody; + _procedureInternal.function.body as RedirectingFactoryBody; List? typeArguments = redirectingFactoryBody.typeArguments; Member? target = redirectingFactoryBody.target; if (typeArguments != null && typeArguments.any((t) => t is UnknownType)) { @@ -422,20 +446,19 @@ class RedirectingFactoryBuilder extends SourceFactoryBuilder { typeArguments ?? [], _tearOffTypeParameters!)); } + if (isConst && isPatch) { + _finishPatch(); + } + _hasBuiltOutlines = true; } - @override - int finishPatch() { - if (!isPatch) return 0; - - super.finishPatch(); + void _finishPatch() { + super._finishPatch(); SourceFactoryBuilder redirectingOrigin = origin; if (redirectingOrigin is RedirectingFactoryBuilder) { redirectingOrigin.typeArguments = typeArguments; } - - return 1; } List? getTypeArguments() { diff --git a/pkg/front_end/lib/src/fasta/incremental_compiler.dart b/pkg/front_end/lib/src/fasta/incremental_compiler.dart index cb1f2a1407601..48bbed7e4d7db 100644 --- a/pkg/front_end/lib/src/fasta/incremental_compiler.dart +++ b/pkg/front_end/lib/src/fasta/incremental_compiler.dart @@ -1918,7 +1918,7 @@ class IncrementalCompiler implements IncrementalKernelGenerator { if (cls == null) return null; } - userCode!.loader.seenMessages.clear(); + userCode!.loader.resetSeenMessages(); for (TypeParameter typeParam in typeDefinitions) { if (!isLegalIdentifier(typeParam.name!)) { diff --git a/pkg/front_end/lib/src/fasta/kernel/constant_evaluator.dart b/pkg/front_end/lib/src/fasta/kernel/constant_evaluator.dart index 12ee6bb11d01b..d365898dd690e 100644 --- a/pkg/front_end/lib/src/fasta/kernel/constant_evaluator.dart +++ b/pkg/front_end/lib/src/fasta/kernel/constant_evaluator.dart @@ -41,6 +41,8 @@ import '../fasta_codes.dart' messageConstEvalCircularity, messageConstEvalContext, messageConstEvalExtension, + messageConstEvalExternalConstructor, + messageConstEvalExternalFactory, messageConstEvalFailedAssertion, messageConstEvalNotListOrSetInSpread, messageConstEvalNotMapInSpread, @@ -1652,6 +1654,8 @@ class ConstantEvaluator implements ExpressionVisitor { node, 'Constructor "$node" has non-trivial body ' '"${constructor.function.body.runtimeType}".'); + } else if (constructor.isExternal) { + return createErrorConstant(node, messageConstEvalExternalConstructor); } return null; } @@ -3012,30 +3016,33 @@ class ConstantEvaluator implements ExpressionVisitor { isConst: true)); } if (target.kind == ProcedureKind.Factory) { - if (target.isConst && - target.enclosingLibrary == coreTypes.coreLibrary && - positionals.length == 1 && - (target.name.text == "fromEnvironment" || - target.name.text == "hasEnvironment")) { - if (environmentDefines != null) { - // Evaluate environment constant. - Constant name = positionals.single; - if (name is StringConstant) { - if (target.name.text == "fromEnvironment") { - return _handleFromEnvironment(target, name, named); - } else { - return _handleHasEnvironment(name); + if (target.isConst) { + if (target.enclosingLibrary == coreTypes.coreLibrary && + positionals.length == 1 && + (target.name.text == "fromEnvironment" || + target.name.text == "hasEnvironment")) { + if (environmentDefines != null) { + // Evaluate environment constant. + Constant name = positionals.single; + if (name is StringConstant) { + if (target.name.text == "fromEnvironment") { + return _handleFromEnvironment(target, name, named); + } else { + return _handleHasEnvironment(name); + } + } else if (name is NullConstant) { + return createErrorConstant(node, messageConstEvalNullValue); } - } else if (name is NullConstant) { - return createErrorConstant(node, messageConstEvalNullValue); + } else { + // Leave environment constant unevaluated. + return unevaluated( + node, + new StaticInvocation(target, + unevaluatedArguments(positionals, named, arguments.types), + isConst: true)); } - } else { - // Leave environment constant unevaluated. - return unevaluated( - node, - new StaticInvocation(target, - unevaluatedArguments(positionals, named, arguments.types), - isConst: true)); + } else if (target.isExternal) { + return createErrorConstant(node, messageConstEvalExternalFactory); } } } else if (target.name.text == 'identical') { diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_constants.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_constants.dart index 6868aa7e0c99c..d0033faf0b33f 100644 --- a/pkg/front_end/lib/src/fasta/kernel/kernel_constants.dart +++ b/pkg/front_end/lib/src/fasta/kernel/kernel_constants.dart @@ -46,6 +46,17 @@ class KernelConstantErrorReporter extends ErrorReporter { @override void reportInvalidExpression(InvalidExpression node) { + // TODO(johnniwinther): Improve the precision of this assertion. Do we + // for instance allow warnings only to have been reported in previous + // compilations. + assert( + // Either we have already reported an error + loader.hasSeenError || + // or we have reported an error in a previous compilation. + loader.builders.values.any((builder) => + builder.library.problemsAsJson?.isNotEmpty ?? false), + "No error reported before seeing: " + "${node.message}"); // Assumed to be already reported. } } diff --git a/pkg/front_end/lib/src/fasta/loader.dart b/pkg/front_end/lib/src/fasta/loader.dart index 31aea3350c491..7dedab8ba7d42 100644 --- a/pkg/front_end/lib/src/fasta/loader.dart +++ b/pkg/front_end/lib/src/fasta/loader.dart @@ -81,6 +81,15 @@ abstract class Loader { final List allComponentProblems = []; final Set seenMessages = new Set(); + bool _hasSeenError = false; + + void resetSeenMessages() { + seenMessages.clear(); + _hasSeenError = false; + } + + /// Returns `true` if a compile time error has been reported. + bool get hasSeenError => _hasSeenError; LibraryBuilder? _coreLibrary; LibraryBuilder? typedDataLibrary; @@ -362,6 +371,9 @@ fileUri: $fileUri severity: $severity """; if (!seenMessages.add(trace)) return null; + if (message.code.severity == Severity.error) { + _hasSeenError = true; + } if (message.code.severity == Severity.context) { internalProblem( templateInternalProblemContextSeverity diff --git a/pkg/front_end/messages.status b/pkg/front_end/messages.status index b201a4cd2c9b1..ba2bc5527d72f 100644 --- a/pkg/front_end/messages.status +++ b/pkg/front_end/messages.status @@ -103,6 +103,10 @@ ConstEvalDuplicateElement/example: Fail ConstEvalDuplicateKey/example: Fail ConstEvalElementImplementsEqual/example: Fail ConstEvalExtension/example: Fail +ConstEvalExternalConstructor/analyzerCode: Fail +ConstEvalExternalConstructor/example: Fail +ConstEvalExternalFactory/analyzerCode: Fail +ConstEvalExternalFactory/example: Fail ConstEvalFailedAssertion/example: Fail ConstEvalFailedAssertionWithMessage/example: Fail ConstEvalFreeTypeParameter/analyzerCode: Fail diff --git a/pkg/front_end/messages.yaml b/pkg/front_end/messages.yaml index f0cb7198e221f..0873cbade0f43 100644 --- a/pkg/front_end/messages.yaml +++ b/pkg/front_end/messages.yaml @@ -219,6 +219,12 @@ ConstEvalExtension: template: "Extension operations can't be used in constant expressions." analyzerCode: NOT_CONSTANT_EXPRESSION +ConstEvalExternalConstructor: + template: "External constructors can't be evaluated in constant expressions." + +ConstEvalExternalFactory: + template: "External factory constructors can't be evaluated in constant expressions." + ConstEvalUnevaluated: template: "Couldn't evaluate constant expression." diff --git a/pkg/front_end/test/spell_checking_list_code.txt b/pkg/front_end/test/spell_checking_list_code.txt index ec72c29227e57..b0e58b263bce4 100644 --- a/pkg/front_end/test/spell_checking_list_code.txt +++ b/pkg/front_end/test/spell_checking_list_code.txt @@ -221,6 +221,7 @@ combine2 combiner compared compares +compilations completes complicating component's diff --git a/pkg/front_end/test/spell_checking_list_tests.txt b/pkg/front_end/test/spell_checking_list_tests.txt index ad13d986073f7..bb193c91c8fa0 100644 --- a/pkg/front_end/test/spell_checking_list_tests.txt +++ b/pkg/front_end/test/spell_checking_list_tests.txt @@ -702,6 +702,7 @@ ox pack paging paint +parallax parameterized party pause diff --git a/pkg/front_end/testcases/dartdevc/symbol.dart b/pkg/front_end/testcases/dartdevc/symbol.dart new file mode 100644 index 0000000000000..e899102024dd6 --- /dev/null +++ b/pkg/front_end/testcases/dartdevc/symbol.dart @@ -0,0 +1,5 @@ +// Copyright (c) 2021, 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. + +main() => const Symbol('a'); \ No newline at end of file diff --git a/pkg/front_end/testcases/dartdevc/symbol.dart.strong.expect b/pkg/front_end/testcases/dartdevc/symbol.dart.strong.expect new file mode 100644 index 0000000000000..d827f5b9125aa --- /dev/null +++ b/pkg/front_end/testcases/dartdevc/symbol.dart.strong.expect @@ -0,0 +1,10 @@ +library /*isNonNullableByDefault*/; +import self as self; +import "dart:_internal" as _in; + +static method main() → dynamic + return #C1; + +constants { + #C1 = #a +} diff --git a/pkg/front_end/testcases/dartdevc/symbol.dart.strong.transformed.expect b/pkg/front_end/testcases/dartdevc/symbol.dart.strong.transformed.expect new file mode 100644 index 0000000000000..d827f5b9125aa --- /dev/null +++ b/pkg/front_end/testcases/dartdevc/symbol.dart.strong.transformed.expect @@ -0,0 +1,10 @@ +library /*isNonNullableByDefault*/; +import self as self; +import "dart:_internal" as _in; + +static method main() → dynamic + return #C1; + +constants { + #C1 = #a +} diff --git a/pkg/front_end/testcases/dartdevc/symbol.dart.textual_outline.expect b/pkg/front_end/testcases/dartdevc/symbol.dart.textual_outline.expect new file mode 100644 index 0000000000000..3aa66461c9fb7 --- /dev/null +++ b/pkg/front_end/testcases/dartdevc/symbol.dart.textual_outline.expect @@ -0,0 +1 @@ +main() => const Symbol('a'); diff --git a/pkg/front_end/testcases/dartdevc/symbol.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/dartdevc/symbol.dart.textual_outline_modelled.expect new file mode 100644 index 0000000000000..3aa66461c9fb7 --- /dev/null +++ b/pkg/front_end/testcases/dartdevc/symbol.dart.textual_outline_modelled.expect @@ -0,0 +1 @@ +main() => const Symbol('a'); diff --git a/pkg/front_end/testcases/dartdevc/symbol.dart.weak.expect b/pkg/front_end/testcases/dartdevc/symbol.dart.weak.expect new file mode 100644 index 0000000000000..d827f5b9125aa --- /dev/null +++ b/pkg/front_end/testcases/dartdevc/symbol.dart.weak.expect @@ -0,0 +1,10 @@ +library /*isNonNullableByDefault*/; +import self as self; +import "dart:_internal" as _in; + +static method main() → dynamic + return #C1; + +constants { + #C1 = #a +} diff --git a/pkg/front_end/testcases/dartdevc/symbol.dart.weak.outline.expect b/pkg/front_end/testcases/dartdevc/symbol.dart.weak.outline.expect new file mode 100644 index 0000000000000..e2cba6be4d131 --- /dev/null +++ b/pkg/front_end/testcases/dartdevc/symbol.dart.weak.outline.expect @@ -0,0 +1,5 @@ +library /*isNonNullableByDefault*/; +import self as self; + +static method main() → dynamic + ; diff --git a/pkg/front_end/testcases/dartdevc/symbol.dart.weak.transformed.expect b/pkg/front_end/testcases/dartdevc/symbol.dart.weak.transformed.expect new file mode 100644 index 0000000000000..d827f5b9125aa --- /dev/null +++ b/pkg/front_end/testcases/dartdevc/symbol.dart.weak.transformed.expect @@ -0,0 +1,10 @@ +library /*isNonNullableByDefault*/; +import self as self; +import "dart:_internal" as _in; + +static method main() → dynamic + return #C1; + +constants { + #C1 = #a +} diff --git a/pkg/front_end/testcases/general/constants/js_semantics/issue46123.dart b/pkg/front_end/testcases/general/constants/js_semantics/issue46123.dart new file mode 100644 index 0000000000000..0210c32a91f0a --- /dev/null +++ b/pkg/front_end/testcases/general/constants/js_semantics/issue46123.dart @@ -0,0 +1,15 @@ +// Copyright (c) 2020, 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. + +import 'package:js/js.dart'; + +@JS() +@anonymous +class ParallaxOptions { + external const factory ParallaxOptions(); +} + +test() => const ParallaxOptions(); + +main() {} diff --git a/pkg/front_end/testcases/general/constants/js_semantics/issue46123.dart.textual_outline.expect b/pkg/front_end/testcases/general/constants/js_semantics/issue46123.dart.textual_outline.expect new file mode 100644 index 0000000000000..8b3f432752c1b --- /dev/null +++ b/pkg/front_end/testcases/general/constants/js_semantics/issue46123.dart.textual_outline.expect @@ -0,0 +1,10 @@ +import 'package:js/js.dart'; + +@JS() +@anonymous +class ParallaxOptions { + external const factory ParallaxOptions(); +} + +test() => const ParallaxOptions(); +main() {} diff --git a/pkg/front_end/testcases/general/constants/js_semantics/issue46123.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/general/constants/js_semantics/issue46123.dart.textual_outline_modelled.expect new file mode 100644 index 0000000000000..bef2d3d563a2d --- /dev/null +++ b/pkg/front_end/testcases/general/constants/js_semantics/issue46123.dart.textual_outline_modelled.expect @@ -0,0 +1,10 @@ +import 'package:js/js.dart'; + +@JS() +@anonymous +class ParallaxOptions { + external const factory ParallaxOptions(); +} + +main() {} +test() => const ParallaxOptions(); diff --git a/pkg/front_end/testcases/general/constants/js_semantics/issue46123.dart.weak.expect b/pkg/front_end/testcases/general/constants/js_semantics/issue46123.dart.weak.expect new file mode 100644 index 0000000000000..c1c307de5319c --- /dev/null +++ b/pkg/front_end/testcases/general/constants/js_semantics/issue46123.dart.weak.expect @@ -0,0 +1,37 @@ +library /*isNonNullableByDefault*/; +// +// Problems in library: +// +// pkg/front_end/testcases/general/constants/js_semantics/issue46123.dart:13:17: Error: Constant evaluation error: +// test() => const ParallaxOptions(); +// ^ +// pkg/front_end/testcases/general/constants/js_semantics/issue46123.dart:13:17: Context: External factory constructors can't be evaluated in constant expressions. +// test() => const ParallaxOptions(); +// ^ +// +import self as self; +import "package:js/js.dart" as js; +import "dart:core" as core; + +import "package:js/js.dart"; + +@#C2 +@#C3 +class ParallaxOptions extends core::Object { + external static factory •() → self::ParallaxOptions; +} +static method test() → dynamic + return invalid-expression "External factory constructors can't be evaluated in constant expressions."; +static method main() → dynamic {} + +constants { + #C1 = null + #C2 = js::JS {name:#C1} + #C3 = js::_Anonymous {} +} + + +Constructor coverage from constants: +org-dartlang-testcase:///issue46123.dart: +- JS. (from org-dartlang-testcase-sdk:///pkg/js/lib/js.dart:21:9) +- Object. (from org-dartlang-sdk:///lib/core/object.dart:25:9) diff --git a/pkg/front_end/testcases/general/constants/js_semantics/issue46123.dart.weak.outline.expect b/pkg/front_end/testcases/general/constants/js_semantics/issue46123.dart.weak.outline.expect new file mode 100644 index 0000000000000..d5602f8f12cde --- /dev/null +++ b/pkg/front_end/testcases/general/constants/js_semantics/issue46123.dart.weak.outline.expect @@ -0,0 +1,22 @@ +library /*isNonNullableByDefault*/; +import self as self; +import "package:js/js.dart" as js; +import "dart:core" as core; + +import "package:js/js.dart"; + +@js::JS::•() +@js::anonymous +class ParallaxOptions extends core::Object { + external static factory •() → self::ParallaxOptions; +} +static method test() → dynamic + ; +static method main() → dynamic + ; + + +Extra constant evaluation status: +Evaluated: ConstructorInvocation @ org-dartlang-testcase:///issue46123.dart:7:2 -> InstanceConstant(const JS{JS.name: null}) +Evaluated: StaticGet @ org-dartlang-testcase:///issue46123.dart:8:2 -> InstanceConstant(const _Anonymous{}) +Extra constant evaluation: evaluated: 2, effectively constant: 2 diff --git a/pkg/front_end/testcases/general/constants/js_semantics/issue46123.dart.weak.transformed.expect b/pkg/front_end/testcases/general/constants/js_semantics/issue46123.dart.weak.transformed.expect new file mode 100644 index 0000000000000..c1c307de5319c --- /dev/null +++ b/pkg/front_end/testcases/general/constants/js_semantics/issue46123.dart.weak.transformed.expect @@ -0,0 +1,37 @@ +library /*isNonNullableByDefault*/; +// +// Problems in library: +// +// pkg/front_end/testcases/general/constants/js_semantics/issue46123.dart:13:17: Error: Constant evaluation error: +// test() => const ParallaxOptions(); +// ^ +// pkg/front_end/testcases/general/constants/js_semantics/issue46123.dart:13:17: Context: External factory constructors can't be evaluated in constant expressions. +// test() => const ParallaxOptions(); +// ^ +// +import self as self; +import "package:js/js.dart" as js; +import "dart:core" as core; + +import "package:js/js.dart"; + +@#C2 +@#C3 +class ParallaxOptions extends core::Object { + external static factory •() → self::ParallaxOptions; +} +static method test() → dynamic + return invalid-expression "External factory constructors can't be evaluated in constant expressions."; +static method main() → dynamic {} + +constants { + #C1 = null + #C2 = js::JS {name:#C1} + #C3 = js::_Anonymous {} +} + + +Constructor coverage from constants: +org-dartlang-testcase:///issue46123.dart: +- JS. (from org-dartlang-testcase-sdk:///pkg/js/lib/js.dart:21:9) +- Object. (from org-dartlang-sdk:///lib/core/object.dart:25:9) diff --git a/pkg/front_end/testcases/general/constants/js_semantics/issue46123b.dart b/pkg/front_end/testcases/general/constants/js_semantics/issue46123b.dart new file mode 100644 index 0000000000000..ecc1c05e35637 --- /dev/null +++ b/pkg/front_end/testcases/general/constants/js_semantics/issue46123b.dart @@ -0,0 +1,15 @@ +// Copyright (c) 2020, 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. + +import 'package:js/js.dart'; + +@JS() +@anonymous +class ParallaxOptions { + external const ParallaxOptions(); +} + +test() => const ParallaxOptions(); + +main() {} diff --git a/pkg/front_end/testcases/general/constants/js_semantics/issue46123b.dart.textual_outline.expect b/pkg/front_end/testcases/general/constants/js_semantics/issue46123b.dart.textual_outline.expect new file mode 100644 index 0000000000000..2d26ea354f228 --- /dev/null +++ b/pkg/front_end/testcases/general/constants/js_semantics/issue46123b.dart.textual_outline.expect @@ -0,0 +1,10 @@ +import 'package:js/js.dart'; + +@JS() +@anonymous +class ParallaxOptions { + external const ParallaxOptions(); +} + +test() => const ParallaxOptions(); +main() {} diff --git a/pkg/front_end/testcases/general/constants/js_semantics/issue46123b.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/general/constants/js_semantics/issue46123b.dart.textual_outline_modelled.expect new file mode 100644 index 0000000000000..0c3a93a0df7e5 --- /dev/null +++ b/pkg/front_end/testcases/general/constants/js_semantics/issue46123b.dart.textual_outline_modelled.expect @@ -0,0 +1,10 @@ +import 'package:js/js.dart'; + +@JS() +@anonymous +class ParallaxOptions { + external const ParallaxOptions(); +} + +main() {} +test() => const ParallaxOptions(); diff --git a/pkg/front_end/testcases/general/constants/js_semantics/issue46123b.dart.weak.expect b/pkg/front_end/testcases/general/constants/js_semantics/issue46123b.dart.weak.expect new file mode 100644 index 0000000000000..29f09a147d391 --- /dev/null +++ b/pkg/front_end/testcases/general/constants/js_semantics/issue46123b.dart.weak.expect @@ -0,0 +1,39 @@ +library /*isNonNullableByDefault*/; +// +// Problems in library: +// +// pkg/front_end/testcases/general/constants/js_semantics/issue46123b.dart:13:17: Error: Constant evaluation error: +// test() => const ParallaxOptions(); +// ^ +// pkg/front_end/testcases/general/constants/js_semantics/issue46123b.dart:13:17: Context: External constructors can't be evaluated in constant expressions. +// test() => const ParallaxOptions(); +// ^ +// +import self as self; +import "package:js/js.dart" as js; +import "dart:core" as core; + +import "package:js/js.dart"; + +@#C2 +@#C3 +class ParallaxOptions extends core::Object /*hasConstConstructor*/ { + external const constructor •() → self::ParallaxOptions + : super core::Object::•() + ; +} +static method test() → dynamic + return invalid-expression "External constructors can't be evaluated in constant expressions."; +static method main() → dynamic {} + +constants { + #C1 = null + #C2 = js::JS {name:#C1} + #C3 = js::_Anonymous {} +} + + +Constructor coverage from constants: +org-dartlang-testcase:///issue46123b.dart: +- JS. (from org-dartlang-testcase-sdk:///pkg/js/lib/js.dart:21:9) +- Object. (from org-dartlang-sdk:///lib/core/object.dart:25:9) diff --git a/pkg/front_end/testcases/general/constants/js_semantics/issue46123b.dart.weak.outline.expect b/pkg/front_end/testcases/general/constants/js_semantics/issue46123b.dart.weak.outline.expect new file mode 100644 index 0000000000000..78273bca68725 --- /dev/null +++ b/pkg/front_end/testcases/general/constants/js_semantics/issue46123b.dart.weak.outline.expect @@ -0,0 +1,24 @@ +library /*isNonNullableByDefault*/; +import self as self; +import "package:js/js.dart" as js; +import "dart:core" as core; + +import "package:js/js.dart"; + +@js::JS::•() +@js::anonymous +class ParallaxOptions extends core::Object /*hasConstConstructor*/ { + external const constructor •() → self::ParallaxOptions + : super core::Object::•() + ; +} +static method test() → dynamic + ; +static method main() → dynamic + ; + + +Extra constant evaluation status: +Evaluated: ConstructorInvocation @ org-dartlang-testcase:///issue46123b.dart:7:2 -> InstanceConstant(const JS{JS.name: null}) +Evaluated: StaticGet @ org-dartlang-testcase:///issue46123b.dart:8:2 -> InstanceConstant(const _Anonymous{}) +Extra constant evaluation: evaluated: 2, effectively constant: 2 diff --git a/pkg/front_end/testcases/general/constants/js_semantics/issue46123b.dart.weak.transformed.expect b/pkg/front_end/testcases/general/constants/js_semantics/issue46123b.dart.weak.transformed.expect new file mode 100644 index 0000000000000..29f09a147d391 --- /dev/null +++ b/pkg/front_end/testcases/general/constants/js_semantics/issue46123b.dart.weak.transformed.expect @@ -0,0 +1,39 @@ +library /*isNonNullableByDefault*/; +// +// Problems in library: +// +// pkg/front_end/testcases/general/constants/js_semantics/issue46123b.dart:13:17: Error: Constant evaluation error: +// test() => const ParallaxOptions(); +// ^ +// pkg/front_end/testcases/general/constants/js_semantics/issue46123b.dart:13:17: Context: External constructors can't be evaluated in constant expressions. +// test() => const ParallaxOptions(); +// ^ +// +import self as self; +import "package:js/js.dart" as js; +import "dart:core" as core; + +import "package:js/js.dart"; + +@#C2 +@#C3 +class ParallaxOptions extends core::Object /*hasConstConstructor*/ { + external const constructor •() → self::ParallaxOptions + : super core::Object::•() + ; +} +static method test() → dynamic + return invalid-expression "External constructors can't be evaluated in constant expressions."; +static method main() → dynamic {} + +constants { + #C1 = null + #C2 = js::JS {name:#C1} + #C3 = js::_Anonymous {} +} + + +Constructor coverage from constants: +org-dartlang-testcase:///issue46123b.dart: +- JS. (from org-dartlang-testcase-sdk:///pkg/js/lib/js.dart:21:9) +- Object. (from org-dartlang-sdk:///lib/core/object.dart:25:9) diff --git a/pkg/front_end/testcases/general/constructor_patch/libraries.json b/pkg/front_end/testcases/general/constructor_patch/libraries.json new file mode 100644 index 0000000000000..154c73c30b2b5 --- /dev/null +++ b/pkg/front_end/testcases/general/constructor_patch/libraries.json @@ -0,0 +1,12 @@ +{ + "none": { + "libraries": { + "test": { + "patches": [ + "patch_lib.dart" + ], + "uri": "origin_lib.dart" + } + } + } +} diff --git a/pkg/front_end/testcases/general/constructor_patch/main.dart b/pkg/front_end/testcases/general/constructor_patch/main.dart new file mode 100644 index 0000000000000..dd2a11048ba5b --- /dev/null +++ b/pkg/front_end/testcases/general/constructor_patch/main.dart @@ -0,0 +1,10 @@ +// Copyright (c) 2020, 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. + +import 'dart:test'; + +main() { + new Class.generative(); + const Class.constGenerative(); +} diff --git a/pkg/front_end/testcases/general/constructor_patch/main.dart.textual_outline.expect b/pkg/front_end/testcases/general/constructor_patch/main.dart.textual_outline.expect new file mode 100644 index 0000000000000..3c9c90e9437e3 --- /dev/null +++ b/pkg/front_end/testcases/general/constructor_patch/main.dart.textual_outline.expect @@ -0,0 +1,3 @@ +import 'dart:test'; + +main() {} diff --git a/pkg/front_end/testcases/general/constructor_patch/main.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/general/constructor_patch/main.dart.textual_outline_modelled.expect new file mode 100644 index 0000000000000..3c9c90e9437e3 --- /dev/null +++ b/pkg/front_end/testcases/general/constructor_patch/main.dart.textual_outline_modelled.expect @@ -0,0 +1,3 @@ +import 'dart:test'; + +main() {} diff --git a/pkg/front_end/testcases/general/constructor_patch/main.dart.weak.expect b/pkg/front_end/testcases/general/constructor_patch/main.dart.weak.expect new file mode 100644 index 0000000000000..40f37f3569b86 --- /dev/null +++ b/pkg/front_end/testcases/general/constructor_patch/main.dart.weak.expect @@ -0,0 +1,42 @@ +library /*isNonNullableByDefault*/; +import self as self; +import "dart:test" as test; + +import "dart:test"; + +static method main() → dynamic { + new test::Class::generative(); + #C2; +} + +library /*isNonNullableByDefault*/; +import self as test; +import "dart:_internal" as _in; +import "dart:core" as core; + +import "dart:_internal"; + +@#C3 +class Class extends core::Object /*hasConstConstructor*/ { + final field core::bool defaultValue /* from org-dartlang-testcase:///patch_lib.dart */; + @#C3 + constructor generative({core::bool defaultValue = #C1}) → test::Class + : test::Class::defaultValue = defaultValue, super core::Object::•() + ; + @#C3 + const constructor constGenerative({core::bool defaultValue = #C1}) → test::Class + : test::Class::defaultValue = defaultValue, super core::Object::•() + ; +} + +constants { + #C1 = true + #C2 = test::Class {defaultValue:#C1} + #C3 = _in::_Patch {} +} + + +Constructor coverage from constants: +org-dartlang-testcase:///main.dart: +- Class.constGenerative (from org-dartlang-testcase:///patch_lib.dart:16:9) +- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart:25:9) diff --git a/pkg/front_end/testcases/general/constructor_patch/main.dart.weak.outline.expect b/pkg/front_end/testcases/general/constructor_patch/main.dart.weak.outline.expect new file mode 100644 index 0000000000000..d5e56584452eb --- /dev/null +++ b/pkg/front_end/testcases/general/constructor_patch/main.dart.weak.outline.expect @@ -0,0 +1,33 @@ +library /*isNonNullableByDefault*/; +import self as self; + +import "dart:test"; + +static method main() → dynamic + ; + +library /*isNonNullableByDefault*/; +import self as self2; +import "dart:_internal" as _in; +import "dart:core" as core; + +import "dart:_internal"; + +@_in::patch +class Class extends core::Object /*hasConstConstructor*/ { + final field core::bool defaultValue /* from org-dartlang-testcase:///patch_lib.dart */; + @_in::patch + external constructor generative({core::bool defaultValue}) → self2::Class + ; + @_in::patch + const constructor constGenerative({core::bool defaultValue = true}) → self2::Class + : self2::Class::defaultValue = defaultValue, super core::Object::•() + ; +} + + +Extra constant evaluation status: +Evaluated: StaticGet @ org-dartlang-testcase:///origin_lib.dart:6:49 -> InstanceConstant(const _Patch{}) +Evaluated: StaticGet @ org-dartlang-testcase:///origin_lib.dart:7:44 -> InstanceConstant(const _Patch{}) +Evaluated: StaticGet @ org-dartlang-testcase:///patch_lib.dart:16:9 -> InstanceConstant(const _Patch{}) +Extra constant evaluation: evaluated: 4, effectively constant: 3 diff --git a/pkg/front_end/testcases/general/constructor_patch/main.dart.weak.transformed.expect b/pkg/front_end/testcases/general/constructor_patch/main.dart.weak.transformed.expect new file mode 100644 index 0000000000000..40f37f3569b86 --- /dev/null +++ b/pkg/front_end/testcases/general/constructor_patch/main.dart.weak.transformed.expect @@ -0,0 +1,42 @@ +library /*isNonNullableByDefault*/; +import self as self; +import "dart:test" as test; + +import "dart:test"; + +static method main() → dynamic { + new test::Class::generative(); + #C2; +} + +library /*isNonNullableByDefault*/; +import self as test; +import "dart:_internal" as _in; +import "dart:core" as core; + +import "dart:_internal"; + +@#C3 +class Class extends core::Object /*hasConstConstructor*/ { + final field core::bool defaultValue /* from org-dartlang-testcase:///patch_lib.dart */; + @#C3 + constructor generative({core::bool defaultValue = #C1}) → test::Class + : test::Class::defaultValue = defaultValue, super core::Object::•() + ; + @#C3 + const constructor constGenerative({core::bool defaultValue = #C1}) → test::Class + : test::Class::defaultValue = defaultValue, super core::Object::•() + ; +} + +constants { + #C1 = true + #C2 = test::Class {defaultValue:#C1} + #C3 = _in::_Patch {} +} + + +Constructor coverage from constants: +org-dartlang-testcase:///main.dart: +- Class.constGenerative (from org-dartlang-testcase:///patch_lib.dart:16:9) +- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart:25:9) diff --git a/pkg/front_end/testcases/general/constructor_patch/origin_lib.dart b/pkg/front_end/testcases/general/constructor_patch/origin_lib.dart new file mode 100644 index 0000000000000..2906fbfc787d5 --- /dev/null +++ b/pkg/front_end/testcases/general/constructor_patch/origin_lib.dart @@ -0,0 +1,8 @@ +// Copyright (c) 2020, 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. + +class Class { + external Class.generative({bool defaultValue: true}); + external const Class.constGenerative({bool defaultValue: true}); +} diff --git a/pkg/front_end/testcases/general/constructor_patch/patch_lib.dart b/pkg/front_end/testcases/general/constructor_patch/patch_lib.dart new file mode 100644 index 0000000000000..0c4899c6aa8e1 --- /dev/null +++ b/pkg/front_end/testcases/general/constructor_patch/patch_lib.dart @@ -0,0 +1,17 @@ +// Copyright (c) 2020, 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. + +// ignore: import_internal_library +import 'dart:_internal'; + +@patch +class Class { + final bool defaultValue; + + @patch + Class.generative({this.defaultValue: true}); + + @patch + const Class.constGenerative({this.defaultValue: true}); +} diff --git a/pkg/front_end/testcases/general/factory_patch/main.dart.weak.expect b/pkg/front_end/testcases/general/factory_patch/main.dart.weak.expect index f739cd95e18c3..3cddf53ef992d 100644 --- a/pkg/front_end/testcases/general/factory_patch/main.dart.weak.expect +++ b/pkg/front_end/testcases/general/factory_patch/main.dart.weak.expect @@ -9,6 +9,14 @@ static method main() → dynamic { } library /*isNonNullableByDefault*/; +// +// Problems in library: +// +// pkg/front_end/testcases/general/factory_patch/patch_lib.dart:22:52: Error: Can't have a default value here because any default values of 'Class._internal' would be used instead. +// Try removing the default value. +// const factory Class.redirect({bool defaultValue: true}) = Class._internal; +// ^ +// import self as test; import "dart:_internal" as _in; import "dart:core" as core; @@ -18,6 +26,7 @@ import "dart:_internal"; @#C1 class Class extends core::Object { final field core::bool defaultValue /* from org-dartlang-testcase:///patch_lib.dart */; + static final field dynamic _redirecting# = [test::Class::redirect]/*isLegacy*/; const constructor _internal({core::bool defaultValue = #C2}) → test::Class : test::Class::defaultValue = defaultValue, super core::Object::•() ; @@ -27,6 +36,9 @@ class Class extends core::Object { @#C1 static factory /* from org-dartlang-testcase:///patch_lib.dart */ constFact({core::bool defaultValue = #C3}) → test::Class return throw "unsupported"; + @#C1 + static factory /* from org-dartlang-testcase:///patch_lib.dart */ redirect({core::bool defaultValue = #C3}) → test::Class + let dynamic #redirecting_factory = test::Class::_internal in invalid-expression; } constants { diff --git a/pkg/front_end/testcases/general/factory_patch/main.dart.weak.outline.expect b/pkg/front_end/testcases/general/factory_patch/main.dart.weak.outline.expect index 25c2ffa121f82..62a00f1aa553d 100644 --- a/pkg/front_end/testcases/general/factory_patch/main.dart.weak.outline.expect +++ b/pkg/front_end/testcases/general/factory_patch/main.dart.weak.outline.expect @@ -16,6 +16,7 @@ import "dart:_internal"; @_in::patch class Class extends core::Object { final field core::bool defaultValue /* from org-dartlang-testcase:///patch_lib.dart */; + static final field dynamic _redirecting# = [self2::Class::redirect]/*isLegacy*/; const constructor _internal({core::bool defaultValue = false}) → self2::Class : self2::Class::defaultValue = defaultValue, super core::Object::•() ; @@ -23,6 +24,9 @@ class Class extends core::Object { external static factory fact({core::bool defaultValue}) → self2::Class; @_in::patch external static factory constFact({core::bool defaultValue = true}) → self2::Class; + @_in::patch + static factory /* from org-dartlang-testcase:///patch_lib.dart */ redirect({core::bool defaultValue = true}) → self2::Class + let dynamic #redirecting_factory = self2::Class::_internal in invalid-expression; } @@ -30,4 +34,5 @@ Extra constant evaluation status: Evaluated: StaticGet @ org-dartlang-testcase:///origin_lib.dart:6:49 -> InstanceConstant(const _Patch{}) Evaluated: StaticGet @ org-dartlang-testcase:///origin_lib.dart:8:27 -> InstanceConstant(const _Patch{}) Evaluated: StaticGet @ (unknown position in org-dartlang-testcase:///origin_lib.dart) -> InstanceConstant(const _Patch{}) -Extra constant evaluation: evaluated: 4, effectively constant: 3 +Evaluated: StaticGet @ org-dartlang-testcase:///patch_lib.dart:22:17 -> InstanceConstant(const _Patch{}) +Extra constant evaluation: evaluated: 9, effectively constant: 4 diff --git a/pkg/front_end/testcases/general/factory_patch/main.dart.weak.transformed.expect b/pkg/front_end/testcases/general/factory_patch/main.dart.weak.transformed.expect index f739cd95e18c3..3cddf53ef992d 100644 --- a/pkg/front_end/testcases/general/factory_patch/main.dart.weak.transformed.expect +++ b/pkg/front_end/testcases/general/factory_patch/main.dart.weak.transformed.expect @@ -9,6 +9,14 @@ static method main() → dynamic { } library /*isNonNullableByDefault*/; +// +// Problems in library: +// +// pkg/front_end/testcases/general/factory_patch/patch_lib.dart:22:52: Error: Can't have a default value here because any default values of 'Class._internal' would be used instead. +// Try removing the default value. +// const factory Class.redirect({bool defaultValue: true}) = Class._internal; +// ^ +// import self as test; import "dart:_internal" as _in; import "dart:core" as core; @@ -18,6 +26,7 @@ import "dart:_internal"; @#C1 class Class extends core::Object { final field core::bool defaultValue /* from org-dartlang-testcase:///patch_lib.dart */; + static final field dynamic _redirecting# = [test::Class::redirect]/*isLegacy*/; const constructor _internal({core::bool defaultValue = #C2}) → test::Class : test::Class::defaultValue = defaultValue, super core::Object::•() ; @@ -27,6 +36,9 @@ class Class extends core::Object { @#C1 static factory /* from org-dartlang-testcase:///patch_lib.dart */ constFact({core::bool defaultValue = #C3}) → test::Class return throw "unsupported"; + @#C1 + static factory /* from org-dartlang-testcase:///patch_lib.dart */ redirect({core::bool defaultValue = #C3}) → test::Class + let dynamic #redirecting_factory = test::Class::_internal in invalid-expression; } constants { diff --git a/pkg/front_end/testcases/general/factory_patch/origin_lib.dart b/pkg/front_end/testcases/general/factory_patch/origin_lib.dart index e7895f2b48369..300b31ee21b15 100644 --- a/pkg/front_end/testcases/general/factory_patch/origin_lib.dart +++ b/pkg/front_end/testcases/general/factory_patch/origin_lib.dart @@ -5,5 +5,5 @@ class Class { external factory Class.fact({bool defaultValue: true}); external const factory Class.constFact({bool defaultValue: true}); - //external const factory Class.redirect({bool defaultValue: true}); + external const factory Class.redirect({bool defaultValue: true}); } diff --git a/pkg/front_end/testcases/general/factory_patch/patch_lib.dart b/pkg/front_end/testcases/general/factory_patch/patch_lib.dart index cfc227860a108..e1fe3fd1c6c5d 100644 --- a/pkg/front_end/testcases/general/factory_patch/patch_lib.dart +++ b/pkg/front_end/testcases/general/factory_patch/patch_lib.dart @@ -18,7 +18,6 @@ class Class { @patch factory Class.constFact({bool defaultValue: true}) => throw 'unsupported'; - /*@patch - const factory Class.redirect({bool defaultValue: true}) = - this._internal(defaultValue: defaultValue);*/ + @patch + const factory Class.redirect({bool defaultValue: true}) = Class._internal; } diff --git a/pkg/front_end/testcases/general/issue45101/main.dart.weak.outline.expect b/pkg/front_end/testcases/general/issue45101/main.dart.weak.outline.expect index c56c3757f17a5..68f366e9671af 100644 --- a/pkg/front_end/testcases/general/issue45101/main.dart.weak.outline.expect +++ b/pkg/front_end/testcases/general/issue45101/main.dart.weak.outline.expect @@ -34,7 +34,7 @@ class _ArraySize extends core::Object impleme class Array extends core::Object { static final field dynamic _redirecting# = [self2::Array::•]; @_in::patch - external static factory •(core::int* foo) → self2::Array* + static factory /* from org-dartlang-testcase:///patch_lib.dart */ •(core::int* foo) → self2::Array* let dynamic #redirecting_factory = self2::_ArraySize::• in let self2::Array::•::T* #typeArg0 = null in invalid-expression; abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf @@ -52,5 +52,5 @@ class Array extends core::Object { Extra constant evaluation status: Evaluated: StaticGet @ org-dartlang-testcase:///origin_lib.dart:10:1 -> InstanceConstant(const _Patch{}) Evaluated: ConstructorInvocation @ (unknown position in org-dartlang-testcase:///origin_lib.dart) -> InstanceConstant(const pragma{pragma.name: "vm:entry-point", pragma.options: null}) -Evaluated: StaticGet @ (unknown position in org-dartlang-testcase:///origin_lib.dart) -> InstanceConstant(const _Patch{}) +Evaluated: StaticGet @ org-dartlang-testcase:///patch_lib.dart:14:17 -> InstanceConstant(const _Patch{}) Extra constant evaluation: evaluated: 9, effectively constant: 3 diff --git a/pkg/front_end/tool/dart_doctest_impl.dart b/pkg/front_end/tool/dart_doctest_impl.dart index 3051c00e37b55..38e9a55414527 100644 --- a/pkg/front_end/tool/dart_doctest_impl.dart +++ b/pkg/front_end/tool/dart_doctest_impl.dart @@ -789,7 +789,7 @@ class DocTestIncrementalCompiler extends IncrementalCompiler { LibraryBuilder libraryBuilder = userCode!.loader .read(libraryUri, -1, accessor: userCode!.loader.first); - userCode!.loader.seenMessages.clear(); + userCode!.loader.resetSeenMessages(); _dartDocTestLibraryBuilder = libraryBuilder; _dartDocTestCode = dartDocTestCode;