-
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 extension type declarations with dot shorthands.
This CL adds the work needed to be able to use dot shorthands with extension types. Also, there's some additional work to set `isSetter` to false for dot shorthands. Static setters don't work together with shorthands. Bug: #59758 Change-Id: I2c14606cf2970ee249f48189c686ea5cb963df0b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/412784 Reviewed-by: Chloe Stefantsova <cstefantsova@google.com> Commit-Queue: Kallen Tu <kallentu@google.com>
- Loading branch information
Showing
12 changed files
with
147 additions
and
9 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
11 changes: 11 additions & 0 deletions
11
pkg/front_end/testcases/dot_shorthands/extension_type.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,11 @@ | ||
// 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. | ||
|
||
extension type IntegerExt(int integer) { | ||
static IntegerExt get one => IntegerExt(1); | ||
} | ||
|
||
void main() { | ||
IntegerExt c = .one; | ||
} |
21 changes: 21 additions & 0 deletions
21
pkg/front_end/testcases/dot_shorthands/extension_type.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,21 @@ | ||
library; | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
extension type IntegerExt(core::int integer) { | ||
abstract extension-type-member representation-field get integer() → core::int; | ||
static get one = get self::IntegerExt|one; | ||
constructor • = self::IntegerExt|constructor#; | ||
constructor tearoff • = self::IntegerExt|constructor#_#new#tearOff; | ||
} | ||
static extension-type-member method IntegerExt|constructor#(core::int integer) → self::IntegerExt% /* erasure=core::int, declared=! */ { | ||
lowered final self::IntegerExt% /* erasure=core::int, declared=! */ #this = integer; | ||
return #this; | ||
} | ||
static extension-type-member method IntegerExt|constructor#_#new#tearOff(core::int integer) → self::IntegerExt% /* erasure=core::int, declared=! */ | ||
return self::IntegerExt|constructor#(integer); | ||
static extension-type-member get IntegerExt|one() → self::IntegerExt% /* erasure=core::int, declared=! */ | ||
return self::IntegerExt|constructor#(1); | ||
static method main() → void { | ||
self::IntegerExt% /* erasure=core::int, declared=! */ c = self::IntegerExt|one; | ||
} |
21 changes: 21 additions & 0 deletions
21
pkg/front_end/testcases/dot_shorthands/extension_type.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,21 @@ | ||
library; | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
extension type IntegerExt(core::int integer) { | ||
abstract extension-type-member representation-field get integer() → core::int; | ||
static get one = get self::IntegerExt|one; | ||
constructor • = self::IntegerExt|constructor#; | ||
constructor tearoff • = self::IntegerExt|constructor#_#new#tearOff; | ||
} | ||
static extension-type-member method IntegerExt|constructor#(core::int integer) → self::IntegerExt% /* erasure=core::int, declared=! */ { | ||
lowered final self::IntegerExt% /* erasure=core::int, declared=! */ #this = integer; | ||
return #this; | ||
} | ||
static extension-type-member method IntegerExt|constructor#_#new#tearOff(core::int integer) → self::IntegerExt% /* erasure=core::int, declared=! */ | ||
return self::IntegerExt|constructor#(integer); | ||
static extension-type-member get IntegerExt|one() → self::IntegerExt% /* erasure=core::int, declared=! */ | ||
return self::IntegerExt|constructor#(1); | ||
static method main() → void { | ||
self::IntegerExt% /* erasure=core::int, declared=! */ c = self::IntegerExt|one; | ||
} |
18 changes: 18 additions & 0 deletions
18
pkg/front_end/testcases/dot_shorthands/extension_type.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,18 @@ | ||
library; | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
extension type IntegerExt(core::int integer) { | ||
abstract extension-type-member representation-field get integer() → core::int; | ||
static get one = get self::IntegerExt|one; | ||
constructor • = self::IntegerExt|constructor#; | ||
constructor tearoff • = self::IntegerExt|constructor#_#new#tearOff; | ||
} | ||
static extension-type-member method IntegerExt|constructor#(core::int integer) → self::IntegerExt% /* erasure=core::int, declared=! */ | ||
; | ||
static extension-type-member method IntegerExt|constructor#_#new#tearOff(core::int integer) → self::IntegerExt% /* erasure=core::int, declared=! */ | ||
return self::IntegerExt|constructor#(integer); | ||
static extension-type-member get IntegerExt|one() → self::IntegerExt% /* erasure=core::int, declared=! */ | ||
; | ||
static method main() → void | ||
; |
21 changes: 21 additions & 0 deletions
21
pkg/front_end/testcases/dot_shorthands/extension_type.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,21 @@ | ||
library; | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
extension type IntegerExt(core::int integer) { | ||
abstract extension-type-member representation-field get integer() → core::int; | ||
static get one = get self::IntegerExt|one; | ||
constructor • = self::IntegerExt|constructor#; | ||
constructor tearoff • = self::IntegerExt|constructor#_#new#tearOff; | ||
} | ||
static extension-type-member method IntegerExt|constructor#(core::int integer) → self::IntegerExt% /* erasure=core::int, declared=! */ { | ||
lowered final self::IntegerExt% /* erasure=core::int, declared=! */ #this = integer; | ||
return #this; | ||
} | ||
static extension-type-member method IntegerExt|constructor#_#new#tearOff(core::int integer) → self::IntegerExt% /* erasure=core::int, declared=! */ | ||
return self::IntegerExt|constructor#(integer); | ||
static extension-type-member get IntegerExt|one() → self::IntegerExt% /* erasure=core::int, declared=! */ | ||
return self::IntegerExt|constructor#(1); | ||
static method main() → void { | ||
self::IntegerExt% /* erasure=core::int, declared=! */ c = self::IntegerExt|one; | ||
} |
5 changes: 5 additions & 0 deletions
5
pkg/front_end/testcases/dot_shorthands/extension_type.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,5 @@ | ||
extension type IntegerExt(int integer) { | ||
static IntegerExt get one => IntegerExt(1); | ||
} | ||
|
||
void main() {} |
5 changes: 5 additions & 0 deletions
5
pkg/front_end/testcases/dot_shorthands/extension_type.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,5 @@ | ||
extension type IntegerExt(int integer) { | ||
static IntegerExt get one => IntegerExt(1); | ||
} | ||
|
||
void main() {} |