Add tests of instantiate to bound in method bodies

Change-Id: Ife92207a5c58e7220a5607b2d798fe40bd779f4e
Reviewed-on: https://dart-review.googlesource.com/34041
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
This commit is contained in:
Dmitry Stefantsov 2018-01-15 14:56:41 +00:00 committed by commit-bot@chromium.org
parent 10058a3600
commit 3371183b24
23 changed files with 423 additions and 0 deletions

View file

@ -0,0 +1,19 @@
// Copyright (c) 2018, 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.
// This test checks that instantiate to bound provides missing type arguments to
// raw interface types found in bodies of methods in cases where those types
// refer to classes imported from compiled dill files.
import 'dart:collection';
class A {
foo() {
LinkedListEntry bar;
}
}
main() {
LinkedListEntry bar;
}

View file

@ -0,0 +1,16 @@
library;
import self as self;
import "dart:core" as core;
import "dart:collection" as col;
class A extends core::Object {
default constructor •() → void
: super core::Object::•()
;
method foo() → dynamic {
col::LinkedListEntry<col::LinkedListEntry<dynamic>> bar;
}
}
static method main() → dynamic {
col::LinkedListEntry<col::LinkedListEntry<dynamic>> bar;
}

View file

@ -0,0 +1,19 @@
// Copyright (c) 2018, 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.
// This test checks that instantiate to bound provides type arguments to raw
// interface types that are themselves used as type arguments of literal lists
// found in method bodies.
class A<T extends num> {}
class B {
foo() {
var a = <A>[];
}
}
main() {
var a = <A>[];
}

View file

@ -0,0 +1,20 @@
library;
import self as self;
import "dart:core" as core;
class A<T extends core::num> extends core::Object {
default constructor •() → void
: super core::Object::•()
;
}
class B extends core::Object {
default constructor •() → void
: super core::Object::•()
;
method foo() → dynamic {
core::List<self::A<core::num>> a = <self::A<core::num>>[];
}
}
static method main() → dynamic {
core::List<self::A<core::num>> a = <self::A<core::num>>[];
}

View file

@ -0,0 +1,19 @@
// Copyright (c) 2018, 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.
// This test checks that instantiate to bound leaves interface types that have
// their type arguments defined by the programmer intact in cases when those
// interface types are used as type arguments of literal lists that are found in
// method bodies.
class A<T> {}
class B<U> {
fun() {
List<A<U>> foo = <A<U>>[];
List<A<num>> bar = <A<num>>[];
}
}
main() {}

View file

@ -0,0 +1,19 @@
library;
import self as self;
import "dart:core" as core;
class A<T extends core::Object> extends core::Object {
default constructor •() → void
: super core::Object::•()
;
}
class B<U extends core::Object> extends core::Object {
default constructor •() → void
: super core::Object::•()
;
method fun() → dynamic {
core::List<self::A<self::B::U>> foo = <self::A<self::B::U>>[];
core::List<self::A<core::num>> bar = <self::A<core::num>>[];
}
}
static method main() → dynamic {}

View file

@ -0,0 +1,19 @@
// Copyright (c) 2018, 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.
// This test checks that instantiate to bound provides type arguments to raw
// interface types that are themselves used as type arguments of literal maps
// found in method bodies.
class A<T extends num> {}
class B {
foo() {
var a = <A, A>{};
}
}
main() {
var a = <A, A>{};
}

View file

@ -0,0 +1,20 @@
library;
import self as self;
import "dart:core" as core;
class A<T extends core::num> extends core::Object {
default constructor •() → void
: super core::Object::•()
;
}
class B extends core::Object {
default constructor •() → void
: super core::Object::•()
;
method foo() → dynamic {
core::Map<self::A<core::num>, self::A<core::num>> a = <self::A<core::num>, self::A<core::num>>{};
}
}
static method main() → dynamic {
core::Map<self::A<core::num>, self::A<core::num>> a = <self::A<core::num>, self::A<core::num>>{};
}

View file

@ -0,0 +1,27 @@
// Copyright (c) 2018, 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.
// This test checks that instantiate to bound provides `dynamic` as the type
// argument for those positions in type argument lists of interface types that
// have the bound omitted in the corresponding type parameter, regardless of
// whether the classes that are referred to by the interface types are imported
// from compiled dill libraries or are defined within the source files being
// compiled. Only those interface types are considered in this test case that
// are found in type annotations in method bodies.
import 'dart:collection';
class A<T> {}
class C {
fun() {
A a;
DoubleLinkedQueue c;
}
}
main() {
A a;
DoubleLinkedQueue c;
}

View file

@ -0,0 +1,23 @@
library;
import self as self;
import "dart:core" as core;
import "dart:collection" as col;
class A<T extends core::Object> extends core::Object {
default constructor •() → void
: super core::Object::•()
;
}
class C extends core::Object {
default constructor •() → void
: super core::Object::•()
;
method fun() → dynamic {
self::A<dynamic> a;
col::DoubleLinkedQueue<dynamic> c;
}
}
static method main() → dynamic {
self::A<dynamic> a;
col::DoubleLinkedQueue<dynamic> c;
}

View file

@ -0,0 +1,19 @@
// Copyright (c) 2018, 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.
// This test checks that instantiate to bound produces correct super-bounded
// types from raw interface types that refer to F-bounded classes and are found
// in method bodies.
class A<T extends A<T>> {}
class B {
foo() {
A a;
}
}
main() {
A a;
}

View file

@ -0,0 +1,20 @@
library;
import self as self;
import "dart:core" as core;
class A<T extends self::A<self::A::T>> extends core::Object {
default constructor •() → void
: super core::Object::•()
;
}
class B extends core::Object {
default constructor •() → void
: super core::Object::•()
;
method foo() → dynamic {
self::A<self::A<dynamic>> a;
}
}
static method main() → dynamic {
self::A<self::A<dynamic>> a;
}

View file

@ -0,0 +1,19 @@
// Copyright (c) 2018, 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.
// This test checks that instantiate to bound provides type arguments to raw
// typedef types that are themselves used as type arguments of literal lists and
// are found in method bodies.
typedef A<T extends num>(T p);
class B {
foo() {
var a = <A>[];
}
}
main() {
var a = <A>[];
}

View file

@ -0,0 +1,16 @@
library;
import self as self;
import "dart:core" as core;
typedef A<T extends core::num> = (T) → dynamic;
class B extends core::Object {
default constructor •() → void
: super core::Object::•()
;
method foo() → dynamic {
core::List<(core::num) → dynamic> a = <(core::num) → dynamic>[];
}
}
static method main() → dynamic {
core::List<(core::num) → dynamic> a = <(core::num) → dynamic>[];
}

View file

@ -0,0 +1,21 @@
// Copyright (c) 2018, 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.
// This test checks that instantiate to bound leaves typedef types that have
// their arguments defined by the programmer intact in cases when those typedef
// types are used as type arguments of literal lists and are found in method
// bodies.
typedef A<T>(T p);
class B<U> {
fun() {
List<A<U>> foo = <A<U>>[];
List<A<num>> bar = <A<num>>[];
}
}
main() {
List<A<num>> bar = <A<num>>[];
}

View file

@ -0,0 +1,17 @@
library;
import self as self;
import "dart:core" as core;
typedef A<T extends core::Object> = (T) → dynamic;
class B<U extends core::Object> extends core::Object {
default constructor •() → void
: super core::Object::•()
;
method fun() → dynamic {
core::List<(self::B::U) → dynamic> foo = <(self::B::U) → dynamic>[];
core::List<(core::num) → dynamic> bar = <(core::num) → dynamic>[];
}
}
static method main() → dynamic {
core::List<(core::num) → dynamic> bar = <(core::num) → dynamic>[];
}

View file

@ -0,0 +1,19 @@
// Copyright (c) 2018, 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.
// This test checks that instantiate to bound provides type arguments to raw
// typedef types that are themselves used as type arguments in literal maps
// found in method bodies.
typedef A<T extends num>(T p);
class B {
foo() {
var a = <A, A>{};
}
}
main() {
var a = <A, A>{};
}

View file

@ -0,0 +1,16 @@
library;
import self as self;
import "dart:core" as core;
typedef A<T extends core::num> = (T) → dynamic;
class B extends core::Object {
default constructor •() → void
: super core::Object::•()
;
method foo() → dynamic {
core::Map<(core::num) → dynamic, (core::num) → dynamic> a = <(core::num) → dynamic, (core::num) → dynamic>{};
}
}
static method main() → dynamic {
core::Map<(core::num) → dynamic, (core::num) → dynamic> a = <(core::num) → dynamic, (core::num) → dynamic>{};
}

View file

@ -0,0 +1,20 @@
// Copyright (c) 2018, 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.
// This test checks that instantiate to bound provides `dynamic` as the type
// argument for those positions in type argument lists of typedef types that
// have the bound omitted in the corresponding type parameters. Only those
// typedef types are considered in the test that are found in method bodies.
typedef A<T>(T p);
class C {
foo() {
A a;
}
}
main() {
A a;
}

View file

@ -0,0 +1,16 @@
library;
import self as self;
import "dart:core" as core;
typedef A<T extends core::Object> = (T) → dynamic;
class C extends core::Object {
default constructor •() → void
: super core::Object::•()
;
method foo() → dynamic {
(dynamic) → dynamic a;
}
}
static method main() → dynamic {
(dynamic) → dynamic a;
}

View file

@ -0,0 +1,21 @@
// Copyright (c) 2018, 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.
// This test checks that instantiate to bound produces correct super-bounded
// types from raw typedef types that refer to F-bounded typedefs and are found
// in method bodies.
typedef A<T>(T p);
typedef B<U extends A<U>>(U p);
class C {
foo() {
B b;
}
}
main() {
B b;
}

View file

@ -0,0 +1,17 @@
library;
import self as self;
import "dart:core" as core;
typedef A<T extends core::Object> = (T) → dynamic;
typedef B<U extends (U) → dynamic> = (U) → dynamic;
class C extends core::Object {
default constructor •() → void
: super core::Object::•()
;
method foo() → dynamic {
((core::Null) → dynamic) → dynamic b;
}
}
static method main() → dynamic {
((core::Null) → dynamic) → dynamic b;
}

View file

@ -111,6 +111,7 @@ inference_new/infer_field_getter_setter_mismatch: TypeCheckError
inference_new/infer_field_override_getter_overrides_setter: TypeCheckError
instantiate_to_bound/typedef_super_bounded_type: Fail
instantiate_to_bound/body_typedef_super_bounded_type: Fail
rasta/abstract_constructor: Fail
rasta/bad_constructor_redirection: Fail