-
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.
[stable][cfe] Add ExtensionTypeRepresentationFieldInitializer.replace…
…Child The added method is required for the resolution of redirection targets to work: it replaces the immediate target invocation node with the final target invocation node. Closes #55135 Cherry-pick: https://dart-review.googlesource.com/c/sdk/+/357161 Cherry-pick-request: #55194 Change-Id: I96643c5af0ca91209cd936aee78f13c416679275 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/357600 Commit-Queue: Chloe Stefantsova <[email protected]> Reviewed-by: Johnni Winther <[email protected]>
- Loading branch information
1 parent
99b7157
commit 6afc2d7
Showing
20 changed files
with
636 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// 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 B implements A { | ||
final int x = 1; | ||
} | ||
abstract class A { | ||
int get x; | ||
factory A() = B; | ||
} | ||
|
||
extension type C._(A point) implements A { | ||
C() : point = A(); // << initializer is redirecting factory | ||
} | ||
|
||
void main() { | ||
expectEquals(A().x, 1); | ||
expectEquals(C().x, 1); | ||
} | ||
|
||
expectEquals(x, y) { | ||
if (x != y) { | ||
throw "Expected equal values, got '${x}' and '${y}'."; | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
pkg/front_end/testcases/dart2js/issue55135.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,47 @@ | ||
library; | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
class B extends core::Object implements self::A { | ||
final field core::int x = 1; | ||
synthetic constructor •() → self::B | ||
: super core::Object::•() | ||
; | ||
static method _#new#tearOff() → self::B | ||
return new self::B::•(); | ||
} | ||
abstract class A extends core::Object { | ||
abstract get x() → core::int; | ||
static factory •() → self::A /* redirection-target: self::B::• */ | ||
return new self::B::•(); | ||
static method _#new#tearOff() → self::A | ||
return new self::B::•(); | ||
} | ||
extension type C(self::A point) implements self::A { | ||
abstract extension-type-member representation-field get point() → self::A; | ||
constructor _ = self::C|constructor#_; | ||
constructor tearoff _ = self::C|constructor#_#_#tearOff; | ||
constructor • = self::C|constructor#; | ||
constructor tearoff • = self::C|constructor#_#new#tearOff; | ||
} | ||
static extension-type-member method C|constructor#_(self::A point) → self::C /* = self::A */ { | ||
lowered final self::C /* = self::A */ #this = point; | ||
return #this; | ||
} | ||
static extension-type-member method C|constructor#_#_#tearOff(self::A point) → self::C /* = self::A */ | ||
return self::C|constructor#_(point); | ||
static extension-type-member method C|constructor#() → self::C /* = self::A */ { | ||
lowered final self::C /* = self::A */ #this = new self::B::•(); | ||
return #this; | ||
} | ||
static extension-type-member method C|constructor#_#new#tearOff() → self::C /* = self::A */ | ||
return self::C|constructor#(); | ||
static method main() → void { | ||
self::expectEquals(new self::B::•().{self::A::x}{core::int}, 1); | ||
self::expectEquals(self::C|constructor#().{self::A::x}{core::int}, 1); | ||
} | ||
static method expectEquals(dynamic x, dynamic y) → dynamic { | ||
if(!(x =={core::Object::==}{(core::Object) → core::bool} y)) { | ||
throw "Expected equal values, got '${x}' and '${y}'."; | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
pkg/front_end/testcases/dart2js/issue55135.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,47 @@ | ||
library; | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
class B extends core::Object implements self::A { | ||
final field core::int x = 1; | ||
synthetic constructor •() → self::B | ||
: super core::Object::•() | ||
; | ||
static method _#new#tearOff() → self::B | ||
return new self::B::•(); | ||
} | ||
abstract class A extends core::Object { | ||
abstract get x() → core::int; | ||
static factory •() → self::A /* redirection-target: self::B::• */ | ||
return new self::B::•(); | ||
static method _#new#tearOff() → self::A | ||
return new self::B::•(); | ||
} | ||
extension type C(self::A point) implements self::A { | ||
abstract extension-type-member representation-field get point() → self::A; | ||
constructor _ = self::C|constructor#_; | ||
constructor tearoff _ = self::C|constructor#_#_#tearOff; | ||
constructor • = self::C|constructor#; | ||
constructor tearoff • = self::C|constructor#_#new#tearOff; | ||
} | ||
static extension-type-member method C|constructor#_(self::A point) → self::C /* = self::A */ { | ||
lowered final self::C /* = self::A */ #this = point; | ||
return #this; | ||
} | ||
static extension-type-member method C|constructor#_#_#tearOff(self::A point) → self::C /* = self::A */ | ||
return self::C|constructor#_(point); | ||
static extension-type-member method C|constructor#() → self::C /* = self::A */ { | ||
lowered final self::C /* = self::A */ #this = new self::B::•(); | ||
return #this; | ||
} | ||
static extension-type-member method C|constructor#_#new#tearOff() → self::C /* = self::A */ | ||
return self::C|constructor#(); | ||
static method main() → void { | ||
self::expectEquals(new self::B::•().{self::A::x}{core::int}, 1); | ||
self::expectEquals(self::C|constructor#().{self::A::x}{core::int}, 1); | ||
} | ||
static method expectEquals(dynamic x, dynamic y) → dynamic { | ||
if(!(x =={core::Object::==}{(core::Object) → core::bool} y)) { | ||
throw "Expected equal values, got '${x}' and '${y}'."; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
pkg/front_end/testcases/dart2js/issue55135.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,14 @@ | ||
class B implements A { | ||
final int x = 1; | ||
} | ||
|
||
abstract class A { | ||
int get x; | ||
factory A() = B; | ||
} | ||
|
||
extension type C._(A point) implements A { | ||
C() : point = A(); | ||
} | ||
void main() {} | ||
expectEquals(x, y) {} |
14 changes: 14 additions & 0 deletions
14
pkg/front_end/testcases/dart2js/issue55135.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,14 @@ | ||
abstract class A { | ||
factory A() = B; | ||
int get x; | ||
} | ||
|
||
class B implements A { | ||
final int x = 1; | ||
} | ||
|
||
expectEquals(x, y) {} | ||
extension type C._(A point) implements A { | ||
C() : point = A(); | ||
} | ||
void main() {} |
47 changes: 47 additions & 0 deletions
47
pkg/front_end/testcases/dart2js/issue55135.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,47 @@ | ||
library; | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
class B extends core::Object implements self::A { | ||
final field core::int x = 1; | ||
synthetic constructor •() → self::B | ||
: super core::Object::•() | ||
; | ||
static method _#new#tearOff() → self::B | ||
return new self::B::•(); | ||
} | ||
abstract class A extends core::Object { | ||
abstract get x() → core::int; | ||
static factory •() → self::A /* redirection-target: self::B::• */ | ||
return new self::B::•(); | ||
static method _#new#tearOff() → self::A | ||
return new self::B::•(); | ||
} | ||
extension type C(self::A point) implements self::A { | ||
abstract extension-type-member representation-field get point() → self::A; | ||
constructor _ = self::C|constructor#_; | ||
constructor tearoff _ = self::C|constructor#_#_#tearOff; | ||
constructor • = self::C|constructor#; | ||
constructor tearoff • = self::C|constructor#_#new#tearOff; | ||
} | ||
static extension-type-member method C|constructor#_(self::A point) → self::C /* = self::A */ { | ||
lowered final self::C /* = self::A */ #this = point; | ||
return #this; | ||
} | ||
static extension-type-member method C|constructor#_#_#tearOff(self::A point) → self::C /* = self::A */ | ||
return self::C|constructor#_(point); | ||
static extension-type-member method C|constructor#() → self::C /* = self::A */ { | ||
lowered final self::C /* = self::A */ #this = new self::B::•(); | ||
return #this; | ||
} | ||
static extension-type-member method C|constructor#_#new#tearOff() → self::C /* = self::A */ | ||
return self::C|constructor#(); | ||
static method main() → void { | ||
self::expectEquals(new self::B::•().{self::A::x}{core::int}, 1); | ||
self::expectEquals(self::C|constructor#().{self::A::x}{core::int}, 1); | ||
} | ||
static method expectEquals(dynamic x, dynamic y) → dynamic { | ||
if(!(x =={core::Object::==}{(core::Object) → core::bool} y)) { | ||
throw "Expected equal values, got '${x}' and '${y}'."; | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
pkg/front_end/testcases/dart2js/issue55135.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,47 @@ | ||
library; | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
class B extends core::Object implements self::A { | ||
final field core::int x = 1; | ||
synthetic constructor •() → self::B | ||
: super core::Object::•() | ||
; | ||
static method _#new#tearOff() → self::B | ||
return new self::B::•(); | ||
} | ||
abstract class A extends core::Object { | ||
abstract get x() → core::int; | ||
static factory •() → self::A /* redirection-target: self::B::• */ | ||
return new self::B::•(); | ||
static method _#new#tearOff() → self::A | ||
return new self::B::•(); | ||
} | ||
extension type C(self::A point) implements self::A { | ||
abstract extension-type-member representation-field get point() → self::A; | ||
constructor _ = self::C|constructor#_; | ||
constructor tearoff _ = self::C|constructor#_#_#tearOff; | ||
constructor • = self::C|constructor#; | ||
constructor tearoff • = self::C|constructor#_#new#tearOff; | ||
} | ||
static extension-type-member method C|constructor#_(self::A point) → self::C /* = self::A */ { | ||
lowered final self::C /* = self::A */ #this = point; | ||
return #this; | ||
} | ||
static extension-type-member method C|constructor#_#_#tearOff(self::A point) → self::C /* = self::A */ | ||
return self::C|constructor#_(point); | ||
static extension-type-member method C|constructor#() → self::C /* = self::A */ { | ||
lowered final self::C /* = self::A */ #this = new self::B::•(); | ||
return #this; | ||
} | ||
static extension-type-member method C|constructor#_#new#tearOff() → self::C /* = self::A */ | ||
return self::C|constructor#(); | ||
static method main() → void { | ||
self::expectEquals(new self::B::•().{self::A::x}{core::int}, 1); | ||
self::expectEquals(self::C|constructor#().{self::A::x}{core::int}, 1); | ||
} | ||
static method expectEquals(dynamic x, dynamic y) → dynamic { | ||
if(!(x =={core::Object::==}{(core::Object) → core::bool} y)) { | ||
throw "Expected equal values, got '${x}' and '${y}'."; | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
pkg/front_end/testcases/dart2js/issue55135.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,37 @@ | ||
library; | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
class B extends core::Object implements self::A { | ||
final field core::int x; | ||
synthetic constructor •() → self::B | ||
; | ||
static method _#new#tearOff() → self::B | ||
return new self::B::•(); | ||
} | ||
abstract class A extends core::Object { | ||
abstract get x() → core::int; | ||
static factory •() → self::A /* redirection-target: self::B::• */ | ||
return new self::B::•(); | ||
static method _#new#tearOff() → self::A | ||
return new self::B::•(); | ||
} | ||
extension type C(self::A point) implements self::A { | ||
abstract extension-type-member representation-field get point() → self::A; | ||
constructor _ = self::C|constructor#_; | ||
constructor tearoff _ = self::C|constructor#_#_#tearOff; | ||
constructor • = self::C|constructor#; | ||
constructor tearoff • = self::C|constructor#_#new#tearOff; | ||
} | ||
static extension-type-member method C|constructor#_(self::A point) → self::C /* = self::A */ | ||
; | ||
static extension-type-member method C|constructor#_#_#tearOff(self::A point) → self::C /* = self::A */ | ||
return self::C|constructor#_(point); | ||
static extension-type-member method C|constructor#() → self::C /* = self::A */ | ||
; | ||
static extension-type-member method C|constructor#_#new#tearOff() → self::C /* = self::A */ | ||
return self::C|constructor#(); | ||
static method main() → void | ||
; | ||
static method expectEquals(dynamic x, dynamic y) → dynamic | ||
; |
47 changes: 47 additions & 0 deletions
47
pkg/front_end/testcases/dart2js/issue55135.dart.weak.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,47 @@ | ||
library; | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
class B extends core::Object implements self::A { | ||
final field core::int x = 1; | ||
synthetic constructor •() → self::B | ||
: super core::Object::•() | ||
; | ||
static method _#new#tearOff() → self::B | ||
return new self::B::•(); | ||
} | ||
abstract class A extends core::Object { | ||
abstract get x() → core::int; | ||
static factory •() → self::A /* redirection-target: self::B::• */ | ||
return new self::B::•(); | ||
static method _#new#tearOff() → self::A | ||
return new self::B::•(); | ||
} | ||
extension type C(self::A point) implements self::A { | ||
abstract extension-type-member representation-field get point() → self::A; | ||
constructor _ = self::C|constructor#_; | ||
constructor tearoff _ = self::C|constructor#_#_#tearOff; | ||
constructor • = self::C|constructor#; | ||
constructor tearoff • = self::C|constructor#_#new#tearOff; | ||
} | ||
static extension-type-member method C|constructor#_(self::A point) → self::C /* = self::A */ { | ||
lowered final self::C /* = self::A */ #this = point; | ||
return #this; | ||
} | ||
static extension-type-member method C|constructor#_#_#tearOff(self::A point) → self::C /* = self::A */ | ||
return self::C|constructor#_(point); | ||
static extension-type-member method C|constructor#() → self::C /* = self::A */ { | ||
lowered final self::C /* = self::A */ #this = new self::B::•(); | ||
return #this; | ||
} | ||
static extension-type-member method C|constructor#_#new#tearOff() → self::C /* = self::A */ | ||
return self::C|constructor#(); | ||
static method main() → void { | ||
self::expectEquals(new self::B::•().{self::A::x}{core::int}, 1); | ||
self::expectEquals(self::C|constructor#().{self::A::x}{core::int}, 1); | ||
} | ||
static method expectEquals(dynamic x, dynamic y) → dynamic { | ||
if(!(x =={core::Object::==}{(core::Object) → core::bool} y)) { | ||
throw "Expected equal values, got '${x}' and '${y}'."; | ||
} | ||
} |
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,26 @@ | ||
// 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 B implements A { | ||
final int x = 1; | ||
} | ||
abstract class A { | ||
int get x; | ||
factory A() = B; | ||
} | ||
|
||
extension type C._(A point) implements A { | ||
C() : point = A(); // << initializer is redirecting factory | ||
} | ||
|
||
void main() { | ||
expectEquals(A().x, 1); | ||
expectEquals(C().x, 1); | ||
} | ||
|
||
expectEquals(x, y) { | ||
if (x != y) { | ||
throw "Expected equal values, got '${x}' and '${y}'."; | ||
} | ||
} |
Oops, something went wrong.