OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library engine.resolver_test; | 5 library engine.resolver_test; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 | 8 |
9 import 'package:analyzer/src/context/context.dart'; | 9 import 'package:analyzer/src/context/context.dart'; |
10 import 'package:analyzer/src/generated/ast.dart'; | 10 import 'package:analyzer/src/generated/ast.dart'; |
(...skipping 12725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12736 FunctionElementImpl e = f.staticElement; | 12736 FunctionElementImpl e = f.staticElement; |
12737 expect(e.typeParameters.toString(), '[T]'); | 12737 expect(e.typeParameters.toString(), '[T]'); |
12738 expect(e.type.boundTypeParameters.toString(), '[T]'); | 12738 expect(e.type.boundTypeParameters.toString(), '[T]'); |
12739 expect(e.type.typeParameters.toString(), '[]'); | 12739 expect(e.type.typeParameters.toString(), '[]'); |
12740 expect(e.type.toString(), '<T>(T) → T'); | 12740 expect(e.type.toString(), '<T>(T) → T'); |
12741 | 12741 |
12742 FunctionType ft = e.type.instantiate([typeProvider.stringType]); | 12742 FunctionType ft = e.type.instantiate([typeProvider.stringType]); |
12743 expect(ft.toString(), '(String) → String'); | 12743 expect(ft.toString(), '(String) → String'); |
12744 } | 12744 } |
12745 | 12745 |
| 12746 void test_genericFunction_bounds() { |
| 12747 _resolveTestUnit(r'/*=T*/ f/*<T extends num>*/(/*=T*/ x) => null;'); |
| 12748 SimpleIdentifier f = _findIdentifier('f'); |
| 12749 FunctionElementImpl e = f.staticElement; |
| 12750 expect(e.typeParameters.toString(), '[T extends num]'); |
| 12751 expect(e.type.boundTypeParameters.toString(), '[T extends num]'); |
| 12752 expect(e.type.typeParameters.toString(), '[]'); |
| 12753 expect(e.type.toString(), '<T extends num>(T) → T'); |
| 12754 } |
| 12755 |
12746 void test_genericFunction_typedef() { | 12756 void test_genericFunction_typedef() { |
12747 String code = r''' | 12757 String code = r''' |
12748 typedef T F<T>(T x); | 12758 typedef T F<T>(T x); |
12749 F f0; | 12759 F f0; |
12750 | 12760 |
12751 class C { | 12761 class C { |
12752 static F f1; | 12762 static F f1; |
12753 F f2; | 12763 F f2; |
12754 void g(F f3) { | 12764 void g(F f3) { |
12755 F f4; | 12765 F f4; |
(...skipping 3170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15926 | 15936 |
15927 void _resolveTestUnit(String code) { | 15937 void _resolveTestUnit(String code) { |
15928 testCode = code; | 15938 testCode = code; |
15929 testSource = addSource(testCode); | 15939 testSource = addSource(testCode); |
15930 LibraryElement library = resolve2(testSource); | 15940 LibraryElement library = resolve2(testSource); |
15931 assertNoErrors(testSource); | 15941 assertNoErrors(testSource); |
15932 verify([testSource]); | 15942 verify([testSource]); |
15933 testUnit = resolveCompilationUnit(testSource, library); | 15943 testUnit = resolveCompilationUnit(testSource, library); |
15934 } | 15944 } |
15935 } | 15945 } |
OLD | NEW |