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

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
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 expect(e.typeParameters.toString(), '[T]'); 13030 expect(e.typeParameters.toString(), '[T]');
13031 expect(e.type.boundTypeParameters.toString(), '[T]'); 13031 expect(e.type.boundTypeParameters.toString(), '[T]');
13032 expect(e.type.toString(), '<T>(T) → T'); 13032 expect(e.type.toString(), '<T>(T) → T');
13033 FunctionType ft = e.type.instantiate([typeProvider.stringType]); 13033 FunctionType ft = e.type.instantiate([typeProvider.stringType]);
13034 expect(ft.toString(), '(String) → String'); 13034 expect(ft.toString(), '(String) → String');
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
13151 '''); 13151 ''');
13152 expect(_findIdentifier('methodCall').staticType.toString(), "int"); 13152 expect(_findIdentifier('methodCall').staticType.toString(), "int");
13153 expect(_findIdentifier('staticCall').staticType.toString(), "int"); 13153 expect(_findIdentifier('staticCall').staticType.toString(), "int");
13154 expect(_findIdentifier('staticFieldCall').staticType.toString(), "int"); 13154 expect(_findIdentifier('staticFieldCall').staticType.toString(), "int");
13155 expect(_findIdentifier('topFunCall').staticType.toString(), "int"); 13155 expect(_findIdentifier('topFunCall').staticType.toString(), "int");
13156 expect(_findIdentifier('topFieldCall').staticType.toString(), "int"); 13156 expect(_findIdentifier('topFieldCall').staticType.toString(), "int");
13157 expect(_findIdentifier('localCall').staticType.toString(), "int"); 13157 expect(_findIdentifier('localCall').staticType.toString(), "int");
13158 expect(_findIdentifier('paramCall').staticType.toString(), "int"); 13158 expect(_findIdentifier('paramCall').staticType.toString(), "int");
13159 } 13159 }
13160 13160
13161 void fail_genericMethod_tearoff() { 13161 void test_genericMethod_tearoff() {
13162 _resolveTestUnit(r''' 13162 _resolveTestUnit(r'''
13163 class C<E> { 13163 class C<E> {
13164 /*=T*/ f/*<T>*/(E e) => null; 13164 /*=T*/ f/*<T>*/(E e) => null;
13165 static /*=T*/ g/*<T>*/(/*=T*/ e) => null; 13165 static /*=T*/ g/*<T>*/(/*=T*/ e) => null;
13166 static final h = g; 13166 static final h = g;
13167 } 13167 }
13168 13168
13169 /*=T*/ topF/*<T>*/(/*=T*/ e) => null; 13169 /*=T*/ topF/*<T>*/(/*=T*/ e) => null;
13170 var topG = topF; 13170 var topG = topF;
13171 void test/*<S>*/(/*=T*/ pf/*<T>*/(/*=T*/ e)) { 13171 void test/*<S>*/(/*=T*/ pf/*<T>*/(/*=T*/ e)) {
(...skipping 3421 matching lines...) Expand 10 before | Expand all | Expand 10 after
16593 16593
16594 void _resolveTestUnit(String code) { 16594 void _resolveTestUnit(String code) {
16595 testCode = code; 16595 testCode = code;
16596 testSource = addSource(testCode); 16596 testSource = addSource(testCode);
16597 LibraryElement library = resolve2(testSource); 16597 LibraryElement library = resolve2(testSource);
16598 assertNoErrors(testSource); 16598 assertNoErrors(testSource);
16599 verify([testSource]); 16599 verify([testSource]);
16600 testUnit = resolveCompilationUnit(testSource, library); 16600 testUnit = resolveCompilationUnit(testSource, library);
16601 } 16601 }
16602 } 16602 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698