forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[cfe] Add test for covariant late final fields
Closes flutter#40805 Change-Id: I896bce935803a951cfb8c9c0d0f70a6227de2413 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/139464 Reviewed-by: Jens Johansen <jensj@google.com> Commit-Queue: Johnni Winther <johnniwinther@google.com>
- Loading branch information
1 parent
e470662
commit d295073
Showing
13 changed files
with
268 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright (c) 2020, 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. | ||
|
||
main() { | ||
D().x = 3.14; | ||
} | ||
|
||
class C { | ||
covariant late final int x; | ||
} | ||
|
||
class D extends C { | ||
set x(num value) { super.x = value.toInt(); } | ||
} |
19 changes: 19 additions & 0 deletions
19
pkg/front_end/testcases/late_lowering/issue40805.dart.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,19 @@ | ||
library /*isNonNullableByDefault*/; | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
class C extends core::Object { | ||
covariant field core::int? _#C#x; | ||
synthetic constructor •() → self::C | ||
; | ||
get x() → core::int; | ||
set x(core::int #t1) → void; | ||
} | ||
class D extends self::C { | ||
synthetic constructor •() → self::D | ||
; | ||
set x(core::num value) → void | ||
; | ||
} | ||
static method main() → dynamic | ||
; |
29 changes: 29 additions & 0 deletions
29
pkg/front_end/testcases/late_lowering/issue40805.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,29 @@ | ||
library /*isNonNullableByDefault*/; | ||
import self as self; | ||
import "dart:core" as core; | ||
import "dart:_internal" as _in; | ||
|
||
class C extends core::Object { | ||
covariant field core::int? _#C#x = null; | ||
synthetic constructor •() → self::C | ||
: super core::Object::•() | ||
; | ||
get x() → core::int | ||
return let final core::int? #t1 = this.{self::C::_#C#x} in #t1.==(null) ?{core::int} throw new _in::LateInitializationErrorImpl::•("Field 'x' has not been initialized.") : #t1{core::int}; | ||
set x(core::int #t2) → void | ||
if(this.{self::C::_#C#x}.==(null)) | ||
this.{self::C::_#C#x} = #t2; | ||
else | ||
throw new _in::LateInitializationErrorImpl::•("Field 'x' has already been initialized."); | ||
} | ||
class D extends self::C { | ||
synthetic constructor •() → self::D | ||
: super self::C::•() | ||
; | ||
set x(core::num value) → void { | ||
super.{self::C::x} = value.{core::num::toInt}(); | ||
} | ||
} | ||
static method main() → dynamic { | ||
new self::D::•().{self::D::x} = 3.14; | ||
} |
29 changes: 29 additions & 0 deletions
29
pkg/front_end/testcases/late_lowering/issue40805.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,29 @@ | ||
library /*isNonNullableByDefault*/; | ||
import self as self; | ||
import "dart:core" as core; | ||
import "dart:_internal" as _in; | ||
|
||
class C extends core::Object { | ||
covariant field core::int? _#C#x = null; | ||
synthetic constructor •() → self::C | ||
: super core::Object::•() | ||
; | ||
get x() → core::int | ||
return let final core::int? #t1 = this.{self::C::_#C#x} in #t1.==(null) ?{core::int} throw new _in::LateInitializationErrorImpl::•("Field 'x' has not been initialized.") : #t1{core::int}; | ||
set x(core::int #t2) → void | ||
if(this.{self::C::_#C#x}.==(null)) | ||
this.{self::C::_#C#x} = #t2; | ||
else | ||
throw new _in::LateInitializationErrorImpl::•("Field 'x' has already been initialized."); | ||
} | ||
class D extends self::C { | ||
synthetic constructor •() → self::D | ||
: super self::C::•() | ||
; | ||
set x(core::num value) → void { | ||
super.{self::C::x} = value.{core::num::toInt}(); | ||
} | ||
} | ||
static method main() → dynamic { | ||
new self::D::•().{self::D::x} = 3.14; | ||
} |
29 changes: 29 additions & 0 deletions
29
pkg/front_end/testcases/late_lowering/issue40805.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,29 @@ | ||
library /*isNonNullableByDefault*/; | ||
import self as self; | ||
import "dart:core" as core; | ||
import "dart:_internal" as _in; | ||
|
||
class C extends core::Object { | ||
covariant field core::int? _#C#x = null; | ||
synthetic constructor •() → self::C | ||
: super core::Object::•() | ||
; | ||
get x() → core::int | ||
return let final core::int? #t1 = this.{self::C::_#C#x} in #t1.==(null) ?{core::int} throw new _in::LateInitializationErrorImpl::•("Field 'x' has not been initialized.") : #t1{core::int}; | ||
set x(core::int #t2) → void | ||
if(this.{self::C::_#C#x}.==(null)) | ||
this.{self::C::_#C#x} = #t2; | ||
else | ||
throw new _in::LateInitializationErrorImpl::•("Field 'x' has already been initialized."); | ||
} | ||
class D extends self::C { | ||
synthetic constructor •() → self::D | ||
: super self::C::•() | ||
; | ||
set x(core::num value) → void { | ||
super.{self::C::x} = value.{core::num::toInt}(); | ||
} | ||
} | ||
static method main() → dynamic { | ||
new self::D::•().{self::D::x} = 3.14; | ||
} |
29 changes: 29 additions & 0 deletions
29
pkg/front_end/testcases/late_lowering/issue40805.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,29 @@ | ||
library /*isNonNullableByDefault*/; | ||
import self as self; | ||
import "dart:core" as core; | ||
import "dart:_internal" as _in; | ||
|
||
class C extends core::Object { | ||
covariant field core::int? _#C#x = null; | ||
synthetic constructor •() → self::C | ||
: super core::Object::•() | ||
; | ||
get x() → core::int | ||
return let final core::int? #t1 = this.{self::C::_#C#x} in #t1.==(null) ?{core::int} throw new _in::LateInitializationErrorImpl::•("Field 'x' has not been initialized.") : #t1{core::int}; | ||
set x(core::int #t2) → void | ||
if(this.{self::C::_#C#x}.==(null)) | ||
this.{self::C::_#C#x} = #t2; | ||
else | ||
throw new _in::LateInitializationErrorImpl::•("Field 'x' has already been initialized."); | ||
} | ||
class D extends self::C { | ||
synthetic constructor •() → self::D | ||
: super self::C::•() | ||
; | ||
set x(core::num value) → void { | ||
super.{self::C::x} = value.{core::num::toInt}(); | ||
} | ||
} | ||
static method main() → dynamic { | ||
new self::D::•().{self::D::x} = 3.14; | ||
} |
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,15 @@ | ||
// Copyright (c) 2020, 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. | ||
|
||
main() { | ||
D().x = 3.14; | ||
} | ||
|
||
class C { | ||
covariant late final int x; | ||
} | ||
|
||
class D extends C { | ||
set x(num value) { super.x = value.toInt(); } | ||
} |
17 changes: 17 additions & 0 deletions
17
pkg/front_end/testcases/nnbd/issue40805.dart.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,17 @@ | ||
library /*isNonNullableByDefault*/; | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
class C extends core::Object { | ||
late covariant final [setter] field core::int x; | ||
synthetic constructor •() → self::C | ||
; | ||
} | ||
class D extends self::C { | ||
synthetic constructor •() → self::D | ||
; | ||
set x(covariant core::num value) → void | ||
; | ||
} | ||
static method main() → dynamic | ||
; |
21 changes: 21 additions & 0 deletions
21
pkg/front_end/testcases/nnbd/issue40805.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 /*isNonNullableByDefault*/; | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
class C extends core::Object { | ||
late covariant final [setter] field core::int x; | ||
synthetic constructor •() → self::C | ||
: super core::Object::•() | ||
; | ||
} | ||
class D extends self::C { | ||
synthetic constructor •() → self::D | ||
: super self::C::•() | ||
; | ||
set x(covariant core::num value) → void { | ||
super.{self::C::x} = value.{core::num::toInt}(); | ||
} | ||
} | ||
static method main() → dynamic { | ||
new self::D::•().{self::D::x} = 3.14; | ||
} |
21 changes: 21 additions & 0 deletions
21
pkg/front_end/testcases/nnbd/issue40805.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 /*isNonNullableByDefault*/; | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
class C extends core::Object { | ||
late covariant final [setter] field core::int x; | ||
synthetic constructor •() → self::C | ||
: super core::Object::•() | ||
; | ||
} | ||
class D extends self::C { | ||
synthetic constructor •() → self::D | ||
: super self::C::•() | ||
; | ||
set x(covariant core::num value) → void { | ||
super.{self::C::x} = value.{core::num::toInt}(); | ||
} | ||
} | ||
static method main() → dynamic { | ||
new self::D::•().{self::D::x} = 3.14; | ||
} |
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 /*isNonNullableByDefault*/; | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
class C extends core::Object { | ||
late covariant final [setter] field core::int x; | ||
synthetic constructor •() → self::C | ||
: super core::Object::•() | ||
; | ||
} | ||
class D extends self::C { | ||
synthetic constructor •() → self::D | ||
: super self::C::•() | ||
; | ||
set x(covariant core::num value) → void { | ||
super.{self::C::x} = value.{core::num::toInt}(); | ||
} | ||
} | ||
static method main() → dynamic { | ||
new self::D::•().{self::D::x} = 3.14; | ||
} |
21 changes: 21 additions & 0 deletions
21
pkg/front_end/testcases/nnbd/issue40805.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,21 @@ | ||
library /*isNonNullableByDefault*/; | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
class C extends core::Object { | ||
late covariant final [setter] field core::int x; | ||
synthetic constructor •() → self::C | ||
: super core::Object::•() | ||
; | ||
} | ||
class D extends self::C { | ||
synthetic constructor •() → self::D | ||
: super self::C::•() | ||
; | ||
set x(covariant core::num value) → void { | ||
super.{self::C::x} = value.{core::num::toInt}(); | ||
} | ||
} | ||
static method main() → dynamic { | ||
new self::D::•().{self::D::x} = 3.14; | ||
} |
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