[CFE] Fix crash on invalid this references

Change-Id: If6a323a7cc2defab3a0f7844b948719c49fef483
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/395301
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
This commit is contained in:
Jens Johansen
2024-11-18 09:26:24 +00:00
committed by Commit Queue
parent 30b0a80224
commit 31e324bfdf
37 changed files with 781 additions and 2 deletions
+11 -2
View File
@@ -3292,6 +3292,10 @@ class BodyBuilder extends StackListenerImpl
// semantics, such parameters introduces a new parameter with that
// name that should be resolved here.
!_context.isConstructor) {
if (declaration.isExtensionTypeInstanceMember) {
return new IncompleteErrorGenerator(
this, nameToken, fasta.messageNotAConstantExpression);
}
addProblem(
fasta.messageNotAConstantExpression, nameOffset, nameToken.length);
}
@@ -7178,8 +7182,13 @@ class BodyBuilder extends StackListenerImpl
debugEvent("ThisExpression");
if (context.isScopeReference && isDeclarationInstanceContext) {
if (thisVariable != null && !inConstructorInitializer) {
push(_createReadOnlyVariableAccess(thisVariable!, token,
offsetForToken(token), 'this', ReadOnlyAccessKind.ExtensionThis));
if (constantContext != ConstantContext.none) {
push(new IncompleteErrorGenerator(
this, token, fasta.messageThisAsIdentifier));
} else {
push(_createReadOnlyVariableAccess(thisVariable!, token,
offsetForToken(token), 'this', ReadOnlyAccessKind.ExtensionThis));
}
} else {
push(new ThisAccessGenerator(this, token, inInitializerLeftHandSide,
inFieldInitializer, inLateFieldInitializer));
@@ -348,6 +348,7 @@ foos
forbidden
forces
foreground
forgot
forrest
forth
forty
@@ -577,6 +578,7 @@ oo
oobar
oocf
ooo
oops
oovf
opacity
operate
@@ -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(String x) {
int x2 = 42;
@x2
int? a, b;
}
@@ -0,0 +1,49 @@
library;
//
// Problems in library:
//
// pkg/front_end/testcases/regress/invalid_this_reference_01.dart:6:7: Error: Extension types can't declare instance fields
// Try removing the field declaration or making it a static field
// int x2 = 42;
// ^^
//
// pkg/front_end/testcases/regress/invalid_this_reference_01.dart:9:8: Error: Extension types can't declare instance fields
// Try removing the field declaration or making it a static field
// int? a, b;
// ^
//
// pkg/front_end/testcases/regress/invalid_this_reference_01.dart:8:4: Error: Not a constant expression.
// @x2
// ^^
//
// pkg/front_end/testcases/regress/invalid_this_reference_01.dart:8:4: 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.
// @x2
// ^
//
import self as self;
import "dart:core" as core;
extension type Foo(core::String x) {
abstract extension-type-member representation-field get x() → core::String;
abstract extension-type-member representation-field get x2() → core::int;
@invalid-expression "pkg/front_end/testcases/regress/invalid_this_reference_01.dart:8:4: 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.
@x2
^" in invalid-expression "pkg/front_end/testcases/regress/invalid_this_reference_01.dart:8:4: Error: Not a constant expression.
@x2
^^"
abstract extension-type-member representation-field get a() → core::int?;
@invalid-expression "pkg/front_end/testcases/regress/invalid_this_reference_01.dart:8:4: 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.
@x2
^" in invalid-expression "pkg/front_end/testcases/regress/invalid_this_reference_01.dart:8:4: Error: Not a constant expression.
@x2
^^"
abstract extension-type-member representation-field get b() → core::int?;
constructor • = self::Foo|constructor#;
constructor tearoff • = self::Foo|constructor#_#new#tearOff;
}
static extension-type-member method Foo|constructor#(core::String x) → self::Foo% /* erasure=core::String, declared=! */ {
lowered final self::Foo% /* erasure=core::String, declared=! */ #this = x;
return #this;
}
static extension-type-member method Foo|constructor#_#new#tearOff(core::String x) → self::Foo% /* erasure=core::String, declared=! */
return self::Foo|constructor#(x);
@@ -0,0 +1,49 @@
library;
//
// Problems in library:
//
// pkg/front_end/testcases/regress/invalid_this_reference_01.dart:6:7: Error: Extension types can't declare instance fields
// Try removing the field declaration or making it a static field
// int x2 = 42;
// ^^
//
// pkg/front_end/testcases/regress/invalid_this_reference_01.dart:9:8: Error: Extension types can't declare instance fields
// Try removing the field declaration or making it a static field
// int? a, b;
// ^
//
// pkg/front_end/testcases/regress/invalid_this_reference_01.dart:8:4: Error: Not a constant expression.
// @x2
// ^^
//
// pkg/front_end/testcases/regress/invalid_this_reference_01.dart:8:4: 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.
// @x2
// ^
//
import self as self;
import "dart:core" as core;
extension type Foo(core::String x) {
abstract extension-type-member representation-field get x() → core::String;
abstract extension-type-member representation-field get x2() → core::int;
@invalid-expression "pkg/front_end/testcases/regress/invalid_this_reference_01.dart:8:4: 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.
@x2
^" in invalid-expression "pkg/front_end/testcases/regress/invalid_this_reference_01.dart:8:4: Error: Not a constant expression.
@x2
^^"
abstract extension-type-member representation-field get a() → core::int?;
@invalid-expression "pkg/front_end/testcases/regress/invalid_this_reference_01.dart:8:4: 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.
@x2
^" in invalid-expression "pkg/front_end/testcases/regress/invalid_this_reference_01.dart:8:4: Error: Not a constant expression.
@x2
^^"
abstract extension-type-member representation-field get b() → core::int?;
constructor • = self::Foo|constructor#;
constructor tearoff • = self::Foo|constructor#_#new#tearOff;
}
static extension-type-member method Foo|constructor#(core::String x) → self::Foo% /* erasure=core::String, declared=! */ {
lowered final self::Foo% /* erasure=core::String, declared=! */ #this = x;
return #this;
}
static extension-type-member method Foo|constructor#_#new#tearOff(core::String x) → self::Foo% /* erasure=core::String, declared=! */
return self::Foo|constructor#(x);
@@ -0,0 +1,47 @@
library;
//
// Problems in library:
//
// pkg/front_end/testcases/regress/invalid_this_reference_01.dart:6:7: Error: Extension types can't declare instance fields
// Try removing the field declaration or making it a static field
// int x2 = 42;
// ^^
//
// pkg/front_end/testcases/regress/invalid_this_reference_01.dart:9:8: Error: Extension types can't declare instance fields
// Try removing the field declaration or making it a static field
// int? a, b;
// ^
//
// pkg/front_end/testcases/regress/invalid_this_reference_01.dart:8:4: Error: Not a constant expression.
// @x2
// ^^
//
// pkg/front_end/testcases/regress/invalid_this_reference_01.dart:8:4: 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.
// @x2
// ^
//
import self as self;
import "dart:core" as core;
extension type Foo(core::String x) {
abstract extension-type-member representation-field get x() → core::String;
abstract extension-type-member representation-field get x2() → core::int;
@invalid-expression "pkg/front_end/testcases/regress/invalid_this_reference_01.dart:8:4: 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.
@x2
^" in invalid-expression "pkg/front_end/testcases/regress/invalid_this_reference_01.dart:8:4: Error: Not a constant expression.
@x2
^^"
abstract extension-type-member representation-field get a() → core::int?;
@invalid-expression "pkg/front_end/testcases/regress/invalid_this_reference_01.dart:8:4: 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.
@x2
^" in invalid-expression "pkg/front_end/testcases/regress/invalid_this_reference_01.dart:8:4: Error: Not a constant expression.
@x2
^^"
abstract extension-type-member representation-field get b() → core::int?;
constructor • = self::Foo|constructor#;
constructor tearoff • = self::Foo|constructor#_#new#tearOff;
}
static extension-type-member method Foo|constructor#(core::String x) → self::Foo% /* erasure=core::String, declared=! */
;
static extension-type-member method Foo|constructor#_#new#tearOff(core::String x) → self::Foo% /* erasure=core::String, declared=! */
return self::Foo|constructor#(x);
@@ -0,0 +1,49 @@
library;
//
// Problems in library:
//
// pkg/front_end/testcases/regress/invalid_this_reference_01.dart:6:7: Error: Extension types can't declare instance fields
// Try removing the field declaration or making it a static field
// int x2 = 42;
// ^^
//
// pkg/front_end/testcases/regress/invalid_this_reference_01.dart:9:8: Error: Extension types can't declare instance fields
// Try removing the field declaration or making it a static field
// int? a, b;
// ^
//
// pkg/front_end/testcases/regress/invalid_this_reference_01.dart:8:4: Error: Not a constant expression.
// @x2
// ^^
//
// pkg/front_end/testcases/regress/invalid_this_reference_01.dart:8:4: 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.
// @x2
// ^
//
import self as self;
import "dart:core" as core;
extension type Foo(core::String x) {
abstract extension-type-member representation-field get x() → core::String;
abstract extension-type-member representation-field get x2() → core::int;
@invalid-expression "pkg/front_end/testcases/regress/invalid_this_reference_01.dart:8:4: 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.
@x2
^" in invalid-expression "pkg/front_end/testcases/regress/invalid_this_reference_01.dart:8:4: Error: Not a constant expression.
@x2
^^"
abstract extension-type-member representation-field get a() → core::int?;
@invalid-expression "pkg/front_end/testcases/regress/invalid_this_reference_01.dart:8:4: 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.
@x2
^" in invalid-expression "pkg/front_end/testcases/regress/invalid_this_reference_01.dart:8:4: Error: Not a constant expression.
@x2
^^"
abstract extension-type-member representation-field get b() → core::int?;
constructor • = self::Foo|constructor#;
constructor tearoff • = self::Foo|constructor#_#new#tearOff;
}
static extension-type-member method Foo|constructor#(core::String x) → self::Foo% /* erasure=core::String, declared=! */ {
lowered final self::Foo% /* erasure=core::String, declared=! */ #this = x;
return #this;
}
static extension-type-member method Foo|constructor#_#new#tearOff(core::String x) → self::Foo% /* erasure=core::String, declared=! */
return self::Foo|constructor#(x);
@@ -0,0 +1,5 @@
extension type Foo(String x) {
int x2 = 42;
@x2
int? a, b;
}
@@ -0,0 +1,5 @@
extension type Foo(String x) {
@x2
int? a, b;
int x2 = 42;
}
@@ -0,0 +1,11 @@
// 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(String x) {
static const int x1 = 42;
int x2 = 42;
int bar1({int baz = x2}) => 42;
int bar2({int baz = x /* oops forgot the 1 */}) => 42;
}
@@ -0,0 +1,58 @@
library;
//
// Problems in library:
//
// pkg/front_end/testcases/regress/invalid_this_reference_02.dart:7:7: Error: Extension types can't declare instance fields
// Try removing the field declaration or making it a static field
// int x2 = 42;
// ^^
//
// pkg/front_end/testcases/regress/invalid_this_reference_02.dart:9:23: Error: Not a constant expression.
// int bar1({int baz = x2}) => 42;
// ^^
//
// pkg/front_end/testcases/regress/invalid_this_reference_02.dart:10:23: Error: Not a constant expression.
// int bar2({int baz = x /* oops forgot the 1 */}) => 42;
// ^
//
import self as self;
import "dart:core" as core;
extension type Foo(core::String x) {
abstract extension-type-member representation-field get x() → core::String;
abstract extension-type-member representation-field get x2() → core::int;
static field x1 = self::Foo|x1;
method bar1 = self::Foo|bar1;
method tearoff bar1 = self::Foo|get#bar1;
method bar2 = self::Foo|bar2;
method tearoff bar2 = self::Foo|get#bar2;
constructor • = self::Foo|constructor#;
constructor tearoff • = self::Foo|constructor#_#new#tearOff;
}
static const field core::int Foo|x1 = #C1;
static extension-type-member method Foo|constructor#(core::String x) → self::Foo% /* erasure=core::String, declared=! */ {
lowered final self::Foo% /* erasure=core::String, declared=! */ #this = x;
return #this;
}
static extension-type-member method Foo|constructor#_#new#tearOff(core::String x) → self::Foo% /* erasure=core::String, declared=! */
return self::Foo|constructor#(x);
static extension-type-member method Foo|bar1(lowered final self::Foo% /* erasure=core::String, declared=! */ #this, {core::int baz = invalid-expression "pkg/front_end/testcases/regress/invalid_this_reference_02.dart:9:23: Error: Not a constant expression.
int bar1({int baz = x2}) => 42;
^^"}) → core::int
return 42;
static extension-type-member method Foo|get#bar1(lowered final self::Foo% /* erasure=core::String, declared=! */ #this) → ({baz: core::int}) → core::int
return ({core::int baz = invalid-expression "pkg/front_end/testcases/regress/invalid_this_reference_02.dart:9:23: Error: Not a constant expression.
int bar1({int baz = x2}) => 42;
^^"}) → core::int => self::Foo|bar1(#this, baz: baz);
static extension-type-member method Foo|bar2(lowered final self::Foo% /* erasure=core::String, declared=! */ #this, {core::int baz = invalid-expression "pkg/front_end/testcases/regress/invalid_this_reference_02.dart:10:23: Error: Not a constant expression.
int bar2({int baz = x /* oops forgot the 1 */}) => 42;
^"}) → core::int
return 42;
static extension-type-member method Foo|get#bar2(lowered final self::Foo% /* erasure=core::String, declared=! */ #this) → ({baz: core::int}) → core::int
return ({core::int baz = invalid-expression "pkg/front_end/testcases/regress/invalid_this_reference_02.dart:10:23: Error: Not a constant expression.
int bar2({int baz = x /* oops forgot the 1 */}) => 42;
^"}) → core::int => self::Foo|bar2(#this, baz: baz);
constants {
#C1 = 42
}
@@ -0,0 +1,58 @@
library;
//
// Problems in library:
//
// pkg/front_end/testcases/regress/invalid_this_reference_02.dart:7:7: Error: Extension types can't declare instance fields
// Try removing the field declaration or making it a static field
// int x2 = 42;
// ^^
//
// pkg/front_end/testcases/regress/invalid_this_reference_02.dart:9:23: Error: Not a constant expression.
// int bar1({int baz = x2}) => 42;
// ^^
//
// pkg/front_end/testcases/regress/invalid_this_reference_02.dart:10:23: Error: Not a constant expression.
// int bar2({int baz = x /* oops forgot the 1 */}) => 42;
// ^
//
import self as self;
import "dart:core" as core;
extension type Foo(core::String x) {
abstract extension-type-member representation-field get x() → core::String;
abstract extension-type-member representation-field get x2() → core::int;
static field x1 = self::Foo|x1;
method bar1 = self::Foo|bar1;
method tearoff bar1 = self::Foo|get#bar1;
method bar2 = self::Foo|bar2;
method tearoff bar2 = self::Foo|get#bar2;
constructor • = self::Foo|constructor#;
constructor tearoff • = self::Foo|constructor#_#new#tearOff;
}
static const field core::int Foo|x1 = #C1;
static extension-type-member method Foo|constructor#(core::String x) → self::Foo% /* erasure=core::String, declared=! */ {
lowered final self::Foo% /* erasure=core::String, declared=! */ #this = x;
return #this;
}
static extension-type-member method Foo|constructor#_#new#tearOff(core::String x) → self::Foo% /* erasure=core::String, declared=! */
return self::Foo|constructor#(x);
static extension-type-member method Foo|bar1(lowered final self::Foo% /* erasure=core::String, declared=! */ #this, {core::int baz = invalid-expression "pkg/front_end/testcases/regress/invalid_this_reference_02.dart:9:23: Error: Not a constant expression.
int bar1({int baz = x2}) => 42;
^^"}) → core::int
return 42;
static extension-type-member method Foo|get#bar1(lowered final self::Foo% /* erasure=core::String, declared=! */ #this) → ({baz: core::int}) → core::int
return ({core::int baz = invalid-expression "pkg/front_end/testcases/regress/invalid_this_reference_02.dart:9:23: Error: Not a constant expression.
int bar1({int baz = x2}) => 42;
^^"}) → core::int => self::Foo|bar1(#this, baz: baz);
static extension-type-member method Foo|bar2(lowered final self::Foo% /* erasure=core::String, declared=! */ #this, {core::int baz = invalid-expression "pkg/front_end/testcases/regress/invalid_this_reference_02.dart:10:23: Error: Not a constant expression.
int bar2({int baz = x /* oops forgot the 1 */}) => 42;
^"}) → core::int
return 42;
static extension-type-member method Foo|get#bar2(lowered final self::Foo% /* erasure=core::String, declared=! */ #this) → ({baz: core::int}) → core::int
return ({core::int baz = invalid-expression "pkg/front_end/testcases/regress/invalid_this_reference_02.dart:10:23: Error: Not a constant expression.
int bar2({int baz = x /* oops forgot the 1 */}) => 42;
^"}) → core::int => self::Foo|bar2(#this, baz: baz);
constants {
#C1 = 42
}
@@ -0,0 +1,36 @@
library;
//
// Problems in library:
//
// pkg/front_end/testcases/regress/invalid_this_reference_02.dart:7:7: Error: Extension types can't declare instance fields
// Try removing the field declaration or making it a static field
// int x2 = 42;
// ^^
//
import self as self;
import "dart:core" as core;
extension type Foo(core::String x) {
abstract extension-type-member representation-field get x() → core::String;
abstract extension-type-member representation-field get x2() → core::int;
static field x1 = self::Foo|x1;
method bar1 = self::Foo|bar1;
method tearoff bar1 = self::Foo|get#bar1;
method bar2 = self::Foo|bar2;
method tearoff bar2 = self::Foo|get#bar2;
constructor • = self::Foo|constructor#;
constructor tearoff • = self::Foo|constructor#_#new#tearOff;
}
static const field core::int Foo|x1 = 42;
static extension-type-member method Foo|constructor#(core::String x) → self::Foo% /* erasure=core::String, declared=! */
;
static extension-type-member method Foo|constructor#_#new#tearOff(core::String x) → self::Foo% /* erasure=core::String, declared=! */
return self::Foo|constructor#(x);
static extension-type-member method Foo|bar1(lowered final self::Foo% /* erasure=core::String, declared=! */ #this, {has-declared-initializer core::int baz}) → core::int
;
static extension-type-member method Foo|get#bar1(lowered final self::Foo% /* erasure=core::String, declared=! */ #this) → ({baz: core::int}) → core::int
return ({core::int baz}) → core::int => self::Foo|bar1(#this, baz: baz);
static extension-type-member method Foo|bar2(lowered final self::Foo% /* erasure=core::String, declared=! */ #this, {has-declared-initializer core::int baz}) → core::int
;
static extension-type-member method Foo|get#bar2(lowered final self::Foo% /* erasure=core::String, declared=! */ #this) → ({baz: core::int}) → core::int
return ({core::int baz}) → core::int => self::Foo|bar2(#this, baz: baz);
@@ -0,0 +1,58 @@
library;
//
// Problems in library:
//
// pkg/front_end/testcases/regress/invalid_this_reference_02.dart:7:7: Error: Extension types can't declare instance fields
// Try removing the field declaration or making it a static field
// int x2 = 42;
// ^^
//
// pkg/front_end/testcases/regress/invalid_this_reference_02.dart:9:23: Error: Not a constant expression.
// int bar1({int baz = x2}) => 42;
// ^^
//
// pkg/front_end/testcases/regress/invalid_this_reference_02.dart:10:23: Error: Not a constant expression.
// int bar2({int baz = x /* oops forgot the 1 */}) => 42;
// ^
//
import self as self;
import "dart:core" as core;
extension type Foo(core::String x) {
abstract extension-type-member representation-field get x() → core::String;
abstract extension-type-member representation-field get x2() → core::int;
static field x1 = self::Foo|x1;
method bar1 = self::Foo|bar1;
method tearoff bar1 = self::Foo|get#bar1;
method bar2 = self::Foo|bar2;
method tearoff bar2 = self::Foo|get#bar2;
constructor • = self::Foo|constructor#;
constructor tearoff • = self::Foo|constructor#_#new#tearOff;
}
static const field core::int Foo|x1 = #C1;
static extension-type-member method Foo|constructor#(core::String x) → self::Foo% /* erasure=core::String, declared=! */ {
lowered final self::Foo% /* erasure=core::String, declared=! */ #this = x;
return #this;
}
static extension-type-member method Foo|constructor#_#new#tearOff(core::String x) → self::Foo% /* erasure=core::String, declared=! */
return self::Foo|constructor#(x);
static extension-type-member method Foo|bar1(lowered final self::Foo% /* erasure=core::String, declared=! */ #this, {core::int baz = invalid-expression "pkg/front_end/testcases/regress/invalid_this_reference_02.dart:9:23: Error: Not a constant expression.
int bar1({int baz = x2}) => 42;
^^"}) → core::int
return 42;
static extension-type-member method Foo|get#bar1(lowered final self::Foo% /* erasure=core::String, declared=! */ #this) → ({baz: core::int}) → core::int
return ({core::int baz = invalid-expression "pkg/front_end/testcases/regress/invalid_this_reference_02.dart:9:23: Error: Not a constant expression.
int bar1({int baz = x2}) => 42;
^^"}) → core::int => self::Foo|bar1(#this, baz: baz);
static extension-type-member method Foo|bar2(lowered final self::Foo% /* erasure=core::String, declared=! */ #this, {core::int baz = invalid-expression "pkg/front_end/testcases/regress/invalid_this_reference_02.dart:10:23: Error: Not a constant expression.
int bar2({int baz = x /* oops forgot the 1 */}) => 42;
^"}) → core::int
return 42;
static extension-type-member method Foo|get#bar2(lowered final self::Foo% /* erasure=core::String, declared=! */ #this) → ({baz: core::int}) → core::int
return ({core::int baz = invalid-expression "pkg/front_end/testcases/regress/invalid_this_reference_02.dart:10:23: Error: Not a constant expression.
int bar2({int baz = x /* oops forgot the 1 */}) => 42;
^"}) → core::int => self::Foo|bar2(#this, baz: baz);
constants {
#C1 = 42
}
@@ -0,0 +1,6 @@
extension type Foo(String x) {
static const int x1 = 42;
int x2 = 42;
int bar1({int baz = x2}) => 42;
int bar2({int baz = x}) => 42;
}
@@ -0,0 +1,6 @@
extension type Foo(String x) {
int bar1({int baz = x2}) => 42;
int bar2({int baz = x}) => 42;
int x2 = 42;
static const int x1 = 42;
}
@@ -0,0 +1,7 @@
// 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 on int {
int bar({int baz = this}) => 42;
}
@@ -0,0 +1,23 @@
library;
//
// Problems in library:
//
// pkg/front_end/testcases/regress/invalid_this_reference_03.dart:6:22: Error: Expected identifier, but got 'this'.
// int bar({int baz = this}) => 42;
// ^^^^
//
import self as self;
import "dart:core" as core;
extension /* unnamed */ _extension#0 on core::int {
method bar = self::_extension#0|bar;
method tearoff bar = self::_extension#0|get#bar;
}
static extension-member method _extension#0|bar(lowered final core::int #this, {core::int baz = invalid-expression "pkg/front_end/testcases/regress/invalid_this_reference_03.dart:6:22: Error: Expected identifier, but got 'this'.
int bar({int baz = this}) => 42;
^^^^"}) → core::int
return 42;
static extension-member method _extension#0|get#bar(lowered final core::int #this) → ({baz: core::int}) → core::int
return ({core::int baz = invalid-expression "pkg/front_end/testcases/regress/invalid_this_reference_03.dart:6:22: Error: Expected identifier, but got 'this'.
int bar({int baz = this}) => 42;
^^^^"}) → core::int => self::_extension#0|bar(#this, baz: baz);
@@ -0,0 +1,23 @@
library;
//
// Problems in library:
//
// pkg/front_end/testcases/regress/invalid_this_reference_03.dart:6:22: Error: Expected identifier, but got 'this'.
// int bar({int baz = this}) => 42;
// ^^^^
//
import self as self;
import "dart:core" as core;
extension /* unnamed */ _extension#0 on core::int {
method bar = self::_extension#0|bar;
method tearoff bar = self::_extension#0|get#bar;
}
static extension-member method _extension#0|bar(lowered final core::int #this, {core::int baz = invalid-expression "pkg/front_end/testcases/regress/invalid_this_reference_03.dart:6:22: Error: Expected identifier, but got 'this'.
int bar({int baz = this}) => 42;
^^^^"}) → core::int
return 42;
static extension-member method _extension#0|get#bar(lowered final core::int #this) → ({baz: core::int}) → core::int
return ({core::int baz = invalid-expression "pkg/front_end/testcases/regress/invalid_this_reference_03.dart:6:22: Error: Expected identifier, but got 'this'.
int bar({int baz = this}) => 42;
^^^^"}) → core::int => self::_extension#0|bar(#this, baz: baz);
@@ -0,0 +1,12 @@
library;
import self as self;
import "dart:core" as core;
extension /* unnamed */ _extension#0 on core::int {
method bar = self::_extension#0|bar;
method tearoff bar = self::_extension#0|get#bar;
}
static extension-member method _extension#0|bar(lowered final core::int #this, {has-declared-initializer core::int baz}) → core::int
;
static extension-member method _extension#0|get#bar(lowered final core::int #this) → ({baz: core::int}) → core::int
return ({core::int baz}) → core::int => self::_extension#0|bar(#this, baz: baz);
@@ -0,0 +1,23 @@
library;
//
// Problems in library:
//
// pkg/front_end/testcases/regress/invalid_this_reference_03.dart:6:22: Error: Expected identifier, but got 'this'.
// int bar({int baz = this}) => 42;
// ^^^^
//
import self as self;
import "dart:core" as core;
extension /* unnamed */ _extension#0 on core::int {
method bar = self::_extension#0|bar;
method tearoff bar = self::_extension#0|get#bar;
}
static extension-member method _extension#0|bar(lowered final core::int #this, {core::int baz = invalid-expression "pkg/front_end/testcases/regress/invalid_this_reference_03.dart:6:22: Error: Expected identifier, but got 'this'.
int bar({int baz = this}) => 42;
^^^^"}) → core::int
return 42;
static extension-member method _extension#0|get#bar(lowered final core::int #this) → ({baz: core::int}) → core::int
return ({core::int baz = invalid-expression "pkg/front_end/testcases/regress/invalid_this_reference_03.dart:6:22: Error: Expected identifier, but got 'this'.
int bar({int baz = this}) => 42;
^^^^"}) → core::int => self::_extension#0|bar(#this, baz: baz);
@@ -0,0 +1,3 @@
extension on int {
int bar({int baz = this}) => 42;
}
@@ -0,0 +1,3 @@
extension on int {
int bar({int baz = this}) => 42;
}
@@ -0,0 +1,7 @@
// 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.
class Foo {
int bar({dynamic baz = this}) => 42;
}
@@ -0,0 +1,20 @@
library;
//
// Problems in library:
//
// pkg/front_end/testcases/regress/invalid_this_reference_04.dart:6:26: Error: Expected identifier, but got 'this'.
// int bar({dynamic baz = this}) => 42;
// ^^^^
//
import self as self;
import "dart:core" as core;
class Foo extends core::Object {
synthetic constructor •() → self::Foo
: super core::Object::•()
;
method bar({dynamic baz = invalid-expression "pkg/front_end/testcases/regress/invalid_this_reference_04.dart:6:26: Error: Expected identifier, but got 'this'.
int bar({dynamic baz = this}) => 42;
^^^^"}) → core::int
return 42;
}
@@ -0,0 +1,20 @@
library;
//
// Problems in library:
//
// pkg/front_end/testcases/regress/invalid_this_reference_04.dart:6:26: Error: Expected identifier, but got 'this'.
// int bar({dynamic baz = this}) => 42;
// ^^^^
//
import self as self;
import "dart:core" as core;
class Foo extends core::Object {
synthetic constructor •() → self::Foo
: super core::Object::•()
;
method bar({dynamic baz = invalid-expression "pkg/front_end/testcases/regress/invalid_this_reference_04.dart:6:26: Error: Expected identifier, but got 'this'.
int bar({dynamic baz = this}) => 42;
^^^^"}) → core::int
return 42;
}
@@ -0,0 +1,19 @@
library;
//
// Problems in library:
//
// pkg/front_end/testcases/regress/invalid_this_reference_04.dart:6:26: Error: Expected identifier, but got 'this'.
// int bar({dynamic baz = this}) => 42;
// ^^^^
//
import self as self;
import "dart:core" as core;
class Foo extends core::Object {
synthetic constructor •() → self::Foo
;
method bar({dynamic baz = invalid-expression "pkg/front_end/testcases/regress/invalid_this_reference_04.dart:6:26: Error: Expected identifier, but got 'this'.
int bar({dynamic baz = this}) => 42;
^^^^"}) → core::int
;
}
@@ -0,0 +1,20 @@
library;
//
// Problems in library:
//
// pkg/front_end/testcases/regress/invalid_this_reference_04.dart:6:26: Error: Expected identifier, but got 'this'.
// int bar({dynamic baz = this}) => 42;
// ^^^^
//
import self as self;
import "dart:core" as core;
class Foo extends core::Object {
synthetic constructor •() → self::Foo
: super core::Object::•()
;
method bar({dynamic baz = invalid-expression "pkg/front_end/testcases/regress/invalid_this_reference_04.dart:6:26: Error: Expected identifier, but got 'this'.
int bar({dynamic baz = this}) => 42;
^^^^"}) → core::int
return 42;
}
@@ -0,0 +1,3 @@
class Foo {
int bar({dynamic baz = this}) => 42;
}
@@ -0,0 +1,3 @@
class Foo {
int bar({dynamic baz = this}) => 42;
}
@@ -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.
class Foo {
int x2 = 42;
@x2
int? a, b;
}
@@ -0,0 +1,29 @@
library;
//
// Problems in library:
//
// pkg/front_end/testcases/regress/invalid_this_reference_05.dart:8:4: Error: Not a constant expression.
// @x2
// ^^
//
// pkg/front_end/testcases/regress/invalid_this_reference_05.dart:8:4: 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.
// @x2
// ^
//
import self as self;
import "dart:core" as core;
class Foo extends core::Object {
field core::int x2 = 42;
@invalid-expression "pkg/front_end/testcases/regress/invalid_this_reference_05.dart:8:4: 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.
@x2
^"
field core::int? a = null;
@invalid-expression "pkg/front_end/testcases/regress/invalid_this_reference_05.dart:8:4: 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.
@x2
^"
field core::int? b = null;
synthetic constructor •() → self::Foo
: super core::Object::•()
;
}
@@ -0,0 +1,29 @@
library;
//
// Problems in library:
//
// pkg/front_end/testcases/regress/invalid_this_reference_05.dart:8:4: Error: Not a constant expression.
// @x2
// ^^
//
// pkg/front_end/testcases/regress/invalid_this_reference_05.dart:8:4: 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.
// @x2
// ^
//
import self as self;
import "dart:core" as core;
class Foo extends core::Object {
field core::int x2 = 42;
@invalid-expression "pkg/front_end/testcases/regress/invalid_this_reference_05.dart:8:4: 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.
@x2
^"
field core::int? a = null;
@invalid-expression "pkg/front_end/testcases/regress/invalid_this_reference_05.dart:8:4: 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.
@x2
^"
field core::int? b = null;
synthetic constructor •() → self::Foo
: super core::Object::•()
;
}
@@ -0,0 +1,28 @@
library;
//
// Problems in library:
//
// pkg/front_end/testcases/regress/invalid_this_reference_05.dart:8:4: Error: Not a constant expression.
// @x2
// ^^
//
// pkg/front_end/testcases/regress/invalid_this_reference_05.dart:8:4: 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.
// @x2
// ^
//
import self as self;
import "dart:core" as core;
class Foo extends core::Object {
field core::int x2;
@invalid-expression "pkg/front_end/testcases/regress/invalid_this_reference_05.dart:8:4: 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.
@x2
^" in this.{self::Foo::x2}{core::int}
field core::int? a;
@invalid-expression "pkg/front_end/testcases/regress/invalid_this_reference_05.dart:8:4: 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.
@x2
^" in this.{self::Foo::x2}{core::int}
field core::int? b;
synthetic constructor •() → self::Foo
;
}
@@ -0,0 +1,29 @@
library;
//
// Problems in library:
//
// pkg/front_end/testcases/regress/invalid_this_reference_05.dart:8:4: Error: Not a constant expression.
// @x2
// ^^
//
// pkg/front_end/testcases/regress/invalid_this_reference_05.dart:8:4: 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.
// @x2
// ^
//
import self as self;
import "dart:core" as core;
class Foo extends core::Object {
field core::int x2 = 42;
@invalid-expression "pkg/front_end/testcases/regress/invalid_this_reference_05.dart:8:4: 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.
@x2
^"
field core::int? a = null;
@invalid-expression "pkg/front_end/testcases/regress/invalid_this_reference_05.dart:8:4: 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.
@x2
^"
field core::int? b = null;
synthetic constructor •() → self::Foo
: super core::Object::•()
;
}
@@ -0,0 +1,5 @@
class Foo {
int x2 = 42;
@x2
int? a, b;
}
@@ -0,0 +1,5 @@
class Foo {
@x2
int? a, b;
int x2 = 42;
}