forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Report EXTENSION_AS_EXPRESSION, set type fo dynamic.
R=brianwilkerson@google.com Bug: dart-lang/sdk#38203 Change-Id: Iee270b7b3fecbeaba202c304f21ef703a8567674 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/116055 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
- Loading branch information
Showing
7 changed files
with
144 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
pkg/analyzer/test/src/diagnostics/extension_as_expression_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
import 'package:analyzer/dart/analysis/features.dart'; | ||
import 'package:analyzer/src/error/codes.dart'; | ||
import 'package:analyzer/src/generated/engine.dart'; | ||
import 'package:test_reflective_loader/test_reflective_loader.dart'; | ||
|
||
import '../dart/resolution/driver_resolution.dart'; | ||
|
||
main() { | ||
defineReflectiveSuite(() { | ||
defineReflectiveTests(ExtensionAsExpressionTest); | ||
}); | ||
} | ||
|
||
@reflectiveTest | ||
class ExtensionAsExpressionTest extends DriverResolutionTest { | ||
@override | ||
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl() | ||
..contextFeatures = new FeatureSet.forTesting( | ||
sdkVersion: '2.3.0', additionalFeatures: [Feature.extension_methods]); | ||
|
||
test_prefixedIdentifier() async { | ||
newFile('/test/lib/a.dart', content: r''' | ||
extension E on int {} | ||
'''); | ||
await assertErrorsInCode(''' | ||
import 'a.dart' as p; | ||
var v = p.E; | ||
''', [ | ||
error(CompileTimeErrorCode.EXTENSION_AS_EXPRESSION, 30, 3), | ||
]); | ||
assertTypeDynamic(findNode.simple('E;')); | ||
assertTypeDynamic(findNode.prefixed('p.E;')); | ||
} | ||
|
||
test_simpleIdentifier() async { | ||
await assertErrorsInCode(''' | ||
extension E on int {} | ||
var v = E; | ||
''', [ | ||
error(CompileTimeErrorCode.EXTENSION_AS_EXPRESSION, 30, 1), | ||
]); | ||
assertTypeDynamic(findNode.simple('E;')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters