Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(267)

Side by Side Diff: tests/language_strong/type_variable_conflict2_test.dart

Issue 3007803002: Migrate block 162 to Dart 2.0.
Patch Set: Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 // Regression test for issue 13134. Invocation of a type parameter.
6
7 import "package:expect/expect.dart";
8
9 class C<T> {
10 noSuchMethod(Invocation im) {
11 Expect.equals(#T, im.memberName);
12 return 42;
13 }
14
15 // Class 'C' has no instance method 'T': call noSuchMethod.
16 foo() => T(); // //# 01: static type warning
17
18 // T is in scope, even in static context. Compile-time error to call this.T().
19 static bar() => T(); // //# 02: compile-time error
20
21 // X is not in scope. NoSuchMethodError.
22 static baz() => X(); // //# 03: static type warning
23
24 // Class 'C' has no static method 'T': NoSuchMethodError.
25 static qux() => C.T(); // //# 04: static type warning
26
27 // Class '_Type' has no instance method 'call': NoSuchMethodError.
28 quux() => (T)(); // //# 05: static type warning
29
30 // Runtime type T not accessible from static context. Compile-time error.
31 static corge() => (T)(); // //# 06: compile-time error
32
33 // Class '_Type' has no [] operator: NoSuchMethodError.
34 grault() => T[0]; // //# 07: static type warning
35
36 // Runtime type T not accessible from static context. Compile-time error.
37 static garply() => T[0]; // //# 08: compile-time error
38
39 // Class '_Type' has no member m: NoSuchMethodError.
40 waldo() => T.m; // //# 09: static type warning
41
42 // Runtime type T not accessible from static context. Compile-time error.
43 static fred() => T.m; // //# 10: compile-time error
44 }
45
46 main() {
47 Expect.equals(42, new C().foo()); // //# 01: continued
48 C.bar(); // //# 02: continued
49 Expect.throws(() => C.baz(), (e) => e is NoSuchMethodError); // //# 03: contin ued
50 Expect.throws(() => C.qux(), (e) => e is NoSuchMethodError); // //# 04: contin ued
51 Expect.throws(() => new C().quux(), (e) => e is NoSuchMethodError); // //# 05: continued
52 C.corge(); // //# 06: continued
53 Expect.throws(() => new C().grault(), (e) => e is NoSuchMethodError); // //# 0 7: continued
54 C.garply(); // //# 08: continued
55 Expect.throws(() => new C().waldo(), (e) => e is NoSuchMethodError); // //# 09 : continued
56 C.fred(); // //# 10: continued
57 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698