-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[cfe] Report error on instantiation of enums from .dill
Closes #48350 Change-Id: I0cedf8a5a12e1a8dee546eec73e012519a054e13 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232384 Reviewed-by: Chloe Stefantsova <cstefantsova@google.com> Commit-Queue: Johnni Winther <johnniwinther@google.com>
- Loading branch information
1 parent
7263b35
commit 2e6d7bf
Showing
16 changed files
with
403 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
pkg/front_end/testcases/expression/instantiate_enum.expression.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Copyright (c) 2022, 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. | ||
|
||
entry_point: "main.dart" | ||
definitions: [] | ||
position: "main.dart" | ||
expression: | | ||
En(123, 'foo') |
7 changes: 7 additions & 0 deletions
7
pkg/front_end/testcases/expression/instantiate_enum.expression.yaml.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Errors: { | ||
org-dartlang-debug:synthetic_debug_expression:1:1: Error: Enums can't be instantiated. | ||
En(123, 'foo') | ||
^^ | ||
} | ||
method /* from org-dartlang-debug:synthetic_debug_expression */ debugExpr() → dynamic | ||
return invalid-expression "org-dartlang-debug:synthetic_debug_expression:1:1: Error: Enums can't be instantiated.\nEn(123, 'foo')\n^^"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
pkg/front_end/testcases/general/instantiate_enum/main.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright (c) 2022, 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 'main_lib.dart'; | ||
|
||
enum Enum1 { a, b, c } | ||
|
||
typedef Alias1 = Enum1; | ||
|
||
test() { | ||
Enum1(123, 'foo'); | ||
Enum2(123, 'foo'); | ||
Alias1(123, 'foo'); | ||
Alias2(123, 'foo'); | ||
} | ||
|
||
main() {} |
6 changes: 6 additions & 0 deletions
6
pkg/front_end/testcases/general/instantiate_enum/main.dart.textual_outline.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import 'main_lib.dart'; | ||
|
||
enum Enum1 { a, b, c } | ||
typedef Alias1 = Enum1; | ||
test() {} | ||
main() {} |
6 changes: 6 additions & 0 deletions
6
pkg/front_end/testcases/general/instantiate_enum/main.dart.textual_outline_modelled.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import 'main_lib.dart'; | ||
|
||
enum Enum1 { a, b, c } | ||
main() {} | ||
test() {} | ||
typedef Alias1 = Enum1; |
98 changes: 98 additions & 0 deletions
98
pkg/front_end/testcases/general/instantiate_enum/main.dart.weak.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
library /*isNonNullableByDefault*/; | ||
// | ||
// Problems in library: | ||
// | ||
// pkg/front_end/testcases/general/instantiate_enum/main.dart:12:3: Error: Enums can't be instantiated. | ||
// Enum1(123, 'foo'); | ||
// ^^^^^ | ||
// | ||
// pkg/front_end/testcases/general/instantiate_enum/main.dart:13:3: Error: Enums can't be instantiated. | ||
// Enum2(123, 'foo'); | ||
// ^^^^^ | ||
// | ||
// pkg/front_end/testcases/general/instantiate_enum/main.dart:14:3: Error: Enums can't be instantiated. | ||
// Alias1(123, 'foo'); | ||
// ^^^^^^ | ||
// | ||
// pkg/front_end/testcases/general/instantiate_enum/main.dart:15:3: Error: Enums can't be instantiated. | ||
// Alias2(123, 'foo'); | ||
// ^^^^^^ | ||
// | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
import "org-dartlang-testcase:///main_lib.dart"; | ||
|
||
typedef Alias1 = self::Enum1; | ||
class Enum1 extends core::_Enum /*isEnum*/ { | ||
static const field core::List<self::Enum1> values = #C10; | ||
static const field self::Enum1 a = #C3; | ||
static const field self::Enum1 b = #C6; | ||
static const field self::Enum1 c = #C9; | ||
const constructor •(core::int index, core::String name) → self::Enum1 | ||
: super core::_Enum::•(index, name) | ||
; | ||
method toString() → core::String | ||
return "Enum1.${this.{core::_Enum::_name}{core::String}}"; | ||
} | ||
static method test() → dynamic { | ||
invalid-expression "pkg/front_end/testcases/general/instantiate_enum/main.dart:12:3: Error: Enums can't be instantiated. | ||
Enum1(123, 'foo'); | ||
^^^^^"; | ||
invalid-expression "pkg/front_end/testcases/general/instantiate_enum/main.dart:13:3: Error: Enums can't be instantiated. | ||
Enum2(123, 'foo'); | ||
^^^^^"; | ||
invalid-expression "pkg/front_end/testcases/general/instantiate_enum/main.dart:14:3: Error: Enums can't be instantiated. | ||
Alias1(123, 'foo'); | ||
^^^^^^"; | ||
invalid-expression "pkg/front_end/testcases/general/instantiate_enum/main.dart:15:3: Error: Enums can't be instantiated. | ||
Alias2(123, 'foo'); | ||
^^^^^^"; | ||
} | ||
static method main() → dynamic {} | ||
|
||
library /*isNonNullableByDefault*/; | ||
import self as self2; | ||
import "dart:core" as core; | ||
|
||
typedef Alias2 = self2::Enum2; | ||
class Enum2 extends core::_Enum /*isEnum*/ { | ||
static const field core::List<self2::Enum2> values = #C14; | ||
static const field self2::Enum2 a = #C11; | ||
static const field self2::Enum2 b = #C12; | ||
static const field self2::Enum2 c = #C13; | ||
const constructor •(core::int index, core::String name) → self2::Enum2 | ||
: super core::_Enum::•(index, name) | ||
; | ||
method toString() → core::String | ||
return "Enum2.${this.{core::_Enum::_name}{core::String}}"; | ||
} | ||
|
||
constants { | ||
#C1 = 0 | ||
#C2 = "a" | ||
#C3 = self::Enum1 {index:#C1, _name:#C2} | ||
#C4 = 1 | ||
#C5 = "b" | ||
#C6 = self::Enum1 {index:#C4, _name:#C5} | ||
#C7 = 2 | ||
#C8 = "c" | ||
#C9 = self::Enum1 {index:#C7, _name:#C8} | ||
#C10 = <self::Enum1*>[#C3, #C6, #C9] | ||
#C11 = self2::Enum2 {index:#C1, _name:#C2} | ||
#C12 = self2::Enum2 {index:#C4, _name:#C5} | ||
#C13 = self2::Enum2 {index:#C7, _name:#C8} | ||
#C14 = <self2::Enum2*>[#C11, #C12, #C13] | ||
} | ||
|
||
|
||
Constructor coverage from constants: | ||
org-dartlang-testcase:///main_lib.dart: | ||
- Enum2. (from org-dartlang-testcase:///main_lib.dart:5:6) | ||
- _Enum. (from org-dartlang-sdk:///sdk/lib/core/enum.dart:103:9) | ||
- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart:25:9) | ||
|
||
org-dartlang-testcase:///main.dart: | ||
- Enum1. (from org-dartlang-testcase:///main.dart:7:6) | ||
- _Enum. (from org-dartlang-sdk:///sdk/lib/core/enum.dart:103:9) | ||
- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart:25:9) |
72 changes: 72 additions & 0 deletions
72
pkg/front_end/testcases/general/instantiate_enum/main.dart.weak.modular.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
library /*isNonNullableByDefault*/; | ||
// | ||
// Problems in library: | ||
// | ||
// pkg/front_end/testcases/general/instantiate_enum/main.dart:12:3: Error: Enums can't be instantiated. | ||
// Enum1(123, 'foo'); | ||
// ^^^^^ | ||
// | ||
// pkg/front_end/testcases/general/instantiate_enum/main.dart:13:3: Error: Enums can't be instantiated. | ||
// Enum2(123, 'foo'); | ||
// ^^^^^ | ||
// | ||
// pkg/front_end/testcases/general/instantiate_enum/main.dart:14:3: Error: Enums can't be instantiated. | ||
// Alias1(123, 'foo'); | ||
// ^^^^^^ | ||
// | ||
// pkg/front_end/testcases/general/instantiate_enum/main.dart:15:3: Error: Enums can't be instantiated. | ||
// Alias2(123, 'foo'); | ||
// ^^^^^^ | ||
// | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
import "org-dartlang-testcase:///main_lib.dart"; | ||
|
||
typedef Alias1 = self::Enum1; | ||
class Enum1 extends core::_Enum /*isEnum*/ { | ||
static const field core::List<self::Enum1> values = #C10; | ||
static const field self::Enum1 a = #C3; | ||
static const field self::Enum1 b = #C6; | ||
static const field self::Enum1 c = #C9; | ||
const constructor •(core::int index, core::String name) → self::Enum1 | ||
: super core::_Enum::•(index, name) | ||
; | ||
method toString() → core::String | ||
return "Enum1.${this.{core::_Enum::_name}{core::String}}"; | ||
} | ||
static method test() → dynamic { | ||
invalid-expression "pkg/front_end/testcases/general/instantiate_enum/main.dart:12:3: Error: Enums can't be instantiated. | ||
Enum1(123, 'foo'); | ||
^^^^^"; | ||
invalid-expression "pkg/front_end/testcases/general/instantiate_enum/main.dart:13:3: Error: Enums can't be instantiated. | ||
Enum2(123, 'foo'); | ||
^^^^^"; | ||
invalid-expression "pkg/front_end/testcases/general/instantiate_enum/main.dart:14:3: Error: Enums can't be instantiated. | ||
Alias1(123, 'foo'); | ||
^^^^^^"; | ||
invalid-expression "pkg/front_end/testcases/general/instantiate_enum/main.dart:15:3: Error: Enums can't be instantiated. | ||
Alias2(123, 'foo'); | ||
^^^^^^"; | ||
} | ||
static method main() → dynamic {} | ||
|
||
constants { | ||
#C1 = 0 | ||
#C2 = "a" | ||
#C3 = self::Enum1 {index:#C1, _name:#C2} | ||
#C4 = 1 | ||
#C5 = "b" | ||
#C6 = self::Enum1 {index:#C4, _name:#C5} | ||
#C7 = 2 | ||
#C8 = "c" | ||
#C9 = self::Enum1 {index:#C7, _name:#C8} | ||
#C10 = <self::Enum1*>[#C3, #C6, #C9] | ||
} | ||
|
||
|
||
Constructor coverage from constants: | ||
org-dartlang-testcase:///main.dart: | ||
- Enum1. (from org-dartlang-testcase:///main.dart:7:6) | ||
- _Enum. (from org-dartlang-sdk:///sdk/lib/core/enum.dart:103:9) | ||
- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart:25:9) |
66 changes: 66 additions & 0 deletions
66
pkg/front_end/testcases/general/instantiate_enum/main.dart.weak.outline.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
library /*isNonNullableByDefault*/; | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
import "org-dartlang-testcase:///main_lib.dart"; | ||
|
||
typedef Alias1 = self::Enum1; | ||
class Enum1 extends core::_Enum /*isEnum*/ { | ||
static const field core::List<self::Enum1> values = const <self::Enum1>[self::Enum1::a, self::Enum1::b, self::Enum1::c]; | ||
static const field self::Enum1 a = const self::Enum1::•(0, "a"); | ||
static const field self::Enum1 b = const self::Enum1::•(1, "b"); | ||
static const field self::Enum1 c = const self::Enum1::•(2, "c"); | ||
const constructor •(core::int index, core::String name) → self::Enum1 | ||
: super core::_Enum::•(index, name) | ||
; | ||
method toString() → core::String | ||
return "Enum1.${this.{core::_Enum::_name}{core::String}}"; | ||
} | ||
static method test() → dynamic | ||
; | ||
static method main() → dynamic | ||
; | ||
|
||
library /*isNonNullableByDefault*/; | ||
import self as self2; | ||
import "dart:core" as core; | ||
|
||
typedef Alias2 = self2::Enum2; | ||
class Enum2 extends core::_Enum /*isEnum*/ { | ||
static const field core::List<self2::Enum2> values = #C10; | ||
static const field self2::Enum2 a = #C3; | ||
static const field self2::Enum2 b = #C6; | ||
static const field self2::Enum2 c = #C9; | ||
const constructor •(core::int index, core::String name) → self2::Enum2 | ||
: super core::_Enum::•(index, name) | ||
; | ||
method toString() → core::String | ||
return "Enum2.${this.{core::_Enum::_name}{core::String}}"; | ||
} | ||
|
||
constants { | ||
#C1 = 0 | ||
#C2 = "a" | ||
#C3 = self2::Enum2 {index:#C1, _name:#C2} | ||
#C4 = 1 | ||
#C5 = "b" | ||
#C6 = self2::Enum2 {index:#C4, _name:#C5} | ||
#C7 = 2 | ||
#C8 = "c" | ||
#C9 = self2::Enum2 {index:#C7, _name:#C8} | ||
#C10 = <self2::Enum2*>[#C3, #C6, #C9] | ||
} | ||
|
||
Extra constant evaluation status: | ||
Evaluated: ListLiteral @ org-dartlang-testcase:///main.dart:7:6 -> ListConstant(const <Enum1*>[const Enum1{_Enum.index: 0, _Enum._name: "a"}, const Enum1{_Enum.index: 1, _Enum._name: "b"}, const Enum1{_Enum.index: 2, _Enum._name: "c"}]) | ||
Evaluated: ConstructorInvocation @ org-dartlang-testcase:///main.dart:7:14 -> InstanceConstant(const Enum1{_Enum.index: 0, _Enum._name: "a"}) | ||
Evaluated: ConstructorInvocation @ org-dartlang-testcase:///main.dart:7:17 -> InstanceConstant(const Enum1{_Enum.index: 1, _Enum._name: "b"}) | ||
Evaluated: ConstructorInvocation @ org-dartlang-testcase:///main.dart:7:20 -> InstanceConstant(const Enum1{_Enum.index: 2, _Enum._name: "c"}) | ||
Extra constant evaluation: evaluated: 14, effectively constant: 4 | ||
|
||
|
||
Constructor coverage from constants: | ||
org-dartlang-testcase:///main_lib.dart: | ||
- Enum2. (from org-dartlang-testcase:///main_lib.dart:5:6) | ||
- _Enum. (from org-dartlang-sdk:///sdk/lib/core/enum.dart:103:9) | ||
- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart:25:9) |
Oops, something went wrong.