| 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_static() { |
| 12747 _resolveTestUnit(r''' |
| 12748 class C<E> { |
| 12749 static /*=T*/ f/*<T>*/(/*=T*/ x) => null; |
| 12750 } |
| 12751 '''); |
| 12752 SimpleIdentifier f = _findIdentifier('f'); |
| 12753 MethodElementImpl e = f.staticElement; |
| 12754 expect(e.typeParameters.toString(), '[T]'); |
| 12755 expect(e.type.boundTypeParameters.toString(), '[T]'); |
| 12756 // TODO(jmesserly): we could get rid of this {E/E} substitution, but it's |
| 12757 // probably harmless, as E won't be used in the function (error verifier |
| 12758 // checks this), and {E/E} is a no-op anyway. |
| 12759 expect(e.type.typeParameters.toString(), '[E]'); |
| 12760 expect(e.type.typeArguments.toString(), '[E]'); |
| 12761 expect(e.type.toString(), '<T>(T) → T'); |
| 12762 |
| 12763 FunctionType ft = e.type.instantiate([typeProvider.stringType]); |
| 12764 expect(ft.toString(), '(String) → String'); |
| 12765 } |
| 12766 |
| 12746 void test_genericFunction_typedef() { | 12767 void test_genericFunction_typedef() { |
| 12747 String code = r''' | 12768 String code = r''' |
| 12748 typedef T F<T>(T x); | 12769 typedef T F<T>(T x); |
| 12749 F f0; | 12770 F f0; |
| 12750 | 12771 |
| 12751 class C { | 12772 class C { |
| 12752 static F f1; | 12773 static F f1; |
| 12753 F f2; | 12774 F f2; |
| 12754 void g(F f3) { | 12775 void g(F f3) { |
| 12755 F f4; | 12776 F f4; |
| (...skipping 3170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15926 | 15947 |
| 15927 void _resolveTestUnit(String code) { | 15948 void _resolveTestUnit(String code) { |
| 15928 testCode = code; | 15949 testCode = code; |
| 15929 testSource = addSource(testCode); | 15950 testSource = addSource(testCode); |
| 15930 LibraryElement library = resolve2(testSource); | 15951 LibraryElement library = resolve2(testSource); |
| 15931 assertNoErrors(testSource); | 15952 assertNoErrors(testSource); |
| 15932 verify([testSource]); | 15953 verify([testSource]); |
| 15933 testUnit = resolveCompilationUnit(testSource, library); | 15954 testUnit = resolveCompilationUnit(testSource, library); |
| 15934 } | 15955 } |
| 15935 } | 15956 } |
| OLD | NEW |