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

Side by Side Diff: pkg/analyzer/test/generated/resolver_test.dart

Issue 1567733002: Fix type parameter element resolution for generics (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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
« no previous file with comments | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 analyzer.test.generated.resolver_test; 5 library analyzer.test.generated.resolver_test;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/dart/element/element.dart'; 9 import 'package:analyzer/dart/element/element.dart';
10 import 'package:analyzer/dart/element/type.dart'; 10 import 'package:analyzer/dart/element/type.dart';
(...skipping 13003 matching lines...) Expand 10 before | Expand all | Expand 10 after
13014 check("f2", _isListOf(_isInt)); 13014 check("f2", _isListOf(_isInt));
13015 check("f3", _isListOf(_isListOf(_isInt))); 13015 check("f3", _isListOf(_isListOf(_isInt)));
13016 } 13016 }
13017 } 13017 }
13018 13018
13019 /** 13019 /**
13020 * Strong mode static analyzer end to end tests 13020 * Strong mode static analyzer end to end tests
13021 */ 13021 */
13022 @reflectiveTest 13022 @reflectiveTest
13023 class StrongModeStaticTypeAnalyzer2Test extends _StaticTypeAnalyzer2TestShared { 13023 class StrongModeStaticTypeAnalyzer2Test extends _StaticTypeAnalyzer2TestShared {
13024 void fail_genericFunction_parameter() { 13024 void test_genericFunction_parameter() {
13025 _resolveTestUnit(r''' 13025 _resolveTestUnit(r'''
13026 void g(/*=T*/ f/*<T>*/(/*=T*/ x)) {} 13026 void g(/*=T*/ f/*<T>*/(/*=T*/ x)) {}
13027 '''); 13027 ''');
13028 SimpleIdentifier f = _findIdentifier('f'); 13028 SimpleIdentifier f = _findIdentifier('f');
13029 ParameterElementImpl e = f.staticElement; 13029 ParameterElementImpl e = f.staticElement;
13030 FunctionType type = e.type;
13030 expect(e.typeParameters.toString(), '[T]'); 13031 expect(e.typeParameters.toString(), '[T]');
13031 expect(e.type.boundTypeParameters.toString(), '[T]'); 13032 expect(type.boundTypeParameters.toString(), '[T]');
13032 expect(e.type.toString(), '<T>(T) → T'); 13033 expect(type.toString(), '<T>(T) → T');
13033 FunctionType ft = e.type.instantiate([typeProvider.stringType]); 13034 FunctionType ft = type.instantiate([typeProvider.stringType]);
13034 expect(ft.toString(), '(String) → String'); 13035 expect(ft.toString(), '(String) → String');
13035 } 13036 }
13036 13037
13037 void fail_genericMethod_functionExpressionInvocation_explicit() { 13038 void fail_genericMethod_functionExpressionInvocation_explicit() {
13038 _resolveTestUnit(r''' 13039 _resolveTestUnit(r'''
13039 class C<E> { 13040 class C<E> {
13040 /*=T*/ f/*<T>*/(/*=T*/ e) => null; 13041 /*=T*/ f/*<T>*/(/*=T*/ e) => null;
13041 static /*=T*/ g/*<T>*/(/*=T*/ e) => null; 13042 static /*=T*/ g/*<T>*/(/*=T*/ e) => null;
13042 static final h = g; 13043 static final h = g;
13043 } 13044 }
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
13151 '''); 13152 ''');
13152 expect(_findIdentifier('methodCall').staticType.toString(), "int"); 13153 expect(_findIdentifier('methodCall').staticType.toString(), "int");
13153 expect(_findIdentifier('staticCall').staticType.toString(), "int"); 13154 expect(_findIdentifier('staticCall').staticType.toString(), "int");
13154 expect(_findIdentifier('staticFieldCall').staticType.toString(), "int"); 13155 expect(_findIdentifier('staticFieldCall').staticType.toString(), "int");
13155 expect(_findIdentifier('topFunCall').staticType.toString(), "int"); 13156 expect(_findIdentifier('topFunCall').staticType.toString(), "int");
13156 expect(_findIdentifier('topFieldCall').staticType.toString(), "int"); 13157 expect(_findIdentifier('topFieldCall').staticType.toString(), "int");
13157 expect(_findIdentifier('localCall').staticType.toString(), "int"); 13158 expect(_findIdentifier('localCall').staticType.toString(), "int");
13158 expect(_findIdentifier('paramCall').staticType.toString(), "int"); 13159 expect(_findIdentifier('paramCall').staticType.toString(), "int");
13159 } 13160 }
13160 13161
13161 void fail_genericMethod_tearoff() { 13162 void test_genericMethod_tearoff() {
13162 _resolveTestUnit(r''' 13163 _resolveTestUnit(r'''
13163 class C<E> { 13164 class C<E> {
13164 /*=T*/ f/*<T>*/(E e) => null; 13165 /*=T*/ f/*<T>*/(E e) => null;
13165 static /*=T*/ g/*<T>*/(/*=T*/ e) => null; 13166 static /*=T*/ g/*<T>*/(/*=T*/ e) => null;
13166 static final h = g; 13167 static final h = g;
13167 } 13168 }
13168 13169
13169 /*=T*/ topF/*<T>*/(/*=T*/ e) => null; 13170 /*=T*/ topF/*<T>*/(/*=T*/ e) => null;
13170 var topG = topF; 13171 var topG = topF;
13171 void test/*<S>*/(/*=T*/ pf/*<T>*/(/*=T*/ e)) { 13172 void test/*<S>*/(/*=T*/ pf/*<T>*/(/*=T*/ e)) {
(...skipping 3421 matching lines...) Expand 10 before | Expand all | Expand 10 after
16593 16594
16594 void _resolveTestUnit(String code) { 16595 void _resolveTestUnit(String code) {
16595 testCode = code; 16596 testCode = code;
16596 testSource = addSource(testCode); 16597 testSource = addSource(testCode);
16597 LibraryElement library = resolve2(testSource); 16598 LibraryElement library = resolve2(testSource);
16598 assertNoErrors(testSource); 16599 assertNoErrors(testSource);
16599 verify([testSource]); 16600 verify([testSource]);
16600 testUnit = resolveCompilationUnit(testSource, library); 16601 testUnit = resolveCompilationUnit(testSource, library);
16601 } 16602 }
16602 } 16603 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698