-
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] Handle static gets and tearoffs in dot shorthands
Resolve static getters and tear-offs in dot shorthands. Method and constructor invocations will come in a later CL. Also, looking to update the parser handling in a future CL, but we'll work incrementally. Bug: #59758 Change-Id: I15c9eb7e531975ea19d496a03ac4b666fa15a04e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/411940 Reviewed-by: Chloe Stefantsova <[email protected]> Commit-Queue: Kallen Tu <[email protected]>
- Loading branch information
Showing
30 changed files
with
442 additions
and
21 deletions.
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
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
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 @@ | ||
--enable-experiment=dot-shorthands |
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,13 @@ | ||
// Copyright (c) 2025, 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 Color { | ||
final int x; | ||
static Color get red => Color(1); | ||
Color(this.x); | ||
} | ||
|
||
void main() { | ||
Color c = .red; | ||
} |
23 changes: 23 additions & 0 deletions
23
pkg/front_end/testcases/dot_shorthands/simple_class.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,23 @@ | ||
library; | ||
// | ||
// Problems in library: | ||
// | ||
// pkg/front_end/testcases/dot_shorthands/simple_class.dart:12:13: Error: Expected an identifier, but got '.'. | ||
// Try inserting an identifier before '.'. | ||
// Color c = .red; | ||
// ^ | ||
// | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
class Color extends core::Object { | ||
final field core::int x; | ||
constructor •(core::int x) → self::Color | ||
: self::Color::x = x, super core::Object::•() | ||
; | ||
static get red() → self::Color | ||
return new self::Color::•(1); | ||
} | ||
static method main() → void { | ||
self::Color c = self::Color::red; | ||
} |
23 changes: 23 additions & 0 deletions
23
pkg/front_end/testcases/dot_shorthands/simple_class.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,23 @@ | ||
library; | ||
// | ||
// Problems in library: | ||
// | ||
// pkg/front_end/testcases/dot_shorthands/simple_class.dart:12:13: Error: Expected an identifier, but got '.'. | ||
// Try inserting an identifier before '.'. | ||
// Color c = .red; | ||
// ^ | ||
// | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
class Color extends core::Object { | ||
final field core::int x; | ||
constructor •(core::int x) → self::Color | ||
: self::Color::x = x, super core::Object::•() | ||
; | ||
static get red() → self::Color | ||
return new self::Color::•(1); | ||
} | ||
static method main() → void { | ||
self::Color c = self::Color::red; | ||
} |
13 changes: 13 additions & 0 deletions
13
pkg/front_end/testcases/dot_shorthands/simple_class.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,13 @@ | ||
library; | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
class Color extends core::Object { | ||
final field core::int x; | ||
constructor •(core::int x) → self::Color | ||
; | ||
static get red() → self::Color | ||
; | ||
} | ||
static method main() → void | ||
; |
23 changes: 23 additions & 0 deletions
23
pkg/front_end/testcases/dot_shorthands/simple_class.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,23 @@ | ||
library; | ||
// | ||
// Problems in library: | ||
// | ||
// pkg/front_end/testcases/dot_shorthands/simple_class.dart:12:13: Error: Expected an identifier, but got '.'. | ||
// Try inserting an identifier before '.'. | ||
// Color c = .red; | ||
// ^ | ||
// | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
class Color extends core::Object { | ||
final field core::int x; | ||
constructor •(core::int x) → self::Color | ||
: self::Color::x = x, super core::Object::•() | ||
; | ||
static get red() → self::Color | ||
return new self::Color::•(1); | ||
} | ||
static method main() → void { | ||
self::Color c = self::Color::red; | ||
} |
7 changes: 7 additions & 0 deletions
7
pkg/front_end/testcases/dot_shorthands/simple_class.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,7 @@ | ||
class Color { | ||
final int x; | ||
static Color get red => Color(1); | ||
Color(this.x); | ||
} | ||
|
||
void main() {} |
Oops, something went wrong.