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

Side by Side Diff: test/codegen/language/generic_tearoff_test.dart

Issue 1930323004: instantiate generic tear-offs, fixes #525 (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 7 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) 2016, 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 import 'dart:math' as math;
6 import 'dart:math' show min; // <-- generic: <T extends num>(T, T) -> T
7 import 'package:expect/expect.dart';
8
9 class C {
10 /*=T*/ m/*<T extends num>*/(/*=T*/ x, /*=T*/ y) => min(x, y);
11 int m2(int x, int y) => min(x, y);
12 }
13
14 typedef int Int2Int2Int(int x, int y);
15
16 void _test(Int2Int2Int f) {
17 int y = f(123, 456);
18 Expect.equals(y, 123);
19 // `f` doesn't take type args.
20 Expect.throws(() => (f as dynamic)/*<int>*/(123, 456));
21 }
22
23 void _testParam(/*=T*/ minFn/*<T extends num>*/(/*=T*/ x, /*=T*/ y)) {
24 _test(minFn);
25 }
26
27 main() {
28 // Strong mode infers: `min<int>`
29 // Test simple/prefixed identifiers and property access
30 _test(min);
31 _test(math.min);
32 _test(new C().m);
33
34 // Test local function, variable, and parameter
35 /*=T*/ m/*<T extends num>*/(/*=T*/ x, /*=T*/ y) => min(x, y);
36 _test(m);
37 final f = min;
38 _test(f);
39 _testParam(math.min);
40
41 // A few misc tests for methods
42 Expect.equals(123, (new C() as dynamic).m/*<int>*/(123, 456));
43 Expect.throws(() => (new C() as dynamic).m2/*<int>*/(123, 456));
44 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698