[cfe] Add test for covariant late final fields

Closes #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>
This commit is contained in:
Johnni Winther
2020-03-16 08:30:08 +00:00
committed by commit-bot@chromium.org
parent e470662897
commit d2950737b8
13 changed files with 268 additions and 0 deletions
@@ -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(); }
}
@@ -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
;
@@ -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;
}
@@ -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;
}
@@ -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;
}
@@ -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;
}
@@ -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(); }
}
@@ -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
;
@@ -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;
}
@@ -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;
}
@@ -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;
}
@@ -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;
}
@@ -1221,6 +1221,7 @@ late_lowering/instance_nullable_final_field_without_initializer: TextSerializati
late_lowering/issue40093: TextSerializationFailure
late_lowering/issue40373: TextSerializationFailure
late_lowering/issue40373b: TextSerializationFailure
late_lowering/issue40805: TextSerializationFailure
late_lowering/late_field_inference: TextSerializationFailure
late_lowering/late_field_with_initializer: TextSerializationFailure
late_lowering/late_field_without_initializer: TextSerializationFailure
@@ -1277,6 +1278,7 @@ nnbd/issue40093: TextSerializationFailure
nnbd/issue40134: TextSerializationFailure
nnbd/issue40512/issue40512: TextSerializationFailure
nnbd/issue40600: TextSerializationFailure
nnbd/issue40805: TextSerializationFailure
nnbd/issue_39286: TextSerializationFailure
nnbd/issue_39286_2: TextSerializationFailure
nnbd/late: TextSerializationFailure