-
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 inline class representation field in object pattern
Closes #52667 Change-Id: I9c6d51597ff27ae3a7cdeed29d75755c18a2d530 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311742 Commit-Queue: Johnni Winther <johnniwinther@google.com> Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
- Loading branch information
1 parent
9b9a8cf
commit 911b376
Showing
12 changed files
with
318 additions
and
2 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,25 @@ | ||
// Copyright (c) 2023, 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. | ||
|
||
abstract class Foo {} | ||
|
||
inline class FooBar implements Foo { | ||
final int i; | ||
|
||
const FooBar(this.i); | ||
} | ||
|
||
inline class FooBaz implements Foo { | ||
final int i; | ||
|
||
const FooBaz(this.i); | ||
} | ||
|
||
void main() { | ||
final a = FooBar(0); | ||
switch (a) { | ||
case FooBar(i: final a): | ||
print("FooBar $a"); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
pkg/front_end/testcases/inline_class/issue52667.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,44 @@ | ||
library; | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
abstract class Foo extends core::Object { | ||
synthetic constructor •() → self::Foo | ||
: super core::Object::•() | ||
; | ||
} | ||
inline class FooBar /* declaredRepresentationType = core::int */ { | ||
constructor • = self::FooBar|; | ||
tearoff • = self::FooBar|_#new#tearOff; | ||
} | ||
inline class FooBaz /* declaredRepresentationType = core::int */ { | ||
constructor • = self::FooBaz|; | ||
tearoff • = self::FooBaz|_#new#tearOff; | ||
} | ||
static inline-class-member method FooBar|(core::int i) → self::FooBar { | ||
lowered final self::FooBar #this = i; | ||
return #this; | ||
} | ||
static inline-class-member method FooBar|_#new#tearOff(core::int i) → self::FooBar | ||
return self::FooBar|(i); | ||
static inline-class-member method FooBaz|(core::int i) → self::FooBaz { | ||
lowered final self::FooBaz #this = i; | ||
return #this; | ||
} | ||
static inline-class-member method FooBaz|_#new#tearOff(core::int i) → self::FooBaz | ||
return self::FooBaz|(i); | ||
static method main() → void { | ||
final self::FooBar a = self::FooBar|(0); | ||
#L1: | ||
{ | ||
final synthesized self::FooBar #0#0 = a; | ||
{ | ||
final hoisted core::int a; | ||
if(let final dynamic #t1 = a = #0#0 as{Unchecked} core::int in true) { | ||
{ | ||
core::print("FooBar ${a}"); | ||
} | ||
} | ||
} | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
pkg/front_end/testcases/inline_class/issue52667.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,49 @@ | ||
library; | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
abstract class Foo extends core::Object { | ||
synthetic constructor •() → self::Foo | ||
: super core::Object::•() | ||
; | ||
} | ||
inline class FooBar /* declaredRepresentationType = core::int */ { | ||
constructor • = self::FooBar|; | ||
tearoff • = self::FooBar|_#new#tearOff; | ||
} | ||
inline class FooBaz /* declaredRepresentationType = core::int */ { | ||
constructor • = self::FooBaz|; | ||
tearoff • = self::FooBaz|_#new#tearOff; | ||
} | ||
static inline-class-member method FooBar|(core::int i) → self::FooBar { | ||
lowered final self::FooBar #this = i; | ||
return #this; | ||
} | ||
static inline-class-member method FooBar|_#new#tearOff(core::int i) → self::FooBar | ||
return self::FooBar|(i); | ||
static inline-class-member method FooBaz|(core::int i) → self::FooBaz { | ||
lowered final self::FooBaz #this = i; | ||
return #this; | ||
} | ||
static inline-class-member method FooBaz|_#new#tearOff(core::int i) → self::FooBaz | ||
return self::FooBaz|(i); | ||
static method main() → void { | ||
final self::FooBar a = self::FooBar|(0); | ||
#L1: | ||
{ | ||
final synthesized self::FooBar #0#0 = a; | ||
{ | ||
final hoisted core::int a; | ||
if(let final core::int #t1 = a = #0#0 as{Unchecked} core::int in true) { | ||
{ | ||
core::print("FooBar ${a}"); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
Extra constant evaluation status: | ||
Evaluated: FactoryConstructorInvocation @ org-dartlang-testcase:///issue52667.dart:20:13 -> IntConstant(0) | ||
Extra constant evaluation: evaluated: 17, effectively constant: 1 |
13 changes: 13 additions & 0 deletions
13
pkg/front_end/testcases/inline_class/issue52667.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,13 @@ | ||
abstract class Foo {} | ||
|
||
inline class FooBar implements Foo { | ||
final int i; | ||
const FooBar(this.i); | ||
} | ||
|
||
inline class FooBaz implements Foo { | ||
final int i; | ||
const FooBaz(this.i); | ||
} | ||
|
||
void main() {} |
13 changes: 13 additions & 0 deletions
13
pkg/front_end/testcases/inline_class/issue52667.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,13 @@ | ||
abstract class Foo {} | ||
|
||
inline class FooBar implements Foo { | ||
const FooBar(this.i); | ||
final int i; | ||
} | ||
|
||
inline class FooBaz implements Foo { | ||
const FooBaz(this.i); | ||
final int i; | ||
} | ||
|
||
void main() {} |
44 changes: 44 additions & 0 deletions
44
pkg/front_end/testcases/inline_class/issue52667.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,44 @@ | ||
library; | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
abstract class Foo extends core::Object { | ||
synthetic constructor •() → self::Foo | ||
: super core::Object::•() | ||
; | ||
} | ||
inline class FooBar /* declaredRepresentationType = core::int */ { | ||
constructor • = self::FooBar|; | ||
tearoff • = self::FooBar|_#new#tearOff; | ||
} | ||
inline class FooBaz /* declaredRepresentationType = core::int */ { | ||
constructor • = self::FooBaz|; | ||
tearoff • = self::FooBaz|_#new#tearOff; | ||
} | ||
static inline-class-member method FooBar|(core::int i) → self::FooBar { | ||
lowered final self::FooBar #this = i; | ||
return #this; | ||
} | ||
static inline-class-member method FooBar|_#new#tearOff(core::int i) → self::FooBar | ||
return self::FooBar|(i); | ||
static inline-class-member method FooBaz|(core::int i) → self::FooBaz { | ||
lowered final self::FooBaz #this = i; | ||
return #this; | ||
} | ||
static inline-class-member method FooBaz|_#new#tearOff(core::int i) → self::FooBaz | ||
return self::FooBaz|(i); | ||
static method main() → void { | ||
final self::FooBar a = self::FooBar|(0); | ||
#L1: | ||
{ | ||
final synthesized self::FooBar #0#0 = a; | ||
{ | ||
final hoisted core::int a; | ||
if(let final dynamic #t1 = a = #0#0 as{Unchecked} core::int in true) { | ||
{ | ||
core::print("FooBar ${a}"); | ||
} | ||
} | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
pkg/front_end/testcases/inline_class/issue52667.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,44 @@ | ||
library; | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
abstract class Foo extends core::Object { | ||
synthetic constructor •() → self::Foo | ||
: super core::Object::•() | ||
; | ||
} | ||
inline class FooBar /* declaredRepresentationType = core::int */ { | ||
constructor • = self::FooBar|; | ||
tearoff • = self::FooBar|_#new#tearOff; | ||
} | ||
inline class FooBaz /* declaredRepresentationType = core::int */ { | ||
constructor • = self::FooBaz|; | ||
tearoff • = self::FooBaz|_#new#tearOff; | ||
} | ||
static inline-class-member method FooBar|(core::int i) → self::FooBar { | ||
lowered final self::FooBar #this = i; | ||
return #this; | ||
} | ||
static inline-class-member method FooBar|_#new#tearOff(core::int i) → self::FooBar | ||
return self::FooBar|(i); | ||
static inline-class-member method FooBaz|(core::int i) → self::FooBaz { | ||
lowered final self::FooBaz #this = i; | ||
return #this; | ||
} | ||
static inline-class-member method FooBaz|_#new#tearOff(core::int i) → self::FooBaz | ||
return self::FooBaz|(i); | ||
static method main() → void { | ||
final self::FooBar a = self::FooBar|(0); | ||
#L1: | ||
{ | ||
final synthesized self::FooBar #0#0 = a; | ||
{ | ||
final hoisted core::int a; | ||
if(let final dynamic #t1 = a = #0#0 as{Unchecked} core::int in true) { | ||
{ | ||
core::print("FooBar ${a}"); | ||
} | ||
} | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
pkg/front_end/testcases/inline_class/issue52667.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,26 @@ | ||
library; | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
abstract class Foo extends core::Object { | ||
synthetic constructor •() → self::Foo | ||
; | ||
} | ||
inline class FooBar /* declaredRepresentationType = core::int */ { | ||
constructor • = self::FooBar|; | ||
tearoff • = self::FooBar|_#new#tearOff; | ||
} | ||
inline class FooBaz /* declaredRepresentationType = core::int */ { | ||
constructor • = self::FooBaz|; | ||
tearoff • = self::FooBaz|_#new#tearOff; | ||
} | ||
static inline-class-member method FooBar|(core::int i) → self::FooBar | ||
; | ||
static inline-class-member method FooBar|_#new#tearOff(core::int i) → self::FooBar | ||
return self::FooBar|(i); | ||
static inline-class-member method FooBaz|(core::int i) → self::FooBaz | ||
; | ||
static inline-class-member method FooBaz|_#new#tearOff(core::int i) → self::FooBaz | ||
return self::FooBaz|(i); | ||
static method main() → void | ||
; |
49 changes: 49 additions & 0 deletions
49
pkg/front_end/testcases/inline_class/issue52667.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,49 @@ | ||
library; | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
abstract class Foo extends core::Object { | ||
synthetic constructor •() → self::Foo | ||
: super core::Object::•() | ||
; | ||
} | ||
inline class FooBar /* declaredRepresentationType = core::int */ { | ||
constructor • = self::FooBar|; | ||
tearoff • = self::FooBar|_#new#tearOff; | ||
} | ||
inline class FooBaz /* declaredRepresentationType = core::int */ { | ||
constructor • = self::FooBaz|; | ||
tearoff • = self::FooBaz|_#new#tearOff; | ||
} | ||
static inline-class-member method FooBar|(core::int i) → self::FooBar { | ||
lowered final self::FooBar #this = i; | ||
return #this; | ||
} | ||
static inline-class-member method FooBar|_#new#tearOff(core::int i) → self::FooBar | ||
return self::FooBar|(i); | ||
static inline-class-member method FooBaz|(core::int i) → self::FooBaz { | ||
lowered final self::FooBaz #this = i; | ||
return #this; | ||
} | ||
static inline-class-member method FooBaz|_#new#tearOff(core::int i) → self::FooBaz | ||
return self::FooBaz|(i); | ||
static method main() → void { | ||
final self::FooBar a = self::FooBar|(0); | ||
#L1: | ||
{ | ||
final synthesized self::FooBar #0#0 = a; | ||
{ | ||
final hoisted core::int a; | ||
if(let final core::int #t1 = a = #0#0 as{Unchecked} core::int in true) { | ||
{ | ||
core::print("FooBar ${a}"); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
Extra constant evaluation status: | ||
Evaluated: FactoryConstructorInvocation @ org-dartlang-testcase:///issue52667.dart:20:13 -> IntConstant(0) | ||
Extra constant evaluation: evaluated: 17, effectively constant: 1 |
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