Skip to content

Commit 0c47a85

Browse files
jensjohacommit-bot@chromium.org
authored andcommitted
[CFE] Fix "Type 'void' not found." bug
Fixes #38943 Bug: 38943 Change-Id: I6086f5f46a67b37a04b21d0053fc7903a83df523 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122000 Reviewed-by: Johnni Winther <johnniwinther@google.com> Commit-Queue: Jens Johansen <jensj@google.com>
1 parent e41086e commit 0c47a85

10 files changed

+71
-11
lines changed

pkg/front_end/lib/src/fasta/builder/named_type_builder.dart

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import '../scope.dart';
3131
import '../severity.dart' show Severity;
3232

3333
import 'builder.dart';
34+
import 'builtin_type_builder.dart';
3435
import 'class_builder.dart';
3536
import 'invalid_type_declaration_builder.dart';
3637
import 'library_builder.dart';
@@ -284,7 +285,11 @@ class NamedTypeBuilder extends TypeBuilder {
284285
}
285286
NamedTypeBuilder newType =
286287
new NamedTypeBuilder(name, nullabilityBuilder, clonedArguments);
287-
newTypes.add(newType);
288+
if (declaration is BuiltinTypeBuilder) {
289+
newType.declaration = declaration;
290+
} else {
291+
newTypes.add(newType);
292+
}
288293
return newType;
289294
}
290295

pkg/front_end/testcases/general/issue38938.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
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.
4+
15
class A {
26
int v;
37
int v;

pkg/front_end/testcases/general/issue38938.dart.outline.expect

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ library;
22
//
33
// Problems in library:
44
//
5-
// pkg/front_end/testcases/general/issue38938.dart:3:7: Error: 'v' is already declared in this scope.
5+
// pkg/front_end/testcases/general/issue38938.dart:7:7: Error: 'v' is already declared in this scope.
66
// int v;
77
// ^
8-
// pkg/front_end/testcases/general/issue38938.dart:2:7: Context: Previous declaration of 'v'.
8+
// pkg/front_end/testcases/general/issue38938.dart:6:7: Context: Previous declaration of 'v'.
99
// int v;
1010
// ^
1111
//

pkg/front_end/testcases/general/issue38938.dart.strong.expect

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ library;
22
//
33
// Problems in library:
44
//
5-
// pkg/front_end/testcases/general/issue38938.dart:3:7: Error: 'v' is already declared in this scope.
5+
// pkg/front_end/testcases/general/issue38938.dart:7:7: Error: 'v' is already declared in this scope.
66
// int v;
77
// ^
8-
// pkg/front_end/testcases/general/issue38938.dart:2:7: Context: Previous declaration of 'v'.
8+
// pkg/front_end/testcases/general/issue38938.dart:6:7: Context: Previous declaration of 'v'.
99
// int v;
1010
// ^
1111
//
12-
// pkg/front_end/testcases/general/issue38938.dart:4:10: Error: Can't use 'v' because it is declared more than once.
12+
// pkg/front_end/testcases/general/issue38938.dart:8:10: Error: Can't use 'v' because it is declared more than once.
1313
// A(this.v);
1414
// ^
1515
//
@@ -19,7 +19,7 @@ import "dart:core" as core;
1919
class A extends core::Object {
2020
field core::int* v = null;
2121
constructor •(core::int* v) → self::A*
22-
: final dynamic #t1 = invalid-expression "pkg/front_end/testcases/general/issue38938.dart:4:10: Error: Can't use 'v' because it is declared more than once.
22+
: final dynamic #t1 = invalid-expression "pkg/front_end/testcases/general/issue38938.dart:8:10: Error: Can't use 'v' because it is declared more than once.
2323
A(this.v);
2424
^", super core::Object::•()
2525
;

pkg/front_end/testcases/general/issue38938.dart.strong.transformed.expect

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ library;
22
//
33
// Problems in library:
44
//
5-
// pkg/front_end/testcases/general/issue38938.dart:3:7: Error: 'v' is already declared in this scope.
5+
// pkg/front_end/testcases/general/issue38938.dart:7:7: Error: 'v' is already declared in this scope.
66
// int v;
77
// ^
8-
// pkg/front_end/testcases/general/issue38938.dart:2:7: Context: Previous declaration of 'v'.
8+
// pkg/front_end/testcases/general/issue38938.dart:6:7: Context: Previous declaration of 'v'.
99
// int v;
1010
// ^
1111
//
12-
// pkg/front_end/testcases/general/issue38938.dart:4:10: Error: Can't use 'v' because it is declared more than once.
12+
// pkg/front_end/testcases/general/issue38938.dart:8:10: Error: Can't use 'v' because it is declared more than once.
1313
// A(this.v);
1414
// ^
1515
//
@@ -19,7 +19,7 @@ import "dart:core" as core;
1919
class A extends core::Object {
2020
field core::int* v = null;
2121
constructor •(core::int* v) → self::A*
22-
: final dynamic #t1 = invalid-expression "pkg/front_end/testcases/general/issue38938.dart:4:10: Error: Can't use 'v' because it is declared more than once.
22+
: final dynamic #t1 = invalid-expression "pkg/front_end/testcases/general/issue38938.dart:8:10: Error: Can't use 'v' because it is declared more than once.
2323
A(this.v);
2424
^", super core::Object::•()
2525
;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
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.
4+
5+
class D<X extends void Function()> {
6+
factory D.foo() => new D._();
7+
D._() {}
8+
}
9+
10+
main() {
11+
print(new D.foo());
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
library;
2+
import self as self;
3+
import "dart:core" as core;
4+
5+
class D<X extends () →* void = () →* void> extends core::Object {
6+
constructor _() → self::D<self::D::X*>*
7+
;
8+
static factory foo<X extends () →* void = dynamic>() → self::D<self::D::foo::X*>*
9+
;
10+
}
11+
static method main() → dynamic
12+
;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
library;
2+
import self as self;
3+
import "dart:core" as core;
4+
5+
class D<X extends () →* void = () →* void> extends core::Object {
6+
constructor _() → self::D<self::D::X*>*
7+
: super core::Object::•() {}
8+
static factory foo<X extends () →* void = dynamic>() → self::D<self::D::foo::X*>*
9+
return new self::D::_<self::D::foo::X*>();
10+
}
11+
static method main() → dynamic {
12+
core::print(self::D::foo<() →* void>());
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
library;
2+
import self as self;
3+
import "dart:core" as core;
4+
5+
class D<X extends () →* void = () →* void> extends core::Object {
6+
constructor _() → self::D<self::D::X*>*
7+
: super core::Object::•() {}
8+
static factory foo<X extends () →* void = dynamic>() → self::D<self::D::foo::X*>*
9+
return new self::D::_<self::D::foo::X*>();
10+
}
11+
static method main() → dynamic {
12+
core::print(self::D::foo<() →* void>());
13+
}

pkg/front_end/testcases/text_serialization.status

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ general/issue37381: TextSerializationFailure
202202
general/issue37776: TextSerializationFailure
203203
general/issue38812: TextSerializationFailure
204204
general/issue38938: TextSerializationFailure
205+
general/issue38943: TextSerializationFailure
205206
general/literals: TextSerializationFailure # Was: Pass
206207
general/local_generic_function: TextSerializationFailure # Was: Pass
207208
general/magic_const: TextSerializationFailure # Was: Pass

0 commit comments

Comments
 (0)