-
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] Fix crash when metadata references locals in extension type
Having metadata on several variables means it has to be cloned which (used to) crash. Change-Id: I0ed1d4b51cec98adb23674d144d3970d3db9d69d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/398060 Reviewed-by: Johnni Winther <[email protected]> Commit-Queue: Jens Johansen <[email protected]>
- Loading branch information
Showing
8 changed files
with
162 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
10 changes: 10 additions & 0 deletions
10
pkg/front_end/testcases/regress/extension_type_metadata_references_variable.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,10 @@ | ||
// Copyright (c) 2024, 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 type Foo._(int _x) { | ||
Foo(this._x, int bar){ | ||
@bar | ||
int a1, a2; | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
...ront_end/testcases/regress/extension_type_metadata_references_variable.dart.strong.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,42 @@ | ||
library; | ||
// | ||
// Problems in library: | ||
// | ||
// pkg/front_end/testcases/regress/extension_type_metadata_references_variable.dart:7:6: Error: Not a constant expression. | ||
// @bar | ||
// ^^^ | ||
// | ||
// pkg/front_end/testcases/regress/extension_type_metadata_references_variable.dart:7:6: Error: This can't be used as an annotation; an annotation should be a reference to a compile-time constant variable, or a call to a constant constructor. | ||
// @bar | ||
// ^ | ||
// | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
extension type Foo(core::int _x) { | ||
abstract extension-type-member representation-field get _x() → core::int; | ||
constructor _ = self::Foo|constructor#_; | ||
constructor tearoff _ = self::Foo|constructor#_#_#tearOff; | ||
constructor • = self::Foo|constructor#; | ||
constructor tearoff • = self::Foo|constructor#_#new#tearOff; | ||
} | ||
static extension-type-member method Foo|constructor#_(core::int _x) → self::Foo% /* erasure=core::int, declared=! */ { | ||
lowered final self::Foo% /* erasure=core::int, declared=! */ #this = _x; | ||
return #this; | ||
} | ||
static extension-type-member method Foo|constructor#_#_#tearOff(core::int _x) → self::Foo% /* erasure=core::int, declared=! */ | ||
return self::Foo|constructor#_(_x); | ||
static extension-type-member method Foo|constructor#(core::int _x, core::int bar) → self::Foo% /* erasure=core::int, declared=! */ { | ||
lowered final self::Foo% /* erasure=core::int, declared=! */ #this = _x; | ||
{ | ||
@invalid-expression "pkg/front_end/testcases/regress/extension_type_metadata_references_variable.dart:7:6: Error: This can't be used as an annotation; an annotation should be a reference to a compile-time constant variable, or a call to a constant constructor. | ||
@bar | ||
^" core::int a1; | ||
@invalid-expression "pkg/front_end/testcases/regress/extension_type_metadata_references_variable.dart:7:6: Error: This can't be used as an annotation; an annotation should be a reference to a compile-time constant variable, or a call to a constant constructor. | ||
@bar | ||
^" core::int a2; | ||
} | ||
return #this; | ||
} | ||
static extension-type-member method Foo|constructor#_#new#tearOff(core::int _x, core::int bar) → self::Foo% /* erasure=core::int, declared=! */ | ||
return self::Foo|constructor#(_x, bar); |
42 changes: 42 additions & 0 deletions
42
.../testcases/regress/extension_type_metadata_references_variable.dart.strong.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,42 @@ | ||
library; | ||
// | ||
// Problems in library: | ||
// | ||
// pkg/front_end/testcases/regress/extension_type_metadata_references_variable.dart:7:6: Error: Not a constant expression. | ||
// @bar | ||
// ^^^ | ||
// | ||
// pkg/front_end/testcases/regress/extension_type_metadata_references_variable.dart:7:6: Error: This can't be used as an annotation; an annotation should be a reference to a compile-time constant variable, or a call to a constant constructor. | ||
// @bar | ||
// ^ | ||
// | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
extension type Foo(core::int _x) { | ||
abstract extension-type-member representation-field get _x() → core::int; | ||
constructor _ = self::Foo|constructor#_; | ||
constructor tearoff _ = self::Foo|constructor#_#_#tearOff; | ||
constructor • = self::Foo|constructor#; | ||
constructor tearoff • = self::Foo|constructor#_#new#tearOff; | ||
} | ||
static extension-type-member method Foo|constructor#_(core::int _x) → self::Foo% /* erasure=core::int, declared=! */ { | ||
lowered final self::Foo% /* erasure=core::int, declared=! */ #this = _x; | ||
return #this; | ||
} | ||
static extension-type-member method Foo|constructor#_#_#tearOff(core::int _x) → self::Foo% /* erasure=core::int, declared=! */ | ||
return self::Foo|constructor#_(_x); | ||
static extension-type-member method Foo|constructor#(core::int _x, core::int bar) → self::Foo% /* erasure=core::int, declared=! */ { | ||
lowered final self::Foo% /* erasure=core::int, declared=! */ #this = _x; | ||
{ | ||
@invalid-expression "pkg/front_end/testcases/regress/extension_type_metadata_references_variable.dart:7:6: Error: This can't be used as an annotation; an annotation should be a reference to a compile-time constant variable, or a call to a constant constructor. | ||
@bar | ||
^" core::int a1; | ||
@invalid-expression "pkg/front_end/testcases/regress/extension_type_metadata_references_variable.dart:7:6: Error: This can't be used as an annotation; an annotation should be a reference to a compile-time constant variable, or a call to a constant constructor. | ||
@bar | ||
^" core::int a2; | ||
} | ||
return #this; | ||
} | ||
static extension-type-member method Foo|constructor#_#new#tearOff(core::int _x, core::int bar) → self::Foo% /* erasure=core::int, declared=! */ | ||
return self::Foo|constructor#(_x, bar); |
19 changes: 19 additions & 0 deletions
19
.../testcases/regress/extension_type_metadata_references_variable.dart.strong.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,19 @@ | ||
library; | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
extension type Foo(core::int _x) { | ||
abstract extension-type-member representation-field get _x() → core::int; | ||
constructor _ = self::Foo|constructor#_; | ||
constructor tearoff _ = self::Foo|constructor#_#_#tearOff; | ||
constructor • = self::Foo|constructor#; | ||
constructor tearoff • = self::Foo|constructor#_#new#tearOff; | ||
} | ||
static extension-type-member method Foo|constructor#_(core::int _x) → self::Foo% /* erasure=core::int, declared=! */ | ||
; | ||
static extension-type-member method Foo|constructor#_#_#tearOff(core::int _x) → self::Foo% /* erasure=core::int, declared=! */ | ||
return self::Foo|constructor#_(_x); | ||
static extension-type-member method Foo|constructor#(core::int _x, core::int bar) → self::Foo% /* erasure=core::int, declared=! */ | ||
; | ||
static extension-type-member method Foo|constructor#_#new#tearOff(core::int _x, core::int bar) → self::Foo% /* erasure=core::int, declared=! */ | ||
return self::Foo|constructor#(_x, bar); |
42 changes: 42 additions & 0 deletions
42
...tcases/regress/extension_type_metadata_references_variable.dart.strong.transformed.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,42 @@ | ||
library; | ||
// | ||
// Problems in library: | ||
// | ||
// pkg/front_end/testcases/regress/extension_type_metadata_references_variable.dart:7:6: Error: Not a constant expression. | ||
// @bar | ||
// ^^^ | ||
// | ||
// pkg/front_end/testcases/regress/extension_type_metadata_references_variable.dart:7:6: Error: This can't be used as an annotation; an annotation should be a reference to a compile-time constant variable, or a call to a constant constructor. | ||
// @bar | ||
// ^ | ||
// | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
extension type Foo(core::int _x) { | ||
abstract extension-type-member representation-field get _x() → core::int; | ||
constructor _ = self::Foo|constructor#_; | ||
constructor tearoff _ = self::Foo|constructor#_#_#tearOff; | ||
constructor • = self::Foo|constructor#; | ||
constructor tearoff • = self::Foo|constructor#_#new#tearOff; | ||
} | ||
static extension-type-member method Foo|constructor#_(core::int _x) → self::Foo% /* erasure=core::int, declared=! */ { | ||
lowered final self::Foo% /* erasure=core::int, declared=! */ #this = _x; | ||
return #this; | ||
} | ||
static extension-type-member method Foo|constructor#_#_#tearOff(core::int _x) → self::Foo% /* erasure=core::int, declared=! */ | ||
return self::Foo|constructor#_(_x); | ||
static extension-type-member method Foo|constructor#(core::int _x, core::int bar) → self::Foo% /* erasure=core::int, declared=! */ { | ||
lowered final self::Foo% /* erasure=core::int, declared=! */ #this = _x; | ||
{ | ||
@invalid-expression "pkg/front_end/testcases/regress/extension_type_metadata_references_variable.dart:7:6: Error: This can't be used as an annotation; an annotation should be a reference to a compile-time constant variable, or a call to a constant constructor. | ||
@bar | ||
^" core::int a1; | ||
@invalid-expression "pkg/front_end/testcases/regress/extension_type_metadata_references_variable.dart:7:6: Error: This can't be used as an annotation; an annotation should be a reference to a compile-time constant variable, or a call to a constant constructor. | ||
@bar | ||
^" core::int a2; | ||
} | ||
return #this; | ||
} | ||
static extension-type-member method Foo|constructor#_#new#tearOff(core::int _x, core::int bar) → self::Foo% /* erasure=core::int, declared=! */ | ||
return self::Foo|constructor#(_x, bar); |
3 changes: 3 additions & 0 deletions
3
...testcases/regress/extension_type_metadata_references_variable.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,3 @@ | ||
extension type Foo._(int _x) { | ||
Foo(this._x, int bar) {} | ||
} |
3 changes: 3 additions & 0 deletions
3
.../regress/extension_type_metadata_references_variable.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,3 @@ | ||
extension type Foo._(int _x) { | ||
Foo(this._x, int bar) {} | ||
} |