blob: 79beb981c838af0b3fb88c46d8b9124090c71d52 [file] [log] [blame]
// 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.
import 'dart:async';
// Tests several aspects of the TOP_MERGE algorithm for merging members
class A<T> {
T member() {
throw "Unreachable";
}
}
class B<T> {
T member() {
throw "Unreachable";
}
}
void takesObject(Object x) {}
class D0 extends A<dynamic> implements B<Object?> {
void test() {
var self = this;
var x = self.member();
x.foo; // Check that member does not return dynamic
// ^
// [analyzer] unspecified
// [cfe] unspecified
x.toString; // Check that member does not return void
takesObject(x); // Check that member does not return Object
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
}
class D1 extends A<Object?> implements B<dynamic> {
void test() {
var self = this;
var x = self.member();
x.foo; // Check that member does not return dynamic
// ^
// [analyzer] unspecified
// [cfe] unspecified
x.toString; // Check that member does not return void
takesObject(x); // Check that member does not return Object
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
}
class D2 extends A<void> implements B<Object?> {
void test() {
var self = this;
var x = self.member();
x.foo; // Check that member does not return dynamic
// ^
// [analyzer] unspecified
// [cfe] unspecified
x.toString; // Check that member does not return void
takesObject(x); // Check that member does not return Object
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
}
class D3 extends A<Object?> implements B<void> {
void test() {
var self = this;
var x = self.member();
x.foo; // Check that member does not return dynamic
// ^
// [analyzer] unspecified
// [cfe] unspecified
x.toString; // Check that member does not return void
takesObject(x); // Check that member does not return Object
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
}
class D4 extends A<void> implements B<dynamic> {
void test() {
var self = this;
var x = self.member();
x.foo; // Check that member does not return dynamic
// ^
// [analyzer] unspecified
// [cfe] unspecified
x.toString; // Check that member does not return void
takesObject(x); // Check that member does not return Object
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
}
class D5 extends A<dynamic> implements B<void> {
void test() {
var self = this;
var x = self.member();
x.foo; // Check that member does not return dynamic
// ^
// [analyzer] unspecified
// [cfe] unspecified
x.toString; // Check that member does not return void
takesObject(x); // Check that member does not return Object
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
}
class D6 extends A<void> implements B<void> {
void test() {
var self = this;
var x = self.member();
x.foo; // Check that member does not return dynamic
// ^
// [analyzer] unspecified
// [cfe] unspecified
x.toString; // Check that member does not return Object?
// ^
// [analyzer] unspecified
// [cfe] unspecified
takesObject(x); // Check that member does not return Object
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
}
class D7 extends A<dynamic> implements B<dynamic> {
void test() {
var self = this;
var x = self.member();
x.foo; // Check that member returns dynamic
}
}
// Test the same examples with top level normalization
class ND0 extends A<FutureOr<dynamic>> implements B<Object?> {
void test() {
var self = this;
var x = self.member();
x.foo; // Check that member does not return dynamic
// ^
// [analyzer] unspecified
// [cfe] unspecified
x.toString; // Check that member does not return void
takesObject(x); // Check that member does not return Object
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
}
class ND1 extends A<FutureOr<Object?>> implements B<dynamic> {
void test() {
var self = this;
var x = self.member();
x.foo; // Check that member does not return dynamic
// ^
// [analyzer] unspecified
// [cfe] unspecified
x.toString; // Check that member does not return void
takesObject(x); // Check that member does not return Object
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
}
class ND2 extends A<FutureOr<void>> implements B<Object?> {
void test() {
var self = this;
var x = self.member();
x.foo; // Check that member does not return dynamic
// ^
// [analyzer] unspecified
// [cfe] unspecified
x.toString; // Check that member does not return void
takesObject(x); // Check that member does not return Object
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
}
class ND3 extends A<FutureOr<Object?>> implements B<void> {
void test() {
var self = this;
var x = self.member();
x.foo; // Check that member does not return dynamic
// ^
// [analyzer] unspecified
// [cfe] unspecified
x.toString; // Check that member does not return void
takesObject(x); // Check that member does not return Object
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
}
class ND4 extends A<FutureOr<void>> implements B<dynamic> {
void test() {
var self = this;
var x = self.member();
x.foo; // Check that member does not return dynamic
// ^
// [analyzer] unspecified
// [cfe] unspecified
x.toString; // Check that member does not return void
takesObject(x); // Check that member does not return Object
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
}
class ND5 extends A<FutureOr<dynamic>> implements B<void> {
void test() {
var self = this;
var x = self.member();
x.foo; // Check that member does not return dynamic
// ^
// [analyzer] unspecified
// [cfe] unspecified
x.toString; // Check that member does not return void
takesObject(x); // Check that member does not return Object
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
}
class ND6 extends A<FutureOr<void>> implements B<void> {
void test() {
var self = this;
var x = self.member();
x.foo; // Check that member does not return dynamic
// ^
// [analyzer] unspecified
// [cfe] unspecified
x.toString; // Check that member does not return Object?
// ^
// [analyzer] unspecified
// [cfe] unspecified
takesObject(x); // Check that member does not return Object
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
}
class ND7 extends A<FutureOr<dynamic>> implements B<dynamic> {
void test() {
var self = this;
var x = self.member();
x.foo; // Check that member returns dynamic
}
}
// Test the same examples with deep normalization
class DND0 extends A<FutureOr<dynamic> Function()>
implements B<Object? Function()> {
void test() {
var self = this;
var x = self.member()();
x.foo; // Check that member does not return dynamic Function()
// ^
// [analyzer] unspecified
// [cfe] unspecified
x.toString; // Check that member does not return void Function()
takesObject(x); // Check that member does not return Object Function()
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
}
class DND1 extends A<FutureOr<Object?> Function()>
implements B<dynamic Function()> {
void test() {
var self = this;
var x = self.member()();
x.foo; // Check that member does not return dynamic Function()
// ^
// [analyzer] unspecified
// [cfe] unspecified
x.toString; // Check that member does not return void Function()
takesObject(x); // Check that member does not return Object Function()
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
}
class DND2 extends A<FutureOr<void> Function()>
implements B<Object? Function()> {
void test() {
var self = this;
var x = self.member()();
x.foo; // Check that member does not return dynamic Function()
// ^
// [analyzer] unspecified
// [cfe] unspecified
x.toString; // Check that member does not return void Function()
takesObject(x); // Check that member does not return Object Function()
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
}
class DND3 extends A<FutureOr<Object?> Function()>
implements B<void Function()> {
void test() {
var self = this;
var x = self.member()();
x.foo; // Check that member does not return dynamic Function()
// ^
// [analyzer] unspecified
// [cfe] unspecified
x.toString; // Check that member does not return void Function()
takesObject(x); // Check that member does not return Object Function()
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
}
class DND4 extends A<FutureOr<void> Function()>
implements B<dynamic Function()> {
void test() {
var self = this;
var x = self.member()();
x.foo; // Check that member does not return dynamic Function()
// ^
// [analyzer] unspecified
// [cfe] unspecified
x.toString; // Check that member does not return void Function()
takesObject(x); // Check that member does not return Object Function()
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
}
class DND5 extends A<FutureOr<dynamic> Function()>
implements B<void Function()> {
void test() {
var self = this;
var x = self.member()();
x.foo; // Check that member does not return dynamic Function()
// ^
// [analyzer] unspecified
// [cfe] unspecified
x.toString; // Check that member does not return void Function()
takesObject(x); // Check that member does not return Object Function()
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
}
class DND6 extends A<FutureOr<void> Function()> implements B<void Function()> {
void test() {
var self = this;
var x = self.member()();
x.foo; // Check that member does not return dynamic Function()
// ^
// [analyzer] unspecified
// [cfe] unspecified
x.toString; // Check that member does not return Object? Function()
// ^
// [analyzer] unspecified
// [cfe] unspecified
takesObject(x); // Check that member does not return Object Function()
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
}
class DND7 extends A<FutureOr<dynamic> Function()>
implements B<dynamic Function()> {
void test() {
var self = this;
var x = self.member()();
x.foo; // Check that member returns dynamic Function()
}
}
// Test the same examples with deep normalization + typedefs
typedef Wrap<T> = FutureOr<T>? Function();
class WND0 extends A<Wrap<FutureOr<dynamic>>> implements B<Wrap<Object?>> {
void test() {
var self = this;
var x = self.member()();
x.foo; // Check that member does not return dynamic Function()
// ^
// [analyzer] unspecified
// [cfe] unspecified
x.toString; // Check that member does not return void Function()
takesObject(x); // Check that member does not return Object Function()
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
}
class WND1 extends A<Wrap<FutureOr<Object?>>> implements B<Wrap<dynamic>> {
void test() {
var self = this;
var x = self.member()();
x.foo; // Check that member does not return dynamic Function()
// ^
// [analyzer] unspecified
// [cfe] unspecified
x.toString; // Check that member does not return void Function()
takesObject(x); // Check that member does not return Object Function()
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
}
class WND2 extends A<Wrap<FutureOr<void>>> implements B<Wrap<Object?>> {
void test() {
var self = this;
var x = self.member()();
x.foo; // Check that member does not return dynamic Function()
// ^
// [analyzer] unspecified
// [cfe] unspecified
x.toString; // Check that member does not return void Function()
takesObject(x); // Check that member does not return Object Function()
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
}
class WND3 extends A<Wrap<FutureOr<Object?>>> implements B<Wrap<void>> {
void test() {
var self = this;
var x = self.member()();
x.foo; // Check that member does not return dynamic Function()
// ^
// [analyzer] unspecified
// [cfe] unspecified
x.toString; // Check that member does not return void Function()
takesObject(x); // Check that member does not return Object Function()
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
}
class WND4 extends A<Wrap<FutureOr<void>>> implements B<Wrap<dynamic>> {
void test() {
var self = this;
var x = self.member()();
x.foo; // Check that member does not return dynamic Function()
// ^
// [analyzer] unspecified
// [cfe] unspecified
x.toString; // Check that member does not return void Function()
takesObject(x); // Check that member does not return Object Function()
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
}
class WND5 extends A<Wrap<FutureOr<dynamic>>> implements B<Wrap<void>> {
void test() {
var self = this;
var x = self.member()();
x.foo; // Check that member does not return dynamic Function()
// ^
// [analyzer] unspecified
// [cfe] unspecified
x.toString; // Check that member does not return void Function()
takesObject(x); // Check that member does not return Object Function()
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
}
class WND6 extends A<Wrap<FutureOr<void>>> implements B<Wrap<void>> {
void test() {
var self = this;
var x = self.member()();
x.foo; // Check that member does not return dynamic Function()
// ^
// [analyzer] unspecified
// [cfe] unspecified
x.toString; // Check that member does not return Object? Function()
// ^
// [analyzer] unspecified
// [cfe] unspecified
takesObject(x); // Check that member does not return Object Function()
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
}
class WND7 extends A<Wrap<FutureOr<dynamic>>> implements B<Wrap<dynamic>> {
void test() {
var self = this;
var x = self.member()();
x.foo; // Check that member returns dynamic Function()
}
}