809d8a778a
We still have `late ResolvedUnitResultImpl result` for now, but many tests migrated to explicit `TestResolvedUnitResult` and its getters. Start migrating analyzer resolution tests away from the implicit ResolutionTest state. Store the TestResolvedUnitResult returned by resolve helpers in local variables, then read nodes and elements through that result. Update helper methods to take the resolved result explicitly when they need access to findNode or findElement. Also return resolved results from small wrapper helpers so their callers do not have to depend on shared state. This keeps each test tied to the unit it resolved and prepares the test harness for removing the remaining stored resolution result. Change-Id: I5e9331fb574d962473e5d36922107f674d7340cc Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/505621 SLSA-Policy-Verified: SLSA Policy Verification Service <devtools-gerritcodereview-exitgate@google.com> Reviewed-by: Johnni Winther <johnniwinther@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
54 lines
1.4 KiB
Dart
54 lines
1.4 KiB
Dart
// 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:test_reflective_loader/test_reflective_loader.dart';
|
|
|
|
import '../src/dart/resolution/context_collection_resolution.dart';
|
|
|
|
main() {
|
|
defineReflectiveSuite(() {
|
|
defineReflectiveTests(IssuesTest);
|
|
});
|
|
}
|
|
|
|
/// Tests for various end-to-end cases reported as user issues, where it is
|
|
/// not obvious where to put the test otherwise.
|
|
@reflectiveTest
|
|
class IssuesTest extends PubPackageResolutionTest {
|
|
/// https://github.com/dart-lang/sdk/issues/38565
|
|
///
|
|
/// The issue was that type inference for annotation instantiation
|
|
/// was done incorrectly, without resolving arguments to the annotation
|
|
/// constructor. So, we were trying to perform type inference using null
|
|
/// types of arguments.
|
|
test_issue38565() async {
|
|
await resolveTestCode('''
|
|
class A<T> {
|
|
const A(int a);
|
|
}
|
|
|
|
class C {
|
|
@A(0)
|
|
int field;
|
|
}
|
|
''');
|
|
// Should not crash.
|
|
}
|
|
|
|
/// https://github.com/dart-lang/sdk/issues/38589
|
|
test_issue38589() async {
|
|
var result = await resolveTestCode('''
|
|
mixin M {}
|
|
|
|
class A implements M {}
|
|
|
|
class B implements M {}
|
|
|
|
var b = true;
|
|
var c = b ? A() : B();
|
|
''');
|
|
assertType(result.findElement.topVar('c').type, 'M');
|
|
}
|
|
}
|