Skip to content

Commit 40d72ae

Browse files
stereotype441commit-bot@chromium.org
authored andcommitted
Re-land "Fix analyzer/FE integration of assignments to ambiguous types."
This reverts commit 9f79588. Change-Id: I485d0722fe8651212660dc961ae9271045ee0c54 Reviewed-on: https://dart-review.googlesource.com/71100 Reviewed-by: Konstantin Shcheglov <[email protected]> Commit-Queue: Paul Berry <[email protected]>
1 parent 9ef53bd commit 40d72ae

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

pkg/analyzer/test/src/dart/analysis/driver_resolution_test.dart

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -903,6 +903,23 @@ void f(num x, int y) {
903903
assertElement(yRef, findElement.parameter('y'));
904904
}
905905

906+
test_assign_to_ambiguous_type() async {
907+
provider.newFile(_p('/test/lib/a.dart'), 'class C {}');
908+
provider.newFile(_p('/test/lib/b.dart'), 'class C {}');
909+
addTestFile('''
910+
import 'a.dart';
911+
import 'b.dart';
912+
void f(int x) {
913+
C = x;
914+
}
915+
''');
916+
await resolveTestFile();
917+
918+
var xRef = findNode.simple('x;');
919+
assertType(xRef, 'int');
920+
assertElement(xRef, findElement.parameter('x'));
921+
}
922+
906923
test_assign_to_class() async {
907924
addTestFile('''
908925
class C {}

pkg/front_end/lib/src/fasta/kernel/kernel_expression_generator.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,9 +1332,11 @@ class KernelTypeUseGenerator extends KernelReadOnlyAccessGenerator
13321332
helper.addProblemErrorIfConst(
13331333
declaration.message.messageObject, offset, token.length);
13341334
}
1335-
return new SyntheticExpressionJudgment(
1335+
return new UnresolvedVariableGetJudgment(
13361336
new Throw(forest.literalString(declaration.message.message, token))
1337-
..fileOffset = offset);
1337+
..fileOffset = offset,
1338+
token.isSynthetic)
1339+
..fileOffset = offset;
13381340
} else {
13391341
return forest.literalType(
13401342
buildTypeWithBuiltArguments(null, nonInstanceAccessIsError: true),

tests/language_2/language_2_analyzer.status

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ issue31596_super_test/01: CompileTimeError # Front end fails to skip forwarding
155155
issue31596_super_test/03: CompileTimeError # Front end fails to skip forwarding stubs when resolving super calls
156156
label5_test/01: Crash # Error recovery in method body (illegal jump target)
157157
label6_test/03: Crash # Error recovery in method body (illegal jump target)
158-
library_ambiguous_test/00: Crash # Error recovery in method body (ambiguous imported name)
159158
library_test/01: Crash # Issue 33686 - No core library found
160159
list_literal_negative_test: Crash # Error recovery in method body (malformed constructor invocation)
161160
list_literal_syntax_test/06: Crash
@@ -251,7 +250,6 @@ parameter_metadata_test/04: Crash # Poor handling of annotation inside function-
251250
parser_quirks_test: CompileTimeError # Issue 34047
252251
part_of_multiple_libs_test/01: Crash # Poor handling of part file used by multiple libs
253252
part_refers_to_core_library_test/01: Crash # Issue 33686 - No core library found
254-
prefix_import_collision_test/01: Crash # Error recovery in method body (ambiguous imported name)
255253
prefix_shadow_test/01: Crash # Error recovery in method body (attempt to use type variable as prefix)
256254
prefix_variable_collision_test/01: Crash # Issue 33686 - No core library found
257255
regress_20394_test/01: Crash # Error recovery in method body (error in super constructor call)

0 commit comments

Comments
 (0)