| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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.strong_mode_test; | 5 library analyzer.test.generated.strong_mode_test; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
| 10 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; | 10 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; |
| (...skipping 1643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1654 String code = r''' | 1654 String code = r''' |
| 1655 class A<S, T> { | 1655 class A<S, T> { |
| 1656 S s; | 1656 S s; |
| 1657 T t; | 1657 T t; |
| 1658 } | 1658 } |
| 1659 class B<S> extends A<S, S> { B(S s); } | 1659 class B<S> extends A<S, S> { B(S s); } |
| 1660 A<int, String> test() => new B(3); | 1660 A<int, String> test() => new B(3); |
| 1661 '''; | 1661 '''; |
| 1662 Source source = addSource(code); | 1662 Source source = addSource(code); |
| 1663 TestAnalysisResult analysisResult = await computeAnalysisResult(source); | 1663 TestAnalysisResult analysisResult = await computeAnalysisResult(source); |
| 1664 assertErrors(source, | 1664 assertErrors(source,[StrongModeCode.INVALID_CAST_LITERAL]); |
| 1665 [StrongModeCode.COULD_NOT_INFER, StrongModeCode.INVALID_CAST_LITERAL]); | |
| 1666 verify([source]); | 1665 verify([source]); |
| 1667 CompilationUnit unit = analysisResult.unit; | 1666 CompilationUnit unit = analysisResult.unit; |
| 1668 FunctionDeclaration test = AstFinder.getTopLevelFunction(unit, "test"); | 1667 FunctionDeclaration test = AstFinder.getTopLevelFunction(unit, "test"); |
| 1669 ExpressionFunctionBody body = test.functionExpression.body; | 1668 ExpressionFunctionBody body = test.functionExpression.body; |
| 1670 DartType type = body.expression.staticType; | 1669 DartType type = body.expression.staticType; |
| 1671 | 1670 |
| 1672 Element elementB = AstFinder.getClass(unit, "B").element; | 1671 Element elementB = AstFinder.getClass(unit, "B").element; |
| 1673 | 1672 |
| 1674 _isInstantiationOf(_hasElement(elementB))([_isNull])(type); | 1673 _isInstantiationOf(_hasElement(elementB))([_isNull])(type); |
| 1675 } | 1674 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1707 class A<S, T> { | 1706 class A<S, T> { |
| 1708 S s; | 1707 S s; |
| 1709 T t; | 1708 T t; |
| 1710 } | 1709 } |
| 1711 class B<S> extends A<S, S> { B(S s); } | 1710 class B<S> extends A<S, S> { B(S s); } |
| 1712 A<int, double> test() => new B(3); | 1711 A<int, double> test() => new B(3); |
| 1713 '''; | 1712 '''; |
| 1714 Source source = addSource(code); | 1713 Source source = addSource(code); |
| 1715 TestAnalysisResult analysisResult = await computeAnalysisResult(source); | 1714 TestAnalysisResult analysisResult = await computeAnalysisResult(source); |
| 1716 assertErrors(source, [ | 1715 assertErrors(source, [ |
| 1717 StrongModeCode.COULD_NOT_INFER, | |
| 1718 StrongModeCode.INVALID_CAST_LITERAL, | 1716 StrongModeCode.INVALID_CAST_LITERAL, |
| 1719 ]); | 1717 ]); |
| 1720 verify([source]); | 1718 verify([source]); |
| 1721 CompilationUnit unit = analysisResult.unit; | 1719 CompilationUnit unit = analysisResult.unit; |
| 1722 FunctionDeclaration test = AstFinder.getTopLevelFunction(unit, "test"); | 1720 FunctionDeclaration test = AstFinder.getTopLevelFunction(unit, "test"); |
| 1723 ExpressionFunctionBody body = test.functionExpression.body; | 1721 ExpressionFunctionBody body = test.functionExpression.body; |
| 1724 DartType type = body.expression.staticType; | 1722 DartType type = body.expression.staticType; |
| 1725 | 1723 |
| 1726 Element elementB = AstFinder.getClass(unit, "B").element; | 1724 Element elementB = AstFinder.getClass(unit, "B").element; |
| 1727 | 1725 |
| (...skipping 1889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3617 var v = x; | 3615 var v = x; |
| 3618 v; // marker | 3616 v; // marker |
| 3619 } | 3617 } |
| 3620 int x = 3; | 3618 int x = 3; |
| 3621 '''; | 3619 '''; |
| 3622 CompilationUnit unit = await resolveSource(code); | 3620 CompilationUnit unit = await resolveSource(code); |
| 3623 assertPropagatedAssignedType(code, unit, typeProvider.intType, null); | 3621 assertPropagatedAssignedType(code, unit, typeProvider.intType, null); |
| 3624 assertTypeOfMarkedExpression(code, unit, typeProvider.intType, null); | 3622 assertTypeOfMarkedExpression(code, unit, typeProvider.intType, null); |
| 3625 } | 3623 } |
| 3626 } | 3624 } |
| OLD | NEW |