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_static() { | 12756 void test_genericFunction_static() { |
12747 _resolveTestUnit(r''' | 12757 _resolveTestUnit(r''' |
12748 class C<E> { | 12758 class C<E> { |
12749 static /*=T*/ f/*<T>*/(/*=T*/ x) => null; | 12759 static /*=T*/ f/*<T>*/(/*=T*/ x) => null; |
12750 } | 12760 } |
12751 '''); | 12761 '''); |
12752 SimpleIdentifier f = _findIdentifier('f'); | 12762 SimpleIdentifier f = _findIdentifier('f'); |
12753 MethodElementImpl e = f.staticElement; | 12763 MethodElementImpl e = f.staticElement; |
12754 expect(e.typeParameters.toString(), '[T]'); | 12764 expect(e.typeParameters.toString(), '[T]'); |
12755 expect(e.type.boundTypeParameters.toString(), '[T]'); | 12765 expect(e.type.boundTypeParameters.toString(), '[T]'); |
(...skipping 3191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15947 | 15957 |
15948 void _resolveTestUnit(String code) { | 15958 void _resolveTestUnit(String code) { |
15949 testCode = code; | 15959 testCode = code; |
15950 testSource = addSource(testCode); | 15960 testSource = addSource(testCode); |
15951 LibraryElement library = resolve2(testSource); | 15961 LibraryElement library = resolve2(testSource); |
15952 assertNoErrors(testSource); | 15962 assertNoErrors(testSource); |
15953 verify([testSource]); | 15963 verify([testSource]); |
15954 testUnit = resolveCompilationUnit(testSource, library); | 15964 testUnit = resolveCompilationUnit(testSource, library); |
15955 } | 15965 } |
15956 } | 15966 } |
OLD | NEW |