mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 10:48:25 +00:00
Migrate language_2/type_promotion to NNBD.
Change-Id: Iff60de7b9fbe9371c71c098a9a36e43d2dc7f134 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151810 Auto-Submit: Bob Nystrom <rnystrom@google.com> Reviewed-by: Nicholas Shahan <nshahan@google.com> Commit-Queue: Bob Nystrom <rnystrom@google.com>
This commit is contained in:
parent
8fd04408f0
commit
a2cc089472
54
tests/language/type_promotion/assign_runtime_test.dart
Normal file
54
tests/language/type_promotion/assign_runtime_test.dart
Normal file
|
@ -0,0 +1,54 @@
|
|||
// TODO(multitest): This was automatically migrated from a multitest and may
|
||||
// contain strange or dead code.
|
||||
|
||||
// Copyright (c) 2013, 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.
|
||||
|
||||
// Test type promotion of assigned locals.
|
||||
|
||||
class A {
|
||||
var a = "a";
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
var b = "b";
|
||||
}
|
||||
|
||||
class C extends B {
|
||||
var c = "c";
|
||||
}
|
||||
|
||||
class D extends A {
|
||||
var d = "d";
|
||||
}
|
||||
|
||||
class E implements C, D {
|
||||
var a = "";
|
||||
var b = "";
|
||||
var c = "";
|
||||
var d = "";
|
||||
}
|
||||
|
||||
void main() {
|
||||
A a = new E();
|
||||
if (a is B) {
|
||||
print(a.a);
|
||||
|
||||
a = A();
|
||||
}
|
||||
if (a is B) {
|
||||
a = A();
|
||||
print(a.a);
|
||||
|
||||
}
|
||||
if (a is B) {
|
||||
print(a.a);
|
||||
|
||||
{
|
||||
a = A();
|
||||
}
|
||||
print(a.a);
|
||||
|
||||
}
|
||||
}
|
57
tests/language/type_promotion/assign_test.dart
Normal file
57
tests/language/type_promotion/assign_test.dart
Normal file
|
@ -0,0 +1,57 @@
|
|||
// Copyright (c) 2013, 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.
|
||||
|
||||
// Test type promotion of assigned locals.
|
||||
|
||||
class A {
|
||||
var a = "a";
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
var b = "b";
|
||||
}
|
||||
|
||||
class C extends B {
|
||||
var c = "c";
|
||||
}
|
||||
|
||||
class D extends A {
|
||||
var d = "d";
|
||||
}
|
||||
|
||||
class E implements C, D {
|
||||
var a = "";
|
||||
var b = "";
|
||||
var c = "";
|
||||
var d = "";
|
||||
}
|
||||
|
||||
void main() {
|
||||
A a = new E();
|
||||
if (a is B) {
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
a = A();
|
||||
}
|
||||
if (a is B) {
|
||||
a = A();
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'b' isn't defined for the class 'A'.
|
||||
}
|
||||
if (a is B) {
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
{
|
||||
a = A();
|
||||
}
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'b' isn't defined for the class 'A'.
|
||||
}
|
||||
}
|
203
tests/language/type_promotion/closure_runtime_1_test.dart
Normal file
203
tests/language/type_promotion/closure_runtime_1_test.dart
Normal file
|
@ -0,0 +1,203 @@
|
|||
// TODO(multitest): This was automatically migrated from a multitest and may
|
||||
// contain strange or dead code.
|
||||
|
||||
// Copyright (c) 2013, 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.
|
||||
|
||||
// Test type promotion of locals potentially mutated in closures.
|
||||
|
||||
import "package:meta/meta.dart" show virtual;
|
||||
|
||||
class A {
|
||||
var a = "a";
|
||||
A operator +(int i) => this;
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
var b = "b";
|
||||
}
|
||||
|
||||
class C extends B {
|
||||
var c = "c";
|
||||
}
|
||||
|
||||
class D extends A {
|
||||
var d = "d";
|
||||
}
|
||||
|
||||
class E extends D implements C {
|
||||
var a = "";
|
||||
var b = "";
|
||||
var c = "";
|
||||
var d = "";
|
||||
}
|
||||
|
||||
func(x) => true;
|
||||
|
||||
void main() {
|
||||
test1();
|
||||
test2();
|
||||
test3();
|
||||
test3a();
|
||||
test4();
|
||||
test5();
|
||||
test6();
|
||||
test6a();
|
||||
test7();
|
||||
test8();
|
||||
test9();
|
||||
test10();
|
||||
test11();
|
||||
test12();
|
||||
}
|
||||
|
||||
void test1() {
|
||||
A a = new E();
|
||||
if (a is B) {
|
||||
print(a.a);
|
||||
|
||||
}
|
||||
void foo() {
|
||||
a = new D();
|
||||
}
|
||||
}
|
||||
|
||||
void test2() {
|
||||
A a = new E();
|
||||
void foo() {
|
||||
a = new D();
|
||||
}
|
||||
|
||||
if (a is B) {
|
||||
print(a.a);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void test3() {
|
||||
A a = new E();
|
||||
void foo() {
|
||||
a = new D();
|
||||
}
|
||||
|
||||
if (a is B) {
|
||||
print(a.a);
|
||||
|
||||
void foo() {
|
||||
a = new D();
|
||||
}
|
||||
|
||||
print(a.a);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void test3a() {
|
||||
A a = new E();
|
||||
void foo() {
|
||||
a = new D();
|
||||
}
|
||||
|
||||
if ((((a)) is B)) {
|
||||
print(a.a);
|
||||
|
||||
void foo() {
|
||||
a = new D();
|
||||
}
|
||||
|
||||
print(a.a);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void test4() {
|
||||
A a = new E();
|
||||
if (a is B) {
|
||||
func(() => a.b);
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
}
|
||||
}
|
||||
|
||||
void test5() {
|
||||
A a = new E();
|
||||
if (a is B) {
|
||||
|
||||
print(a.a);
|
||||
}
|
||||
a = A();
|
||||
}
|
||||
|
||||
void test6() {
|
||||
A a = new E();
|
||||
if (a is B) {
|
||||
func(() => a);
|
||||
print(a.a);
|
||||
|
||||
}
|
||||
a = A();
|
||||
}
|
||||
|
||||
void test6a() {
|
||||
A a = new E();
|
||||
if (((a) is B)) {
|
||||
func(() => a);
|
||||
print(a.a);
|
||||
|
||||
}
|
||||
a = A();
|
||||
}
|
||||
|
||||
void test7() {
|
||||
A a = new E();
|
||||
if (a is B && func(() => a)) {
|
||||
print(a.a);
|
||||
|
||||
}
|
||||
a = A();
|
||||
}
|
||||
|
||||
void test8() {
|
||||
A a = new E();
|
||||
if (a is B
|
||||
|
||||
) {
|
||||
print(a.a);
|
||||
}
|
||||
a = A();
|
||||
}
|
||||
|
||||
void test9() {
|
||||
A a = new E();
|
||||
|
||||
a = A();
|
||||
}
|
||||
|
||||
void test10() {
|
||||
List<A> a = <E>[new E()];
|
||||
if (a is List<B>) {
|
||||
func(() => a[0]);
|
||||
|
||||
}
|
||||
a = [];
|
||||
}
|
||||
|
||||
void test11() {
|
||||
List<A> a = <E>[new E()];
|
||||
if (a is List<B>) {
|
||||
func(() => a[0] = E());
|
||||
|
||||
}
|
||||
a = [];
|
||||
}
|
||||
|
||||
void test12() {
|
||||
A a = new E();
|
||||
if (a is B) {
|
||||
func(() => a++);
|
||||
print(a.a);
|
||||
|
||||
}
|
||||
a = A();
|
||||
}
|
203
tests/language/type_promotion/closure_runtime_2_test.dart
Normal file
203
tests/language/type_promotion/closure_runtime_2_test.dart
Normal file
|
@ -0,0 +1,203 @@
|
|||
// TODO(multitest): This was automatically migrated from a multitest and may
|
||||
// contain strange or dead code.
|
||||
|
||||
// Copyright (c) 2013, 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.
|
||||
|
||||
// Test type promotion of locals potentially mutated in closures.
|
||||
|
||||
import "package:meta/meta.dart" show virtual;
|
||||
|
||||
class A {
|
||||
var a = "a";
|
||||
A operator +(int i) => this;
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
var b = "b";
|
||||
}
|
||||
|
||||
class C extends B {
|
||||
var c = "c";
|
||||
}
|
||||
|
||||
class D extends A {
|
||||
var d = "d";
|
||||
}
|
||||
|
||||
class E extends D implements C {
|
||||
var a = "";
|
||||
var b = "";
|
||||
var c = "";
|
||||
var d = "";
|
||||
}
|
||||
|
||||
func(x) => true;
|
||||
|
||||
void main() {
|
||||
test1();
|
||||
test2();
|
||||
test3();
|
||||
test3a();
|
||||
test4();
|
||||
test5();
|
||||
test6();
|
||||
test6a();
|
||||
test7();
|
||||
test8();
|
||||
test9();
|
||||
test10();
|
||||
test11();
|
||||
test12();
|
||||
}
|
||||
|
||||
void test1() {
|
||||
A a = new E();
|
||||
if (a is B) {
|
||||
print(a.a);
|
||||
|
||||
}
|
||||
void foo() {
|
||||
a = new D();
|
||||
}
|
||||
}
|
||||
|
||||
void test2() {
|
||||
A a = new E();
|
||||
void foo() {
|
||||
a = new D();
|
||||
}
|
||||
|
||||
if (a is B) {
|
||||
print(a.a);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void test3() {
|
||||
A a = new E();
|
||||
void foo() {
|
||||
a = new D();
|
||||
}
|
||||
|
||||
if (a is B) {
|
||||
print(a.a);
|
||||
|
||||
void foo() {
|
||||
a = new D();
|
||||
}
|
||||
|
||||
print(a.a);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void test3a() {
|
||||
A a = new E();
|
||||
void foo() {
|
||||
a = new D();
|
||||
}
|
||||
|
||||
if ((((a)) is B)) {
|
||||
print(a.a);
|
||||
|
||||
void foo() {
|
||||
a = new D();
|
||||
}
|
||||
|
||||
print(a.a);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void test4() {
|
||||
A a = new E();
|
||||
if (a is B) {
|
||||
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
}
|
||||
}
|
||||
|
||||
void test5() {
|
||||
A a = new E();
|
||||
if (a is B) {
|
||||
|
||||
print(a.a);
|
||||
}
|
||||
a = A();
|
||||
}
|
||||
|
||||
void test6() {
|
||||
A a = new E();
|
||||
if (a is B) {
|
||||
func(() => a);
|
||||
print(a.a);
|
||||
|
||||
}
|
||||
a = A();
|
||||
}
|
||||
|
||||
void test6a() {
|
||||
A a = new E();
|
||||
if (((a) is B)) {
|
||||
func(() => a);
|
||||
print(a.a);
|
||||
|
||||
}
|
||||
a = A();
|
||||
}
|
||||
|
||||
void test7() {
|
||||
A a = new E();
|
||||
if (a is B && func(() => a)) {
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
}
|
||||
a = A();
|
||||
}
|
||||
|
||||
void test8() {
|
||||
A a = new E();
|
||||
if (a is B
|
||||
|
||||
) {
|
||||
print(a.a);
|
||||
}
|
||||
a = A();
|
||||
}
|
||||
|
||||
void test9() {
|
||||
A a = new E();
|
||||
|
||||
a = A();
|
||||
}
|
||||
|
||||
void test10() {
|
||||
List<A> a = <E>[new E()];
|
||||
if (a is List<B>) {
|
||||
func(() => a[0]);
|
||||
|
||||
}
|
||||
a = [];
|
||||
}
|
||||
|
||||
void test11() {
|
||||
List<A> a = <E>[new E()];
|
||||
if (a is List<B>) {
|
||||
func(() => a[0] = E());
|
||||
|
||||
}
|
||||
a = [];
|
||||
}
|
||||
|
||||
void test12() {
|
||||
A a = new E();
|
||||
if (a is B) {
|
||||
func(() => a++);
|
||||
print(a.a);
|
||||
|
||||
}
|
||||
a = A();
|
||||
}
|
203
tests/language/type_promotion/closure_runtime_test.dart
Normal file
203
tests/language/type_promotion/closure_runtime_test.dart
Normal file
|
@ -0,0 +1,203 @@
|
|||
// TODO(multitest): This was automatically migrated from a multitest and may
|
||||
// contain strange or dead code.
|
||||
|
||||
// Copyright (c) 2013, 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.
|
||||
|
||||
// Test type promotion of locals potentially mutated in closures.
|
||||
|
||||
import "package:meta/meta.dart" show virtual;
|
||||
|
||||
class A {
|
||||
var a = "a";
|
||||
A operator +(int i) => this;
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
var b = "b";
|
||||
}
|
||||
|
||||
class C extends B {
|
||||
var c = "c";
|
||||
}
|
||||
|
||||
class D extends A {
|
||||
var d = "d";
|
||||
}
|
||||
|
||||
class E extends D implements C {
|
||||
var a = "";
|
||||
var b = "";
|
||||
var c = "";
|
||||
var d = "";
|
||||
}
|
||||
|
||||
func(x) => true;
|
||||
|
||||
void main() {
|
||||
test1();
|
||||
test2();
|
||||
test3();
|
||||
test3a();
|
||||
test4();
|
||||
test5();
|
||||
test6();
|
||||
test6a();
|
||||
test7();
|
||||
test8();
|
||||
test9();
|
||||
test10();
|
||||
test11();
|
||||
test12();
|
||||
}
|
||||
|
||||
void test1() {
|
||||
A a = new E();
|
||||
if (a is B) {
|
||||
print(a.a);
|
||||
|
||||
}
|
||||
void foo() {
|
||||
a = new D();
|
||||
}
|
||||
}
|
||||
|
||||
void test2() {
|
||||
A a = new E();
|
||||
void foo() {
|
||||
a = new D();
|
||||
}
|
||||
|
||||
if (a is B) {
|
||||
print(a.a);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void test3() {
|
||||
A a = new E();
|
||||
void foo() {
|
||||
a = new D();
|
||||
}
|
||||
|
||||
if (a is B) {
|
||||
print(a.a);
|
||||
|
||||
void foo() {
|
||||
a = new D();
|
||||
}
|
||||
|
||||
print(a.a);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void test3a() {
|
||||
A a = new E();
|
||||
void foo() {
|
||||
a = new D();
|
||||
}
|
||||
|
||||
if ((((a)) is B)) {
|
||||
print(a.a);
|
||||
|
||||
void foo() {
|
||||
a = new D();
|
||||
}
|
||||
|
||||
print(a.a);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void test4() {
|
||||
A a = new E();
|
||||
if (a is B) {
|
||||
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
}
|
||||
}
|
||||
|
||||
void test5() {
|
||||
A a = new E();
|
||||
if (a is B) {
|
||||
|
||||
print(a.a);
|
||||
}
|
||||
a = A();
|
||||
}
|
||||
|
||||
void test6() {
|
||||
A a = new E();
|
||||
if (a is B) {
|
||||
func(() => a);
|
||||
print(a.a);
|
||||
|
||||
}
|
||||
a = A();
|
||||
}
|
||||
|
||||
void test6a() {
|
||||
A a = new E();
|
||||
if (((a) is B)) {
|
||||
func(() => a);
|
||||
print(a.a);
|
||||
|
||||
}
|
||||
a = A();
|
||||
}
|
||||
|
||||
void test7() {
|
||||
A a = new E();
|
||||
if (a is B && func(() => a)) {
|
||||
print(a.a);
|
||||
|
||||
}
|
||||
a = A();
|
||||
}
|
||||
|
||||
void test8() {
|
||||
A a = new E();
|
||||
if (a is B
|
||||
|
||||
) {
|
||||
print(a.a);
|
||||
}
|
||||
a = A();
|
||||
}
|
||||
|
||||
void test9() {
|
||||
A a = new E();
|
||||
|
||||
a = A();
|
||||
}
|
||||
|
||||
void test10() {
|
||||
List<A> a = <E>[new E()];
|
||||
if (a is List<B>) {
|
||||
func(() => a[0]);
|
||||
|
||||
}
|
||||
a = [];
|
||||
}
|
||||
|
||||
void test11() {
|
||||
List<A> a = <E>[new E()];
|
||||
if (a is List<B>) {
|
||||
func(() => a[0] = E());
|
||||
|
||||
}
|
||||
a = [];
|
||||
}
|
||||
|
||||
void test12() {
|
||||
A a = new E();
|
||||
if (a is B) {
|
||||
func(() => a++);
|
||||
print(a.a);
|
||||
|
||||
}
|
||||
a = A();
|
||||
}
|
227
tests/language/type_promotion/closure_test.dart
Normal file
227
tests/language/type_promotion/closure_test.dart
Normal file
|
@ -0,0 +1,227 @@
|
|||
// Copyright (c) 2013, 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.
|
||||
|
||||
// Test type promotion of locals potentially mutated in closures.
|
||||
|
||||
import "package:meta/meta.dart" show virtual;
|
||||
|
||||
class A {
|
||||
var a = "a";
|
||||
A operator +(int i) => this;
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
var b = "b";
|
||||
}
|
||||
|
||||
class C extends B {
|
||||
var c = "c";
|
||||
}
|
||||
|
||||
class D extends A {
|
||||
var d = "d";
|
||||
}
|
||||
|
||||
class E extends D implements C {
|
||||
var a = "";
|
||||
var b = "";
|
||||
var c = "";
|
||||
var d = "";
|
||||
}
|
||||
|
||||
func(x) => true;
|
||||
|
||||
void main() {
|
||||
test1();
|
||||
test2();
|
||||
test3();
|
||||
test3a();
|
||||
test4();
|
||||
test5();
|
||||
test6();
|
||||
test6a();
|
||||
test7();
|
||||
test8();
|
||||
test9();
|
||||
test10();
|
||||
test11();
|
||||
test12();
|
||||
}
|
||||
|
||||
void test1() {
|
||||
A a = new E();
|
||||
if (a is B) {
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
}
|
||||
void foo() {
|
||||
a = new D();
|
||||
}
|
||||
}
|
||||
|
||||
void test2() {
|
||||
A a = new E();
|
||||
void foo() {
|
||||
a = new D();
|
||||
}
|
||||
|
||||
if (a is B) {
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'b' isn't defined for the class 'A'.
|
||||
}
|
||||
}
|
||||
|
||||
void test3() {
|
||||
A a = new E();
|
||||
void foo() {
|
||||
a = new D();
|
||||
}
|
||||
|
||||
if (a is B) {
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'b' isn't defined for the class 'A'.
|
||||
void foo() {
|
||||
a = new D();
|
||||
}
|
||||
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'b' isn't defined for the class 'A'.
|
||||
}
|
||||
}
|
||||
|
||||
void test3a() {
|
||||
A a = new E();
|
||||
void foo() {
|
||||
a = new D();
|
||||
}
|
||||
|
||||
if ((((a)) is B)) {
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'b' isn't defined for the class 'A'.
|
||||
void foo() {
|
||||
a = new D();
|
||||
}
|
||||
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'b' isn't defined for the class 'A'.
|
||||
}
|
||||
}
|
||||
|
||||
void test4() {
|
||||
A a = new E();
|
||||
if (a is B) {
|
||||
func(() => a.b);
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
}
|
||||
}
|
||||
|
||||
void test5() {
|
||||
A a = new E();
|
||||
if (a is B) {
|
||||
func(() => a.b);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'b' isn't defined for the class 'A'.
|
||||
print(a.a);
|
||||
}
|
||||
a = A();
|
||||
}
|
||||
|
||||
void test6() {
|
||||
A a = new E();
|
||||
if (a is B) {
|
||||
func(() => a);
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
}
|
||||
a = A();
|
||||
}
|
||||
|
||||
void test6a() {
|
||||
A a = new E();
|
||||
if (((a) is B)) {
|
||||
func(() => a);
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
}
|
||||
a = A();
|
||||
}
|
||||
|
||||
void test7() {
|
||||
A a = new E();
|
||||
if (a is B && func(() => a)) {
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
}
|
||||
a = A();
|
||||
}
|
||||
|
||||
void test8() {
|
||||
A a = new E();
|
||||
if (a is B
|
||||
&& func(() => a.b)
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'b' isn't defined for the class 'A'.
|
||||
) {
|
||||
print(a.a);
|
||||
}
|
||||
a = A();
|
||||
}
|
||||
|
||||
void test9() {
|
||||
A a = new E();
|
||||
var b = a is B ? func(() => a.b) : false;
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'b' isn't defined for the class 'A'.
|
||||
a = A();
|
||||
}
|
||||
|
||||
void test10() {
|
||||
List<A> a = <E>[new E()];
|
||||
if (a is List<B>) {
|
||||
func(() => a[0]);
|
||||
print(a[0].b);
|
||||
}
|
||||
a = [];
|
||||
}
|
||||
|
||||
void test11() {
|
||||
List<A> a = <E>[new E()];
|
||||
if (a is List<B>) {
|
||||
func(() => a[0] = E());
|
||||
print(a[0].b);
|
||||
}
|
||||
a = [];
|
||||
}
|
||||
|
||||
void test12() {
|
||||
A a = new E();
|
||||
if (a is B) {
|
||||
func(() => a++);
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'b' isn't defined for the class 'A'.
|
||||
}
|
||||
a = A();
|
||||
}
|
127
tests/language/type_promotion/functions_runtime_test.dart
Normal file
127
tests/language/type_promotion/functions_runtime_test.dart
Normal file
|
@ -0,0 +1,127 @@
|
|||
// TODO(multitest): This was automatically migrated from a multitest and may
|
||||
// contain strange or dead code.
|
||||
|
||||
// Copyright (c) 2013, 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.
|
||||
|
||||
// Test type promotion of functions.
|
||||
|
||||
class A {}
|
||||
|
||||
class B extends A {}
|
||||
|
||||
class C {}
|
||||
|
||||
// Subtype relations:
|
||||
//
|
||||
// FuncDynToA == A Function(dynamic) <:
|
||||
// FuncDynToDyn == dynamic Function(dynamic) <:> // "void == dynamic"
|
||||
// FuncDynToVoid == void Function(dynamic) <:
|
||||
// FuncAtoDyn == dynamic Function(A).
|
||||
//
|
||||
// Declarations ordered by "super before sub", as is common for classes:
|
||||
|
||||
typedef FuncAtoDyn(A a);
|
||||
typedef void FuncDynToVoid(x);
|
||||
typedef FuncDynToDyn(x);
|
||||
typedef A FuncDynToA(x);
|
||||
|
||||
dynamic func(x) => x;
|
||||
|
||||
late A a;
|
||||
late B b;
|
||||
late C c;
|
||||
|
||||
main() {
|
||||
testFuncAtoDyn();
|
||||
testFuncDynToDyn();
|
||||
testFuncDynToVoid();
|
||||
testFuncDynToA();
|
||||
}
|
||||
|
||||
testFuncAtoDyn() {
|
||||
FuncAtoDyn funcAtoDyn = func;
|
||||
a = funcAtoDyn(new A());
|
||||
b = funcAtoDyn(new B());
|
||||
|
||||
|
||||
if (funcAtoDyn is FuncDynToDyn) {
|
||||
// Promotion: FuncDynToDyn <: FuncAtoDyn.
|
||||
a = funcAtoDyn(new A());
|
||||
b = funcAtoDyn(new B());
|
||||
c = funcAtoDyn(new C());
|
||||
}
|
||||
}
|
||||
|
||||
testFuncDynToDyn() {
|
||||
FuncDynToDyn funcDynToDyn = func;
|
||||
a = funcDynToDyn(new A());
|
||||
b = funcDynToDyn(new B());
|
||||
c = funcDynToDyn(new C());
|
||||
|
||||
if (funcDynToDyn is FuncAtoDyn) {
|
||||
// No promotion: FuncAtoDyn <\: FuncDynToDyn.
|
||||
a = funcDynToDyn(new A());
|
||||
b = funcDynToDyn(new B());
|
||||
c = funcDynToDyn(new C());
|
||||
}
|
||||
|
||||
if (funcDynToDyn is FuncDynToVoid) {
|
||||
// Promotion: FuncDynToVoid <: FuncDynToDyn.
|
||||
funcDynToDyn(new A());
|
||||
funcDynToDyn(new B());
|
||||
funcDynToDyn(new C());
|
||||
// Returned value has type `void`, usage is restricted.
|
||||
|
||||
}
|
||||
|
||||
if (funcDynToDyn is FuncDynToA) {
|
||||
// Promotion: FuncDynToA <: FuncDynToDyn.
|
||||
a = funcDynToDyn(new A());
|
||||
b = funcDynToDyn(new B()) as B;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
testFuncDynToVoid() {
|
||||
FuncDynToVoid funcDynToVoid = func;
|
||||
|
||||
|
||||
|
||||
|
||||
if (funcDynToVoid is FuncDynToDyn) {
|
||||
// Promotion: FuncDynToDyn <:> FuncDynToVoid.
|
||||
a = funcDynToVoid(new A());
|
||||
b = funcDynToVoid(new B());
|
||||
c = funcDynToVoid(new C());
|
||||
}
|
||||
|
||||
if (funcDynToVoid is FuncDynToA) {
|
||||
// Promotion: FuncDynToA <: FuncDynToVoid.
|
||||
a = funcDynToVoid(new A());
|
||||
b = funcDynToVoid(new B()) as B;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
testFuncDynToA() {
|
||||
FuncDynToA funcDynToA = (x) => x as A;
|
||||
a = funcDynToA(new A());
|
||||
b = funcDynToA(new B()) as B;
|
||||
|
||||
|
||||
if (funcDynToA is FuncDynToDyn) {
|
||||
// No promotion: FuncDynToDyn <\: FuncDynToA.
|
||||
a = funcDynToA(new A());
|
||||
b = funcDynToA(new B()) as B;
|
||||
|
||||
}
|
||||
|
||||
if (funcDynToA is FuncDynToVoid) {
|
||||
// No promotion: FuncDynToVoid <\: FuncDynToA.
|
||||
a = funcDynToA(new A());
|
||||
b = funcDynToA(new B()) as B;
|
||||
|
||||
}
|
||||
}
|
164
tests/language/type_promotion/functions_test.dart
Normal file
164
tests/language/type_promotion/functions_test.dart
Normal file
|
@ -0,0 +1,164 @@
|
|||
// Copyright (c) 2013, 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.
|
||||
|
||||
// Test type promotion of functions.
|
||||
|
||||
class A {}
|
||||
|
||||
class B extends A {}
|
||||
|
||||
class C {}
|
||||
|
||||
// Subtype relations:
|
||||
//
|
||||
// FuncDynToA == A Function(dynamic) <:
|
||||
// FuncDynToDyn == dynamic Function(dynamic) <:> // "void == dynamic"
|
||||
// FuncDynToVoid == void Function(dynamic) <:
|
||||
// FuncAtoDyn == dynamic Function(A).
|
||||
//
|
||||
// Declarations ordered by "super before sub", as is common for classes:
|
||||
|
||||
typedef FuncAtoDyn(A a);
|
||||
typedef void FuncDynToVoid(x);
|
||||
typedef FuncDynToDyn(x);
|
||||
typedef A FuncDynToA(x);
|
||||
|
||||
dynamic func(x) => x;
|
||||
|
||||
late A a;
|
||||
late B b;
|
||||
late C c;
|
||||
|
||||
main() {
|
||||
testFuncAtoDyn();
|
||||
testFuncDynToDyn();
|
||||
testFuncDynToVoid();
|
||||
testFuncDynToA();
|
||||
}
|
||||
|
||||
testFuncAtoDyn() {
|
||||
FuncAtoDyn funcAtoDyn = func;
|
||||
a = funcAtoDyn(new A());
|
||||
b = funcAtoDyn(new B());
|
||||
c = funcAtoDyn(new C());
|
||||
// ^^^^^^^
|
||||
// [analyzer] STATIC_WARNING.ARGUMENT_TYPE_NOT_ASSIGNABLE
|
||||
// ^
|
||||
// [cfe] The argument type 'C' can't be assigned to the parameter type 'A'.
|
||||
|
||||
if (funcAtoDyn is FuncDynToDyn) {
|
||||
// Promotion: FuncDynToDyn <: FuncAtoDyn.
|
||||
a = funcAtoDyn(new A());
|
||||
b = funcAtoDyn(new B());
|
||||
c = funcAtoDyn(new C());
|
||||
}
|
||||
}
|
||||
|
||||
testFuncDynToDyn() {
|
||||
FuncDynToDyn funcDynToDyn = func;
|
||||
a = funcDynToDyn(new A());
|
||||
b = funcDynToDyn(new B());
|
||||
c = funcDynToDyn(new C());
|
||||
|
||||
if (funcDynToDyn is FuncAtoDyn) {
|
||||
// No promotion: FuncAtoDyn <\: FuncDynToDyn.
|
||||
a = funcDynToDyn(new A());
|
||||
b = funcDynToDyn(new B());
|
||||
c = funcDynToDyn(new C());
|
||||
}
|
||||
|
||||
if (funcDynToDyn is FuncDynToVoid) {
|
||||
// Promotion: FuncDynToVoid <: FuncDynToDyn.
|
||||
funcDynToDyn(new A());
|
||||
funcDynToDyn(new B());
|
||||
funcDynToDyn(new C());
|
||||
// Returned value has type `void`, usage is restricted.
|
||||
Object o = funcDynToDyn(null);
|
||||
// ^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] STATIC_WARNING.USE_OF_VOID_RESULT
|
||||
// ^
|
||||
// [cfe] This expression has type 'void' and can't be used.
|
||||
}
|
||||
|
||||
if (funcDynToDyn is FuncDynToA) {
|
||||
// Promotion: FuncDynToA <: FuncDynToDyn.
|
||||
a = funcDynToDyn(new A());
|
||||
b = funcDynToDyn(new B()) as B;
|
||||
c = funcDynToDyn(new C());
|
||||
// ^^^^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
|
||||
// ^
|
||||
// [cfe] A value of type 'A' can't be assigned to a variable of type 'C'.
|
||||
}
|
||||
}
|
||||
|
||||
testFuncDynToVoid() {
|
||||
FuncDynToVoid funcDynToVoid = func;
|
||||
a = funcDynToVoid(new A());
|
||||
// ^^^^^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] STATIC_WARNING.USE_OF_VOID_RESULT
|
||||
// ^
|
||||
// [cfe] This expression has type 'void' and can't be used.
|
||||
b = funcDynToVoid(new B());
|
||||
// ^^^^^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] STATIC_WARNING.USE_OF_VOID_RESULT
|
||||
// ^
|
||||
// [cfe] This expression has type 'void' and can't be used.
|
||||
c = funcDynToVoid(new C());
|
||||
// ^^^^^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] STATIC_WARNING.USE_OF_VOID_RESULT
|
||||
// ^
|
||||
// [cfe] This expression has type 'void' and can't be used.
|
||||
|
||||
if (funcDynToVoid is FuncDynToDyn) {
|
||||
// Promotion: FuncDynToDyn <:> FuncDynToVoid.
|
||||
a = funcDynToVoid(new A());
|
||||
b = funcDynToVoid(new B());
|
||||
c = funcDynToVoid(new C());
|
||||
}
|
||||
|
||||
if (funcDynToVoid is FuncDynToA) {
|
||||
// Promotion: FuncDynToA <: FuncDynToVoid.
|
||||
a = funcDynToVoid(new A());
|
||||
b = funcDynToVoid(new B()) as B;
|
||||
c = funcDynToVoid(new C());
|
||||
// ^^^^^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
|
||||
// ^
|
||||
// [cfe] A value of type 'A' can't be assigned to a variable of type 'C'.
|
||||
}
|
||||
}
|
||||
|
||||
testFuncDynToA() {
|
||||
FuncDynToA funcDynToA = (x) => x as A;
|
||||
a = funcDynToA(new A());
|
||||
b = funcDynToA(new B()) as B;
|
||||
c = funcDynToA(new C());
|
||||
// ^^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
|
||||
// ^
|
||||
// [cfe] A value of type 'A' can't be assigned to a variable of type 'C'.
|
||||
|
||||
if (funcDynToA is FuncDynToDyn) {
|
||||
// No promotion: FuncDynToDyn <\: FuncDynToA.
|
||||
a = funcDynToA(new A());
|
||||
b = funcDynToA(new B()) as B;
|
||||
c = funcDynToA(new C());
|
||||
// ^^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
|
||||
// ^
|
||||
// [cfe] A value of type 'A' can't be assigned to a variable of type 'C'.
|
||||
}
|
||||
|
||||
if (funcDynToA is FuncDynToVoid) {
|
||||
// No promotion: FuncDynToVoid <\: FuncDynToA.
|
||||
a = funcDynToA(new A());
|
||||
b = funcDynToA(new B()) as B;
|
||||
c = funcDynToA(new C());
|
||||
// ^^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
|
||||
// ^
|
||||
// [cfe] A value of type 'A' can't be assigned to a variable of type 'C'.
|
||||
}
|
||||
}
|
163
tests/language/type_promotion/local_runtime_test.dart
Normal file
163
tests/language/type_promotion/local_runtime_test.dart
Normal file
|
@ -0,0 +1,163 @@
|
|||
// TODO(multitest): This was automatically migrated from a multitest and may
|
||||
// contain strange or dead code.
|
||||
|
||||
// Copyright (c) 2013, 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.
|
||||
|
||||
// Test type promotion of locals.
|
||||
|
||||
class A {
|
||||
var a = "a";
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
var b = "b";
|
||||
}
|
||||
|
||||
class C extends B {
|
||||
var c = "c";
|
||||
}
|
||||
|
||||
class D extends A {
|
||||
var d = "d";
|
||||
}
|
||||
|
||||
class E implements C, D {
|
||||
var a = "";
|
||||
var b = "";
|
||||
var c = "";
|
||||
var d = "";
|
||||
}
|
||||
|
||||
void main() {
|
||||
A a = new E();
|
||||
print(a.a);
|
||||
|
||||
|
||||
|
||||
|
||||
if (a is B) {
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
|
||||
|
||||
|
||||
if (a is C) {
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
print(a.c);
|
||||
|
||||
}
|
||||
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
|
||||
|
||||
}
|
||||
if (a is C) {
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
print(a.c);
|
||||
|
||||
|
||||
if (a is B) {
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
print(a.c);
|
||||
|
||||
}
|
||||
if (a is D) {
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
print(a.c);
|
||||
|
||||
}
|
||||
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
print(a.c);
|
||||
|
||||
}
|
||||
|
||||
print(a.a);
|
||||
|
||||
|
||||
|
||||
|
||||
if (a is D) {
|
||||
print(a.a);
|
||||
|
||||
|
||||
print(a.d);
|
||||
}
|
||||
|
||||
print(a.a);
|
||||
|
||||
|
||||
|
||||
|
||||
var o1 = a is B
|
||||
? '${a.a}'
|
||||
'${a.b}'
|
||||
|
||||
|
||||
: '${a.a}'
|
||||
|
||||
|
||||
|
||||
;
|
||||
|
||||
var o2 = a is C
|
||||
? '${a.a}'
|
||||
'${a.b}'
|
||||
'${a.c}'
|
||||
|
||||
: '${a.a}'
|
||||
|
||||
|
||||
|
||||
;
|
||||
|
||||
var o3 = a is D
|
||||
? '${a.a}'
|
||||
|
||||
|
||||
'${a.d}'
|
||||
: '${a.a}'
|
||||
|
||||
|
||||
|
||||
;
|
||||
|
||||
if (a is B && a is B) {
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
|
||||
|
||||
}
|
||||
if (a is B && a is C) {
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
print(a.c);
|
||||
|
||||
}
|
||||
if (a is C && a is B) {
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
print(a.c);
|
||||
|
||||
}
|
||||
if (a is C && a is D) {
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
print(a.c);
|
||||
|
||||
}
|
||||
if (a is D && a is C) {
|
||||
print(a.a);
|
||||
|
||||
|
||||
print(a.d);
|
||||
}
|
||||
}
|
283
tests/language/type_promotion/local_test.dart
Normal file
283
tests/language/type_promotion/local_test.dart
Normal file
|
@ -0,0 +1,283 @@
|
|||
// Copyright (c) 2013, 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.
|
||||
|
||||
// Test type promotion of locals.
|
||||
|
||||
class A {
|
||||
var a = "a";
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
var b = "b";
|
||||
}
|
||||
|
||||
class C extends B {
|
||||
var c = "c";
|
||||
}
|
||||
|
||||
class D extends A {
|
||||
var d = "d";
|
||||
}
|
||||
|
||||
class E implements C, D {
|
||||
var a = "";
|
||||
var b = "";
|
||||
var c = "";
|
||||
var d = "";
|
||||
}
|
||||
|
||||
void main() {
|
||||
A a = new E();
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'b' isn't defined for the class 'A'.
|
||||
print(a.c);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'c' isn't defined for the class 'A'.
|
||||
print(a.d);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'd' isn't defined for the class 'A'.
|
||||
|
||||
if (a is B) {
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
print(a.c);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'c' isn't defined for the class 'B'.
|
||||
print(a.d);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'd' isn't defined for the class 'B'.
|
||||
|
||||
if (a is C) {
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
print(a.c);
|
||||
print(a.d);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'd' isn't defined for the class 'C'.
|
||||
}
|
||||
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
print(a.c);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'c' isn't defined for the class 'B'.
|
||||
print(a.d);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'd' isn't defined for the class 'B'.
|
||||
}
|
||||
if (a is C) {
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
print(a.c);
|
||||
print(a.d);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'd' isn't defined for the class 'C'.
|
||||
|
||||
if (a is B) {
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
print(a.c);
|
||||
print(a.d);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'd' isn't defined for the class 'C'.
|
||||
}
|
||||
if (a is D) {
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
print(a.c);
|
||||
print(a.d);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'd' isn't defined for the class 'C'.
|
||||
}
|
||||
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
print(a.c);
|
||||
print(a.d);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'd' isn't defined for the class 'C'.
|
||||
}
|
||||
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'b' isn't defined for the class 'A'.
|
||||
print(a.c);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'c' isn't defined for the class 'A'.
|
||||
print(a.d);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'd' isn't defined for the class 'A'.
|
||||
|
||||
if (a is D) {
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'b' isn't defined for the class 'D'.
|
||||
print(a.c);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'c' isn't defined for the class 'D'.
|
||||
print(a.d);
|
||||
}
|
||||
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'b' isn't defined for the class 'A'.
|
||||
print(a.c);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'c' isn't defined for the class 'A'.
|
||||
print(a.d);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'd' isn't defined for the class 'A'.
|
||||
|
||||
var o1 = a is B
|
||||
? '${a.a}'
|
||||
'${a.b}'
|
||||
'${a.c}'
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'c' isn't defined for the class 'B'.
|
||||
'${a.d}'
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'd' isn't defined for the class 'B'.
|
||||
: '${a.a}'
|
||||
'${a.b}'
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'b' isn't defined for the class 'A'.
|
||||
'${a.c}'
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'c' isn't defined for the class 'A'.
|
||||
'${a.d}'
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'd' isn't defined for the class 'A'.
|
||||
;
|
||||
|
||||
var o2 = a is C
|
||||
? '${a.a}'
|
||||
'${a.b}'
|
||||
'${a.c}'
|
||||
'${a.d}'
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'd' isn't defined for the class 'C'.
|
||||
: '${a.a}'
|
||||
'${a.b}'
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'b' isn't defined for the class 'A'.
|
||||
'${a.c}'
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'c' isn't defined for the class 'A'.
|
||||
'${a.d}'
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'd' isn't defined for the class 'A'.
|
||||
;
|
||||
|
||||
var o3 = a is D
|
||||
? '${a.a}'
|
||||
'${a.b}'
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'b' isn't defined for the class 'D'.
|
||||
'${a.c}'
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'c' isn't defined for the class 'D'.
|
||||
'${a.d}'
|
||||
: '${a.a}'
|
||||
'${a.b}'
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'b' isn't defined for the class 'A'.
|
||||
'${a.c}'
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'c' isn't defined for the class 'A'.
|
||||
'${a.d}'
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'd' isn't defined for the class 'A'.
|
||||
;
|
||||
|
||||
if (a is B && a is B) {
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
print(a.c);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'c' isn't defined for the class 'B'.
|
||||
print(a.d);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'd' isn't defined for the class 'B'.
|
||||
}
|
||||
if (a is B && a is C) {
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
print(a.c);
|
||||
print(a.d);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'd' isn't defined for the class 'C'.
|
||||
}
|
||||
if (a is C && a is B) {
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
print(a.c);
|
||||
print(a.d);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'd' isn't defined for the class 'C'.
|
||||
}
|
||||
if (a is C && a is D) {
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
print(a.c);
|
||||
print(a.d);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'd' isn't defined for the class 'C'.
|
||||
}
|
||||
if (a is D && a is C) {
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'b' isn't defined for the class 'D'.
|
||||
print(a.c);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'c' isn't defined for the class 'D'.
|
||||
print(a.d);
|
||||
}
|
||||
}
|
52
tests/language/type_promotion/logical_and_runtime_test.dart
Normal file
52
tests/language/type_promotion/logical_and_runtime_test.dart
Normal file
|
@ -0,0 +1,52 @@
|
|||
// TODO(multitest): This was automatically migrated from a multitest and may
|
||||
// contain strange or dead code.
|
||||
|
||||
// Copyright (c) 2013, 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.
|
||||
|
||||
// Test type promotion of locals potentially mutated.
|
||||
|
||||
class A {
|
||||
var a = true;
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
var b = true;
|
||||
}
|
||||
|
||||
class C extends B {
|
||||
var c = true;
|
||||
}
|
||||
|
||||
class D extends A {
|
||||
var d = true;
|
||||
}
|
||||
|
||||
class E implements C, D {
|
||||
var a = true;
|
||||
var b = true;
|
||||
var c = true;
|
||||
var d = true;
|
||||
}
|
||||
|
||||
void main() {
|
||||
A a = new E();
|
||||
var b;
|
||||
if (a is D && ((a = new D()) != null)) {
|
||||
|
||||
}
|
||||
if (a is D && (b = a.d)) {
|
||||
|
||||
a = A();
|
||||
}
|
||||
if ((((a) is D) && (b = (a).d))) {
|
||||
|
||||
a = A();
|
||||
}
|
||||
if (f(a = A()) && a is D) {
|
||||
b = a.d;
|
||||
}
|
||||
}
|
||||
|
||||
bool f(x) => true;
|
49
tests/language/type_promotion/logical_and_test.dart
Normal file
49
tests/language/type_promotion/logical_and_test.dart
Normal file
|
@ -0,0 +1,49 @@
|
|||
// Copyright (c) 2013, 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.
|
||||
|
||||
// Test type promotion of locals potentially mutated.
|
||||
|
||||
class A {
|
||||
var a = true;
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
var b = true;
|
||||
}
|
||||
|
||||
class C extends B {
|
||||
var c = true;
|
||||
}
|
||||
|
||||
class D extends A {
|
||||
var d = true;
|
||||
}
|
||||
|
||||
class E implements C, D {
|
||||
var a = true;
|
||||
var b = true;
|
||||
var c = true;
|
||||
var d = true;
|
||||
}
|
||||
|
||||
void main() {
|
||||
A a = new E();
|
||||
var b;
|
||||
if (a is D && ((a = new D()) != null)) {
|
||||
b = a.d;
|
||||
}
|
||||
if (a is D && (b = a.d)) {
|
||||
b = a.d;
|
||||
a = A();
|
||||
}
|
||||
if ((((a) is D) && (b = (a).d))) {
|
||||
b = a.d;
|
||||
a = A();
|
||||
}
|
||||
if (f(a = A()) && a is D) {
|
||||
b = a.d;
|
||||
}
|
||||
}
|
||||
|
||||
bool f(x) => true;
|
|
@ -0,0 +1,93 @@
|
|||
// TODO(multitest): This was automatically migrated from a multitest and may
|
||||
// contain strange or dead code.
|
||||
|
||||
// Copyright (c) 2013, 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.
|
||||
|
||||
// Test use of more specific in type promotion of interface types.
|
||||
|
||||
class A {
|
||||
var a;
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
var b;
|
||||
}
|
||||
|
||||
class C {
|
||||
var c;
|
||||
}
|
||||
|
||||
class D<T> {
|
||||
T? d;
|
||||
|
||||
D(this.d);
|
||||
}
|
||||
|
||||
class E<T> extends D<T> {
|
||||
T? e;
|
||||
|
||||
E(e)
|
||||
: this.e = e,
|
||||
super(e);
|
||||
}
|
||||
|
||||
void main() {
|
||||
testInterface();
|
||||
testGeneric();
|
||||
}
|
||||
|
||||
void testInterface() {
|
||||
var x;
|
||||
var y;
|
||||
|
||||
A a = new B();
|
||||
if (a is B) {
|
||||
// Promotion B << A.
|
||||
x = a.b;
|
||||
}
|
||||
if (a is C) {
|
||||
// No promotion C !<< A.
|
||||
|
||||
}
|
||||
B b = new B();
|
||||
if (b is A) {
|
||||
// No promotion B !<< A.
|
||||
|
||||
}
|
||||
if (x is A) {
|
||||
// Promotion A << dynamic.
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
testGeneric() {
|
||||
var x;
|
||||
var y;
|
||||
|
||||
D d1 = new E<B>(null);
|
||||
if (d1 is E) {
|
||||
// Promotion: E << D.
|
||||
|
||||
}
|
||||
if (d1 is E<A>) {
|
||||
// Promotion: E<A> << D.
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
D<A> d2 = new E<B>(null);
|
||||
if (d2 is E) {
|
||||
// No promotion: E !<< D<A>
|
||||
|
||||
}
|
||||
|
||||
D<A> d3 = new E<B>(new B());
|
||||
if (d3 is E<B>) {
|
||||
// Promotion: E<B> << D<A>
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
// TODO(multitest): This was automatically migrated from a multitest and may
|
||||
// contain strange or dead code.
|
||||
|
||||
// Copyright (c) 2013, 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.
|
||||
|
||||
// Test use of more specific in type promotion of interface types.
|
||||
|
||||
class A {
|
||||
var a;
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
var b;
|
||||
}
|
||||
|
||||
class C {
|
||||
var c;
|
||||
}
|
||||
|
||||
class D<T> {
|
||||
T? d;
|
||||
|
||||
D(this.d);
|
||||
}
|
||||
|
||||
class E<T> extends D<T> {
|
||||
T? e;
|
||||
|
||||
E(e)
|
||||
: this.e = e,
|
||||
super(e);
|
||||
}
|
||||
|
||||
void main() {
|
||||
testInterface();
|
||||
testGeneric();
|
||||
}
|
||||
|
||||
void testInterface() {
|
||||
var x;
|
||||
var y;
|
||||
|
||||
A a = new B();
|
||||
if (a is B) {
|
||||
// Promotion B << A.
|
||||
|
||||
}
|
||||
if (a is C) {
|
||||
// No promotion C !<< A.
|
||||
|
||||
}
|
||||
B b = new B();
|
||||
if (b is A) {
|
||||
// No promotion B !<< A.
|
||||
x = b.b;
|
||||
}
|
||||
if (x is A) {
|
||||
// Promotion A << dynamic.
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
testGeneric() {
|
||||
var x;
|
||||
var y;
|
||||
|
||||
D d1 = new E<B>(null);
|
||||
if (d1 is E) {
|
||||
// Promotion: E << D.
|
||||
|
||||
}
|
||||
if (d1 is E<A>) {
|
||||
// Promotion: E<A> << D.
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
D<A> d2 = new E<B>(null);
|
||||
if (d2 is E) {
|
||||
// No promotion: E !<< D<A>
|
||||
|
||||
}
|
||||
|
||||
D<A> d3 = new E<B>(new B());
|
||||
if (d3 is E<B>) {
|
||||
// Promotion: E<B> << D<A>
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
// TODO(multitest): This was automatically migrated from a multitest and may
|
||||
// contain strange or dead code.
|
||||
|
||||
// Copyright (c) 2013, 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.
|
||||
|
||||
// Test use of more specific in type promotion of interface types.
|
||||
|
||||
class A {
|
||||
var a;
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
var b;
|
||||
}
|
||||
|
||||
class C {
|
||||
var c;
|
||||
}
|
||||
|
||||
class D<T> {
|
||||
T? d;
|
||||
|
||||
D(this.d);
|
||||
}
|
||||
|
||||
class E<T> extends D<T> {
|
||||
T? e;
|
||||
|
||||
E(e)
|
||||
: this.e = e,
|
||||
super(e);
|
||||
}
|
||||
|
||||
void main() {
|
||||
testInterface();
|
||||
testGeneric();
|
||||
}
|
||||
|
||||
void testInterface() {
|
||||
var x;
|
||||
var y;
|
||||
|
||||
A a = new B();
|
||||
if (a is B) {
|
||||
// Promotion B << A.
|
||||
|
||||
}
|
||||
if (a is C) {
|
||||
// No promotion C !<< A.
|
||||
|
||||
}
|
||||
B b = new B();
|
||||
if (b is A) {
|
||||
// No promotion B !<< A.
|
||||
|
||||
}
|
||||
if (x is A) {
|
||||
// Promotion A << dynamic.
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
testGeneric() {
|
||||
var x;
|
||||
var y;
|
||||
|
||||
D d1 = new E<B>(null);
|
||||
if (d1 is E) {
|
||||
// Promotion: E << D.
|
||||
x = d1.e;
|
||||
}
|
||||
if (d1 is E<A>) {
|
||||
// Promotion: E<A> << D.
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
D<A> d2 = new E<B>(null);
|
||||
if (d2 is E) {
|
||||
// No promotion: E !<< D<A>
|
||||
|
||||
}
|
||||
|
||||
D<A> d3 = new E<B>(new B());
|
||||
if (d3 is E<B>) {
|
||||
// Promotion: E<B> << D<A>
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
// TODO(multitest): This was automatically migrated from a multitest and may
|
||||
// contain strange or dead code.
|
||||
|
||||
// Copyright (c) 2013, 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.
|
||||
|
||||
// Test use of more specific in type promotion of interface types.
|
||||
|
||||
class A {
|
||||
var a;
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
var b;
|
||||
}
|
||||
|
||||
class C {
|
||||
var c;
|
||||
}
|
||||
|
||||
class D<T> {
|
||||
T? d;
|
||||
|
||||
D(this.d);
|
||||
}
|
||||
|
||||
class E<T> extends D<T> {
|
||||
T? e;
|
||||
|
||||
E(e)
|
||||
: this.e = e,
|
||||
super(e);
|
||||
}
|
||||
|
||||
void main() {
|
||||
testInterface();
|
||||
testGeneric();
|
||||
}
|
||||
|
||||
void testInterface() {
|
||||
var x;
|
||||
var y;
|
||||
|
||||
A a = new B();
|
||||
if (a is B) {
|
||||
// Promotion B << A.
|
||||
|
||||
}
|
||||
if (a is C) {
|
||||
// No promotion C !<< A.
|
||||
|
||||
}
|
||||
B b = new B();
|
||||
if (b is A) {
|
||||
// No promotion B !<< A.
|
||||
|
||||
}
|
||||
if (x is A) {
|
||||
// Promotion A << dynamic.
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
testGeneric() {
|
||||
var x;
|
||||
var y;
|
||||
|
||||
D d1 = new E<B>(null);
|
||||
if (d1 is E) {
|
||||
// Promotion: E << D.
|
||||
|
||||
}
|
||||
if (d1 is E<A>) {
|
||||
// Promotion: E<A> << D.
|
||||
|
||||
|
||||
x = d1.e;
|
||||
}
|
||||
|
||||
D<A> d2 = new E<B>(null);
|
||||
if (d2 is E) {
|
||||
// No promotion: E !<< D<A>
|
||||
|
||||
}
|
||||
|
||||
D<A> d3 = new E<B>(new B());
|
||||
if (d3 is E<B>) {
|
||||
// Promotion: E<B> << D<A>
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
// TODO(multitest): This was automatically migrated from a multitest and may
|
||||
// contain strange or dead code.
|
||||
|
||||
// Copyright (c) 2013, 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.
|
||||
|
||||
// Test use of more specific in type promotion of interface types.
|
||||
|
||||
class A {
|
||||
var a;
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
var b;
|
||||
}
|
||||
|
||||
class C {
|
||||
var c;
|
||||
}
|
||||
|
||||
class D<T> {
|
||||
T? d;
|
||||
|
||||
D(this.d);
|
||||
}
|
||||
|
||||
class E<T> extends D<T> {
|
||||
T? e;
|
||||
|
||||
E(e)
|
||||
: this.e = e,
|
||||
super(e);
|
||||
}
|
||||
|
||||
void main() {
|
||||
testInterface();
|
||||
testGeneric();
|
||||
}
|
||||
|
||||
void testInterface() {
|
||||
var x;
|
||||
var y;
|
||||
|
||||
A a = new B();
|
||||
if (a is B) {
|
||||
// Promotion B << A.
|
||||
|
||||
}
|
||||
if (a is C) {
|
||||
// No promotion C !<< A.
|
||||
|
||||
}
|
||||
B b = new B();
|
||||
if (b is A) {
|
||||
// No promotion B !<< A.
|
||||
|
||||
}
|
||||
if (x is A) {
|
||||
// Promotion A << dynamic.
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
testGeneric() {
|
||||
var x;
|
||||
var y;
|
||||
|
||||
D d1 = new E<B>(null);
|
||||
if (d1 is E) {
|
||||
// Promotion: E << D.
|
||||
|
||||
}
|
||||
if (d1 is E<A>) {
|
||||
// Promotion: E<A> << D.
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
D<A> d2 = new E<B>(null);
|
||||
if (d2 is E) {
|
||||
// No promotion: E !<< D<A>
|
||||
|
||||
}
|
||||
|
||||
D<A> d3 = new E<B>(new B());
|
||||
if (d3 is E<B>) {
|
||||
// Promotion: E<B> << D<A>
|
||||
x = d3.d!.b;
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
// TODO(multitest): This was automatically migrated from a multitest and may
|
||||
// contain strange or dead code.
|
||||
|
||||
// Copyright (c) 2013, 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.
|
||||
|
||||
// Test use of more specific in type promotion of interface types.
|
||||
|
||||
class A {
|
||||
var a;
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
var b;
|
||||
}
|
||||
|
||||
class C {
|
||||
var c;
|
||||
}
|
||||
|
||||
class D<T> {
|
||||
T? d;
|
||||
|
||||
D(this.d);
|
||||
}
|
||||
|
||||
class E<T> extends D<T> {
|
||||
T? e;
|
||||
|
||||
E(e)
|
||||
: this.e = e,
|
||||
super(e);
|
||||
}
|
||||
|
||||
void main() {
|
||||
testInterface();
|
||||
testGeneric();
|
||||
}
|
||||
|
||||
void testInterface() {
|
||||
var x;
|
||||
var y;
|
||||
|
||||
A a = new B();
|
||||
if (a is B) {
|
||||
// Promotion B << A.
|
||||
|
||||
}
|
||||
if (a is C) {
|
||||
// No promotion C !<< A.
|
||||
|
||||
}
|
||||
B b = new B();
|
||||
if (b is A) {
|
||||
// No promotion B !<< A.
|
||||
|
||||
}
|
||||
if (x is A) {
|
||||
// Promotion A << dynamic.
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
testGeneric() {
|
||||
var x;
|
||||
var y;
|
||||
|
||||
D d1 = new E<B>(null);
|
||||
if (d1 is E) {
|
||||
// Promotion: E << D.
|
||||
|
||||
}
|
||||
if (d1 is E<A>) {
|
||||
// Promotion: E<A> << D.
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
D<A> d2 = new E<B>(null);
|
||||
if (d2 is E) {
|
||||
// No promotion: E !<< D<A>
|
||||
|
||||
}
|
||||
|
||||
D<A> d3 = new E<B>(new B());
|
||||
if (d3 is E<B>) {
|
||||
// Promotion: E<B> << D<A>
|
||||
|
||||
x = d3.e!.b;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
// TODO(multitest): This was automatically migrated from a multitest and may
|
||||
// contain strange or dead code.
|
||||
|
||||
// Copyright (c) 2013, 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.
|
||||
|
||||
// Test use of more specific in type promotion of interface types.
|
||||
|
||||
class A {
|
||||
var a;
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
var b;
|
||||
}
|
||||
|
||||
class C {
|
||||
var c;
|
||||
}
|
||||
|
||||
class D<T> {
|
||||
T? d;
|
||||
|
||||
D(this.d);
|
||||
}
|
||||
|
||||
class E<T> extends D<T> {
|
||||
T? e;
|
||||
|
||||
E(e)
|
||||
: this.e = e,
|
||||
super(e);
|
||||
}
|
||||
|
||||
void main() {
|
||||
testInterface();
|
||||
testGeneric();
|
||||
}
|
||||
|
||||
void testInterface() {
|
||||
var x;
|
||||
var y;
|
||||
|
||||
A a = new B();
|
||||
if (a is B) {
|
||||
// Promotion B << A.
|
||||
|
||||
}
|
||||
if (a is C) {
|
||||
// No promotion C !<< A.
|
||||
|
||||
}
|
||||
B b = new B();
|
||||
if (b is A) {
|
||||
// No promotion B !<< A.
|
||||
|
||||
}
|
||||
if (x is A) {
|
||||
// Promotion A << dynamic.
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
testGeneric() {
|
||||
var x;
|
||||
var y;
|
||||
|
||||
D d1 = new E<B>(null);
|
||||
if (d1 is E) {
|
||||
// Promotion: E << D.
|
||||
|
||||
}
|
||||
if (d1 is E<A>) {
|
||||
// Promotion: E<A> << D.
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
D<A> d2 = new E<B>(null);
|
||||
if (d2 is E) {
|
||||
// No promotion: E !<< D<A>
|
||||
|
||||
}
|
||||
|
||||
D<A> d3 = new E<B>(new B());
|
||||
if (d3 is E<B>) {
|
||||
// Promotion: E<B> << D<A>
|
||||
|
||||
|
||||
}
|
||||
}
|
107
tests/language/type_promotion/more_specific_test.dart
Normal file
107
tests/language/type_promotion/more_specific_test.dart
Normal file
|
@ -0,0 +1,107 @@
|
|||
// Copyright (c) 2013, 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.
|
||||
|
||||
// Test use of more specific in type promotion of interface types.
|
||||
|
||||
class A {
|
||||
var a;
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
var b;
|
||||
}
|
||||
|
||||
class C {
|
||||
var c;
|
||||
}
|
||||
|
||||
class D<T> {
|
||||
T d;
|
||||
|
||||
D(this.d);
|
||||
}
|
||||
|
||||
class E<T> extends D<T> {
|
||||
T? e;
|
||||
|
||||
E(e)
|
||||
: this.e = e,
|
||||
super(e);
|
||||
}
|
||||
|
||||
void main() {
|
||||
testInterface();
|
||||
testGeneric();
|
||||
}
|
||||
|
||||
void testInterface() {
|
||||
var x;
|
||||
var y;
|
||||
|
||||
A a = new B();
|
||||
if (a is B) {
|
||||
// Promotion B << A.
|
||||
x = a.b;
|
||||
}
|
||||
if (a is C) {
|
||||
// No promotion C !<< A.
|
||||
x = a.c;
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'c' isn't defined for the class 'A'.
|
||||
}
|
||||
B b = new B();
|
||||
if (b is A) {
|
||||
// No promotion B !<< A.
|
||||
x = b.b;
|
||||
}
|
||||
if (x is A) {
|
||||
// Promotion A << dynamic.
|
||||
y = x.b;
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'b' isn't defined for the class 'A'.
|
||||
}
|
||||
}
|
||||
|
||||
testGeneric() {
|
||||
var x;
|
||||
var y;
|
||||
|
||||
D d1 = new E<B>(null);
|
||||
if (d1 is E) {
|
||||
// Promotion: E << D.
|
||||
x = d1.e;
|
||||
}
|
||||
if (d1 is E<A>) {
|
||||
// Promotion: E<A> << D.
|
||||
int a = d1.d;
|
||||
// ^^^^
|
||||
// [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
|
||||
// ^
|
||||
// [cfe] A value of type 'A' can't be assigned to a variable of type 'int'.
|
||||
String b = d1.d;
|
||||
// ^^^^
|
||||
// [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
|
||||
// ^
|
||||
// [cfe] A value of type 'A' can't be assigned to a variable of type 'String'.
|
||||
x = d1.e;
|
||||
}
|
||||
|
||||
D<A> d2 = new E<B>(null);
|
||||
if (d2 is E) {
|
||||
// No promotion: E !<< D<A>
|
||||
x = d2.e;
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'e' isn't defined for the class 'D<A>'.
|
||||
}
|
||||
|
||||
D<A> d3 = new E<B>(new B());
|
||||
if (d3 is E<B>) {
|
||||
// Promotion: E<B> << D<A>
|
||||
x = d3.d.b;
|
||||
x = d3.e!.b;
|
||||
}
|
||||
}
|
103
tests/language/type_promotion/multiple_runtime_test.dart
Normal file
103
tests/language/type_promotion/multiple_runtime_test.dart
Normal file
|
@ -0,0 +1,103 @@
|
|||
// TODO(multitest): This was automatically migrated from a multitest and may
|
||||
// contain strange or dead code.
|
||||
|
||||
// Copyright (c) 2013, 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.
|
||||
|
||||
// Test type promotion of locals.
|
||||
|
||||
class A {
|
||||
var a = "a";
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
var b = "b";
|
||||
}
|
||||
|
||||
class C extends B {
|
||||
var c = "c";
|
||||
}
|
||||
|
||||
class D extends A {
|
||||
var d = "d";
|
||||
}
|
||||
|
||||
class E implements C, D {
|
||||
var a = "";
|
||||
var b = "";
|
||||
var c = "";
|
||||
var d = "";
|
||||
}
|
||||
|
||||
void main() {
|
||||
test(new E());
|
||||
}
|
||||
|
||||
void test(A a1) {
|
||||
A a2 = new E();
|
||||
print(a1.a);
|
||||
|
||||
|
||||
|
||||
|
||||
print(a2.a);
|
||||
|
||||
|
||||
|
||||
|
||||
if (a1 is B && a2 is C) {
|
||||
print(a1.a);
|
||||
print(a1.b);
|
||||
|
||||
|
||||
|
||||
print(a2.a);
|
||||
print(a2.b);
|
||||
print(a2.c);
|
||||
|
||||
|
||||
if (a1 is C && a2 is D) {
|
||||
print(a1.a);
|
||||
print(a1.b);
|
||||
print(a1.c);
|
||||
|
||||
|
||||
print(a2.a);
|
||||
print(a2.b);
|
||||
print(a2.c);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
var o1 = a1 is B && a2 is C
|
||||
? '${a1.a}'
|
||||
'${a1.b}'
|
||||
|
||||
|
||||
'${a2.a}'
|
||||
'${a2.b}'
|
||||
'${a2.c}'
|
||||
|
||||
: '${a1.a}'
|
||||
|
||||
|
||||
|
||||
'${a2.a}'
|
||||
|
||||
|
||||
|
||||
;
|
||||
|
||||
if (a2 is C && a1 is B && a1 is C && a2 is B && a2 is D) {
|
||||
print(a1.a);
|
||||
print(a1.b);
|
||||
print(a1.c);
|
||||
|
||||
|
||||
print(a2.a);
|
||||
print(a2.b);
|
||||
print(a2.c);
|
||||
|
||||
}
|
||||
}
|
166
tests/language/type_promotion/multiple_test.dart
Normal file
166
tests/language/type_promotion/multiple_test.dart
Normal file
|
@ -0,0 +1,166 @@
|
|||
// Copyright (c) 2013, 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.
|
||||
|
||||
// Test type promotion of locals.
|
||||
|
||||
class A {
|
||||
var a = "a";
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
var b = "b";
|
||||
}
|
||||
|
||||
class C extends B {
|
||||
var c = "c";
|
||||
}
|
||||
|
||||
class D extends A {
|
||||
var d = "d";
|
||||
}
|
||||
|
||||
class E implements C, D {
|
||||
var a = "";
|
||||
var b = "";
|
||||
var c = "";
|
||||
var d = "";
|
||||
}
|
||||
|
||||
void main() {
|
||||
test(new E());
|
||||
}
|
||||
|
||||
void test(A a1) {
|
||||
A a2 = new E();
|
||||
print(a1.a);
|
||||
print(a1.b);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'b' isn't defined for the class 'A'.
|
||||
print(a1.c);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'c' isn't defined for the class 'A'.
|
||||
print(a1.d);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'd' isn't defined for the class 'A'.
|
||||
|
||||
print(a2.a);
|
||||
print(a2.b);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'b' isn't defined for the class 'A'.
|
||||
print(a2.c);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'c' isn't defined for the class 'A'.
|
||||
print(a2.d);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'd' isn't defined for the class 'A'.
|
||||
|
||||
if (a1 is B && a2 is C) {
|
||||
print(a1.a);
|
||||
print(a1.b);
|
||||
print(a1.c);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'c' isn't defined for the class 'B'.
|
||||
print(a1.d);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'd' isn't defined for the class 'B'.
|
||||
|
||||
print(a2.a);
|
||||
print(a2.b);
|
||||
print(a2.c);
|
||||
print(a2.d);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'd' isn't defined for the class 'C'.
|
||||
|
||||
if (a1 is C && a2 is D) {
|
||||
print(a1.a);
|
||||
print(a1.b);
|
||||
print(a1.c);
|
||||
print(a1.d);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'd' isn't defined for the class 'C'.
|
||||
|
||||
print(a2.a);
|
||||
print(a2.b);
|
||||
print(a2.c);
|
||||
print(a2.d);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'd' isn't defined for the class 'C'.
|
||||
}
|
||||
}
|
||||
|
||||
var o1 = a1 is B && a2 is C
|
||||
? '${a1.a}'
|
||||
'${a1.b}'
|
||||
'${a1.c}'
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'c' isn't defined for the class 'B'.
|
||||
'${a1.d}'
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'd' isn't defined for the class 'B'.
|
||||
'${a2.a}'
|
||||
'${a2.b}'
|
||||
'${a2.c}'
|
||||
'${a2.d}'
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'd' isn't defined for the class 'C'.
|
||||
: '${a1.a}'
|
||||
'${a1.b}'
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'b' isn't defined for the class 'A'.
|
||||
'${a1.c}'
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'c' isn't defined for the class 'A'.
|
||||
'${a1.d}'
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'd' isn't defined for the class 'A'.
|
||||
'${a2.a}'
|
||||
'${a2.b}'
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'b' isn't defined for the class 'A'.
|
||||
'${a2.c}'
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'c' isn't defined for the class 'A'.
|
||||
'${a2.d}'
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'd' isn't defined for the class 'A'.
|
||||
;
|
||||
|
||||
if (a2 is C && a1 is B && a1 is C && a2 is B && a2 is D) {
|
||||
print(a1.a);
|
||||
print(a1.b);
|
||||
print(a1.c);
|
||||
print(a1.d);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'd' isn't defined for the class 'C'.
|
||||
|
||||
print(a2.a);
|
||||
print(a2.b);
|
||||
print(a2.c);
|
||||
print(a2.d);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'd' isn't defined for the class 'C'.
|
||||
}
|
||||
}
|
211
tests/language/type_promotion/parameter_runtime_test.dart
Normal file
211
tests/language/type_promotion/parameter_runtime_test.dart
Normal file
|
@ -0,0 +1,211 @@
|
|||
// TODO(multitest): This was automatically migrated from a multitest and may
|
||||
// contain strange or dead code.
|
||||
|
||||
// Copyright (c) 2013, 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.
|
||||
|
||||
// Test type promotion of parameters.
|
||||
|
||||
class A {
|
||||
var a = "a";
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
var b = "b";
|
||||
}
|
||||
|
||||
class C extends B {
|
||||
var c = "c";
|
||||
}
|
||||
|
||||
class D extends A {
|
||||
var d = "d";
|
||||
}
|
||||
|
||||
class E implements C, D {
|
||||
var a = "";
|
||||
var b = "";
|
||||
var c = "";
|
||||
var d = "";
|
||||
}
|
||||
|
||||
void main() {
|
||||
test(new E());
|
||||
}
|
||||
|
||||
void test(A a) {
|
||||
print(a.a);
|
||||
|
||||
|
||||
|
||||
|
||||
if (a is B) {
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
|
||||
|
||||
|
||||
if (a is C) {
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
print(a.c);
|
||||
|
||||
}
|
||||
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
|
||||
|
||||
}
|
||||
if (a is C) {
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
print(a.c);
|
||||
|
||||
|
||||
if (a is B) {
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
print(a.c);
|
||||
|
||||
}
|
||||
if (a is D) {
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
print(a.c);
|
||||
|
||||
}
|
||||
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
print(a.c);
|
||||
|
||||
}
|
||||
|
||||
print(a.a);
|
||||
|
||||
|
||||
|
||||
|
||||
if (a is D) {
|
||||
print(a.a);
|
||||
|
||||
|
||||
print(a.d);
|
||||
}
|
||||
|
||||
print(a.a);
|
||||
|
||||
|
||||
|
||||
|
||||
var o1 = a is B
|
||||
? '${a.a}'
|
||||
'${a.b}'
|
||||
|
||||
|
||||
: '${a.a}'
|
||||
|
||||
|
||||
|
||||
;
|
||||
|
||||
var o2 = a is C
|
||||
? '${a.a}'
|
||||
'${a.b}'
|
||||
'${a.c}'
|
||||
|
||||
: '${a.a}'
|
||||
|
||||
|
||||
|
||||
;
|
||||
|
||||
var o3 = a is D
|
||||
? '${a.a}'
|
||||
|
||||
|
||||
'${a.d}'
|
||||
: '${a.a}'
|
||||
|
||||
|
||||
|
||||
;
|
||||
|
||||
if (a is B && a is B) {
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
|
||||
|
||||
}
|
||||
if (a is B && a is C) {
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
print(a.c);
|
||||
|
||||
}
|
||||
if (a is C && a is B) {
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
print(a.c);
|
||||
|
||||
}
|
||||
if (a is C && a is D) {
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
print(a.c);
|
||||
|
||||
}
|
||||
if (a is D && a is C) {
|
||||
print(a.a);
|
||||
|
||||
|
||||
print(a.d);
|
||||
}
|
||||
if (a is D &&
|
||||
a.a == ""
|
||||
|
||||
|
||||
&&
|
||||
a.d == "") {
|
||||
print(a.a);
|
||||
|
||||
|
||||
print(a.d);
|
||||
}
|
||||
if (a.a == ""
|
||||
|
||||
|
||||
|
||||
&&
|
||||
a is B &&
|
||||
a.a == "" &&
|
||||
a.b == ""
|
||||
|
||||
|
||||
&&
|
||||
a is C &&
|
||||
a.a == "" &&
|
||||
a.b == "" &&
|
||||
a.c == ""
|
||||
|
||||
) {
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
print(a.c);
|
||||
|
||||
}
|
||||
if ((a is B)) {
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
|
||||
|
||||
}
|
||||
if ((a is B && (a) is C) && a is B) {
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
print(a.c);
|
||||
|
||||
}
|
||||
}
|
373
tests/language/type_promotion/parameter_test.dart
Normal file
373
tests/language/type_promotion/parameter_test.dart
Normal file
|
@ -0,0 +1,373 @@
|
|||
// Copyright (c) 2013, 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.
|
||||
|
||||
// Test type promotion of parameters.
|
||||
|
||||
class A {
|
||||
var a = "a";
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
var b = "b";
|
||||
}
|
||||
|
||||
class C extends B {
|
||||
var c = "c";
|
||||
}
|
||||
|
||||
class D extends A {
|
||||
var d = "d";
|
||||
}
|
||||
|
||||
class E implements C, D {
|
||||
var a = "";
|
||||
var b = "";
|
||||
var c = "";
|
||||
var d = "";
|
||||
}
|
||||
|
||||
void main() {
|
||||
test(new E());
|
||||
}
|
||||
|
||||
void test(A a) {
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'b' isn't defined for the class 'A'.
|
||||
print(a.c);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'c' isn't defined for the class 'A'.
|
||||
print(a.d);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'd' isn't defined for the class 'A'.
|
||||
|
||||
if (a is B) {
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
print(a.c);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'c' isn't defined for the class 'B'.
|
||||
print(a.d);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'd' isn't defined for the class 'B'.
|
||||
|
||||
if (a is C) {
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
print(a.c);
|
||||
print(a.d);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'd' isn't defined for the class 'C'.
|
||||
}
|
||||
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
print(a.c);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'c' isn't defined for the class 'B'.
|
||||
print(a.d);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'd' isn't defined for the class 'B'.
|
||||
}
|
||||
if (a is C) {
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
print(a.c);
|
||||
print(a.d);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'd' isn't defined for the class 'C'.
|
||||
|
||||
if (a is B) {
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
print(a.c);
|
||||
print(a.d);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'd' isn't defined for the class 'C'.
|
||||
}
|
||||
if (a is D) {
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
print(a.c);
|
||||
print(a.d);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'd' isn't defined for the class 'C'.
|
||||
}
|
||||
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
print(a.c);
|
||||
print(a.d);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'd' isn't defined for the class 'C'.
|
||||
}
|
||||
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'b' isn't defined for the class 'A'.
|
||||
print(a.c);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'c' isn't defined for the class 'A'.
|
||||
print(a.d);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'd' isn't defined for the class 'A'.
|
||||
|
||||
if (a is D) {
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'b' isn't defined for the class 'D'.
|
||||
print(a.c);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'c' isn't defined for the class 'D'.
|
||||
print(a.d);
|
||||
}
|
||||
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'b' isn't defined for the class 'A'.
|
||||
print(a.c);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'c' isn't defined for the class 'A'.
|
||||
print(a.d);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'd' isn't defined for the class 'A'.
|
||||
|
||||
var o1 = a is B
|
||||
? '${a.a}'
|
||||
'${a.b}'
|
||||
'${a.c}'
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'c' isn't defined for the class 'B'.
|
||||
'${a.d}'
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'd' isn't defined for the class 'B'.
|
||||
: '${a.a}'
|
||||
'${a.b}'
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'b' isn't defined for the class 'A'.
|
||||
'${a.c}'
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'c' isn't defined for the class 'A'.
|
||||
'${a.d}'
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'd' isn't defined for the class 'A'.
|
||||
;
|
||||
|
||||
var o2 = a is C
|
||||
? '${a.a}'
|
||||
'${a.b}'
|
||||
'${a.c}'
|
||||
'${a.d}'
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'd' isn't defined for the class 'C'.
|
||||
: '${a.a}'
|
||||
'${a.b}'
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'b' isn't defined for the class 'A'.
|
||||
'${a.c}'
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'c' isn't defined for the class 'A'.
|
||||
'${a.d}'
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'd' isn't defined for the class 'A'.
|
||||
;
|
||||
|
||||
var o3 = a is D
|
||||
? '${a.a}'
|
||||
'${a.b}'
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'b' isn't defined for the class 'D'.
|
||||
'${a.c}'
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'c' isn't defined for the class 'D'.
|
||||
'${a.d}'
|
||||
: '${a.a}'
|
||||
'${a.b}'
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'b' isn't defined for the class 'A'.
|
||||
'${a.c}'
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'c' isn't defined for the class 'A'.
|
||||
'${a.d}'
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'd' isn't defined for the class 'A'.
|
||||
;
|
||||
|
||||
if (a is B && a is B) {
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
print(a.c);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'c' isn't defined for the class 'B'.
|
||||
print(a.d);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'd' isn't defined for the class 'B'.
|
||||
}
|
||||
if (a is B && a is C) {
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
print(a.c);
|
||||
print(a.d);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'd' isn't defined for the class 'C'.
|
||||
}
|
||||
if (a is C && a is B) {
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
print(a.c);
|
||||
print(a.d);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'd' isn't defined for the class 'C'.
|
||||
}
|
||||
if (a is C && a is D) {
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
print(a.c);
|
||||
print(a.d);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'd' isn't defined for the class 'C'.
|
||||
}
|
||||
if (a is D && a is C) {
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'b' isn't defined for the class 'D'.
|
||||
print(a.c);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'c' isn't defined for the class 'D'.
|
||||
print(a.d);
|
||||
}
|
||||
if (a is D &&
|
||||
a.a == ""
|
||||
&& a.b == ""
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'b' isn't defined for the class 'D'.
|
||||
&& a.c == ""
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'c' isn't defined for the class 'D'.
|
||||
&&
|
||||
a.d == "") {
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'b' isn't defined for the class 'D'.
|
||||
print(a.c);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'c' isn't defined for the class 'D'.
|
||||
print(a.d);
|
||||
}
|
||||
if (a.a == ""
|
||||
&& a.b == ""
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'b' isn't defined for the class 'A'.
|
||||
&& a.c == ""
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'c' isn't defined for the class 'A'.
|
||||
&& a.d == ""
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'd' isn't defined for the class 'A'.
|
||||
&&
|
||||
a is B &&
|
||||
a.a == "" &&
|
||||
a.b == ""
|
||||
&& a.c == ""
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'c' isn't defined for the class 'B'.
|
||||
&& a.d == ""
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'd' isn't defined for the class 'B'.
|
||||
&&
|
||||
a is C &&
|
||||
a.a == "" &&
|
||||
a.b == "" &&
|
||||
a.c == ""
|
||||
&& a.d == ""
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'd' isn't defined for the class 'C'.
|
||||
) {
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
print(a.c);
|
||||
print(a.d);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'd' isn't defined for the class 'C'.
|
||||
}
|
||||
if ((a is B)) {
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
print(a.c);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'c' isn't defined for the class 'B'.
|
||||
print(a.d);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'd' isn't defined for the class 'B'.
|
||||
}
|
||||
if ((a is B && (a) is C) && a is B) {
|
||||
print(a.a);
|
||||
print(a.b);
|
||||
print(a.c);
|
||||
print(a.d);
|
||||
// ^
|
||||
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
|
||||
// [cfe] The getter 'd' isn't defined for the class 'C'.
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue