Fix crash with multiple same-named redirecting constructors
Without this CL we end up putting a null-reference in the tree because
the parent is never set on the redirecting constructor we try pointing
to.
Fixes #35259, #35260.
Change-Id: I8ad520453742ff1de8dd9ca5e619f9edbff9971c
Reviewed-on: https://dart-review.googlesource.com/c/85384
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
diff --git a/pkg/front_end/lib/src/fasta/dill/dill_class_builder.dart b/pkg/front_end/lib/src/fasta/dill/dill_class_builder.dart
index 5febe96..fb395c3 100644
--- a/pkg/front_end/lib/src/fasta/dill/dill_class_builder.dart
+++ b/pkg/front_end/lib/src/fasta/dill/dill_class_builder.dart
@@ -36,7 +36,7 @@
null,
new Scope(<String, MemberBuilder>{}, <String, MemberBuilder>{},
parent.scope, "class ${cls.name}", isModifiable: false),
- new Scope(<String, MemberBuilder>{}, null, null, "constructors",
+ new Scope(<String, MemberBuilder>{}, null, null, cls.name,
isModifiable: false),
parent,
cls.fileOffset);
diff --git a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
index 8d44dc6..7507a99 100644
--- a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
@@ -3289,6 +3289,7 @@
}
String errorName;
+ LocatedMessage message;
if (type is ClassBuilder<TypeBuilder, Object>) {
if (type is EnumBuilder<TypeBuilder, Object>) {
return buildProblem(fasta.messageEnumInstantiation,
@@ -3299,6 +3300,8 @@
Member target = b?.target;
if (b == null) {
// Not found. Reported below.
+ } else if (b is ProblemBuilder) {
+ message = b.message.withLocation(uri, charOffset, noLength);
} else if (b.isConstructor) {
if (type.isAbstract) {
return new InvalidConstructorInvocationJudgment(
@@ -3362,7 +3365,8 @@
forest.literalNull(null)..fileOffset = charOffset,
errorName,
arguments,
- nameLastToken.charOffset),
+ nameLastToken.charOffset,
+ message: message),
arguments)
..fileOffset = arguments.fileOffset;
}
diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_class_builder.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_class_builder.dart
index 96511e2a4..0c866f4 100644
--- a/pkg/front_end/lib/src/fasta/kernel/kernel_class_builder.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/kernel_class_builder.dart
@@ -416,58 +416,67 @@
List<String> names = constructors.keys.toList();
for (String name in names) {
Declaration declaration = constructors[name];
- if (declaration.parent != this) {
- unexpected(
- "$fileUri", "${declaration.parent.fileUri}", charOffset, fileUri);
- }
- if (declaration is KernelRedirectingFactoryBuilder) {
- // Compute the immediate redirection target, not the effective.
- ConstructorReferenceBuilder redirectionTarget =
- declaration.redirectionTarget;
- if (redirectionTarget != null) {
- Declaration targetBuilder = redirectionTarget.target;
- addRedirectingConstructor(declaration, library);
- if (targetBuilder is ProcedureBuilder) {
- List<DartType> typeArguments = declaration.typeArguments;
- if (typeArguments == null) {
- // TODO(32049) If type arguments aren't specified, they should
- // be inferred. Currently, the inference is not performed.
- // The code below is a workaround.
- typeArguments = new List<DartType>.filled(
- targetBuilder.target.enclosingClass.typeParameters.length,
- const DynamicType(),
- growable: true);
+ do {
+ if (declaration.parent != this) {
+ unexpected("$fileUri", "${declaration.parent.fileUri}", charOffset,
+ fileUri);
+ }
+ if (declaration is KernelRedirectingFactoryBuilder) {
+ // Compute the immediate redirection target, not the effective.
+ ConstructorReferenceBuilder redirectionTarget =
+ declaration.redirectionTarget;
+ if (redirectionTarget != null) {
+ Declaration targetBuilder = redirectionTarget.target;
+ if (declaration.next == null) {
+ // Only the first one (that is, the last on in the linked list)
+ // is actually in the kernel tree. This call creates a StaticGet
+ // to [declaration.target] in a field `_redirecting#` which is
+ // only legal to do to things in the kernel tree.
+ addRedirectingConstructor(declaration, library);
}
- declaration.setRedirectingFactoryBody(
- targetBuilder.target, typeArguments);
- } else if (targetBuilder is DillMemberBuilder) {
- List<DartType> typeArguments = declaration.typeArguments;
- if (typeArguments == null) {
- // TODO(32049) If type arguments aren't specified, they should
- // be inferred. Currently, the inference is not performed.
- // The code below is a workaround.
- typeArguments = new List<DartType>.filled(
- targetBuilder.target.enclosingClass.typeParameters.length,
- const DynamicType(),
- growable: true);
- }
- declaration.setRedirectingFactoryBody(
- targetBuilder.member, typeArguments);
- } else {
- Message message = templateRedirectionTargetNotFound
- .withArguments(redirectionTarget.fullNameForErrors);
- if (declaration.isConst) {
- addProblem(message, declaration.charOffset, noLength);
+ if (targetBuilder is ProcedureBuilder) {
+ List<DartType> typeArguments = declaration.typeArguments;
+ if (typeArguments == null) {
+ // TODO(32049) If type arguments aren't specified, they should
+ // be inferred. Currently, the inference is not performed.
+ // The code below is a workaround.
+ typeArguments = new List<DartType>.filled(
+ targetBuilder.target.enclosingClass.typeParameters.length,
+ const DynamicType(),
+ growable: true);
+ }
+ declaration.setRedirectingFactoryBody(
+ targetBuilder.target, typeArguments);
+ } else if (targetBuilder is DillMemberBuilder) {
+ List<DartType> typeArguments = declaration.typeArguments;
+ if (typeArguments == null) {
+ // TODO(32049) If type arguments aren't specified, they should
+ // be inferred. Currently, the inference is not performed.
+ // The code below is a workaround.
+ typeArguments = new List<DartType>.filled(
+ targetBuilder.target.enclosingClass.typeParameters.length,
+ const DynamicType(),
+ growable: true);
+ }
+ declaration.setRedirectingFactoryBody(
+ targetBuilder.member, typeArguments);
} else {
- addProblem(message, declaration.charOffset, noLength);
+ Message message = templateRedirectionTargetNotFound
+ .withArguments(redirectionTarget.fullNameForErrors);
+ if (declaration.isConst) {
+ addProblem(message, declaration.charOffset, noLength);
+ } else {
+ addProblem(message, declaration.charOffset, noLength);
+ }
+ // CoreTypes aren't computed yet, and this is the outline
+ // phase. So we can't and shouldn't create a method body.
+ declaration.body = new RedirectingFactoryBody.unresolved(
+ redirectionTarget.fullNameForErrors);
}
- // CoreTypes aren't computed yet, and this is the outline
- // phase. So we can't and shouldn't create a method body.
- declaration.body = new RedirectingFactoryBody.unresolved(
- redirectionTarget.fullNameForErrors);
}
}
- }
+ declaration = declaration.next;
+ } while (declaration != null);
}
}
return count;
@@ -1719,9 +1728,12 @@
Iterable<String> names = constructors.keys;
for (String name in names) {
Declaration constructor = constructors[name];
- if (constructor is KernelRedirectingFactoryBuilder) {
- checkRedirectingFactory(constructor, typeEnvironment);
- }
+ do {
+ if (constructor is KernelRedirectingFactoryBuilder) {
+ checkRedirectingFactory(constructor, typeEnvironment);
+ }
+ constructor = constructor.next;
+ } while (constructor != null);
}
}
diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_enum_builder.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_enum_builder.dart
index ba576ed..7491a7c 100644
--- a/pkg/front_end/lib/src/fasta/kernel/kernel_enum_builder.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/kernel_enum_builder.dart
@@ -222,8 +222,7 @@
name,
new Scope(members, null, parent.scope, "enum $name",
isModifiable: false),
- new Scope(constructors, null, null, "constructors",
- isModifiable: false),
+ new Scope(constructors, null, null, name, isModifiable: false),
cls,
enumConstantInfos,
intType,
diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_library_builder.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_library_builder.dart
index 15368bc..8b7bbe5 100644
--- a/pkg/front_end/lib/src/fasta/kernel/kernel_library_builder.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/kernel_library_builder.dart
@@ -251,8 +251,8 @@
// When looking up a constructor, we don't consider type variables or the
// library scope.
- Scope constructorScope = new Scope(constructors, null, null, "constructors",
- isModifiable: false);
+ Scope constructorScope =
+ new Scope(constructors, null, null, className, isModifiable: false);
bool isMixinDeclaration = false;
if (modifiers & mixinDeclarationMask != 0) {
isMixinDeclaration = true;
@@ -531,7 +531,7 @@
new Scope(<String, MemberBuilder>{}, <String, MemberBuilder>{},
scope.withTypeVariables(typeVariables),
"mixin $fullname ", isModifiable: false),
- new Scope(<String, MemberBuilder>{}, null, null, "constructors",
+ new Scope(<String, MemberBuilder>{}, null, null, fullname,
isModifiable: false),
this,
<ConstructorReferenceBuilder>[],
diff --git a/pkg/front_end/lib/src/fasta/scope.dart b/pkg/front_end/lib/src/fasta/scope.dart
index a8d2025..6abbc4f 100644
--- a/pkg/front_end/lib/src/fasta/scope.dart
+++ b/pkg/front_end/lib/src/fasta/scope.dart
@@ -28,13 +28,14 @@
/// level scope.
Scope parent;
- final String debugName;
+ final String classNameOrDebugName;
- MutableScope(this.local, this.setters, this.parent, this.debugName) {
- assert(debugName != null);
+ MutableScope(
+ this.local, this.setters, this.parent, this.classNameOrDebugName) {
+ assert(classNameOrDebugName != null);
}
- String toString() => "Scope($debugName, ${local.keys})";
+ String toString() => "Scope($classNameOrDebugName, ${local.keys})";
}
class Scope extends MutableScope {
@@ -128,7 +129,8 @@
Declaration builder = map[name];
if (builder == null) return null;
if (builder.next != null) {
- return new AmbiguousBuilder(name, builder, charOffset, fileUri);
+ return new AmbiguousBuilder(name.isEmpty ? classNameOrDebugName : name,
+ builder, charOffset, fileUri);
} else if (!isInstanceScope && builder.isInstanceMember) {
return null;
} else {
diff --git a/pkg/front_end/testcases/legacy.status b/pkg/front_end/testcases/legacy.status
index 6fec1c8..42f9157 100644
--- a/pkg/front_end/testcases/legacy.status
+++ b/pkg/front_end/testcases/legacy.status
@@ -107,6 +107,8 @@
regress/issue_34225: RuntimeError
regress/issue_34563: RuntimeError # Test execution after recovery
regress/issue_35177: RuntimeError
+regress/issue_35259: RuntimeError # Expected
+regress/issue_35260: RuntimeError # Expected
runtime_checks/implicit_downcast_constructor_initializer: RuntimeError # Test exercises strong mode semantics
runtime_checks/implicit_downcast_do: RuntimeError # Test exercises strong mode semantics
runtime_checks/implicit_downcast_for_condition: RuntimeError # Test exercises strong mode semantics
diff --git a/pkg/front_end/testcases/regress/issue_35259.dart b/pkg/front_end/testcases/regress/issue_35259.dart
new file mode 100644
index 0000000..10246aa
--- /dev/null
+++ b/pkg/front_end/testcases/regress/issue_35259.dart
@@ -0,0 +1,12 @@
+// Copyright (c) 2018, 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.
+
+class Supertype {
+ factory Supertype() = Unresolved;
+ factory Supertype() = Unresolved;
+}
+
+main() {
+ print(new Supertype());
+}
diff --git a/pkg/front_end/testcases/regress/issue_35259.dart.legacy.expect b/pkg/front_end/testcases/regress/issue_35259.dart.legacy.expect
new file mode 100644
index 0000000..37d28a6
--- /dev/null
+++ b/pkg/front_end/testcases/regress/issue_35259.dart.legacy.expect
@@ -0,0 +1,47 @@
+// Formatted problems:
+//
+// pkg/front_end/testcases/regress/issue_35259.dart:7:11: Error: 'Supertype' is already declared in this scope.
+// factory Supertype() = Unresolved;
+// ^^^^^^^^^
+// pkg/front_end/testcases/regress/issue_35259.dart:6:11: Context: Previous declaration of 'Supertype'.
+// factory Supertype() = Unresolved;
+// ^^^^^^^^^
+//
+// pkg/front_end/testcases/regress/issue_35259.dart:6:25: Warning: Couldn't find constructor 'Unresolved'.
+// factory Supertype() = Unresolved;
+// ^
+//
+// pkg/front_end/testcases/regress/issue_35259.dart:7:25: Warning: Couldn't find constructor 'Unresolved'.
+// factory Supertype() = Unresolved;
+// ^
+//
+// pkg/front_end/testcases/regress/issue_35259.dart:7:11: Warning: Redirection constructor target not found: 'Unresolved'
+// factory Supertype() = Unresolved;
+// ^
+//
+// pkg/front_end/testcases/regress/issue_35259.dart:6:11: Warning: Redirection constructor target not found: 'Unresolved'
+// factory Supertype() = Unresolved;
+// ^
+//
+// pkg/front_end/testcases/regress/issue_35259.dart:11:13: Error: Can't use 'Supertype' because it is declared more than once.
+// print(new Supertype());
+// ^
+
+// Unhandled errors:
+//
+// pkg/front_end/testcases/regress/issue_35259.dart:7:11: Error: 'Supertype' is already declared in this scope.
+// factory Supertype() = Unresolved;
+// ^^^^^^^^^
+
+library;
+import self as self;
+import "dart:core" as core;
+
+class Supertype extends core::Object {
+ static field dynamic _redirecting# = <dynamic>[self::Supertype::•];
+ static factory •() → self::Supertype
+ let dynamic #redirecting_factory = "Unresolved" in invalid-expression;
+}
+static method main() → dynamic {
+ core::print(let dynamic _ = null in throw new core::NoSuchMethodError::withInvocation(null, new core::_InvocationMirror::_withType(#Supertype, 32, const <core::Type>[], const <dynamic>[], core::Map::unmodifiable<core::Symbol, dynamic>(const <core::Symbol, dynamic>{}))));
+}
diff --git a/pkg/front_end/testcases/regress/issue_35259.dart.legacy.transformed.expect b/pkg/front_end/testcases/regress/issue_35259.dart.legacy.transformed.expect
new file mode 100644
index 0000000..263531d
--- /dev/null
+++ b/pkg/front_end/testcases/regress/issue_35259.dart.legacy.transformed.expect
@@ -0,0 +1,18 @@
+// Unhandled errors:
+//
+// pkg/front_end/testcases/regress/issue_35259.dart:7:11: Error: 'Supertype' is already declared in this scope.
+// factory Supertype() = Unresolved;
+// ^^^^^^^^^
+
+library;
+import self as self;
+import "dart:core" as core;
+
+class Supertype extends core::Object {
+ static field dynamic _redirecting# = <dynamic>[self::Supertype::•];
+ static factory •() → self::Supertype
+ let dynamic #redirecting_factory = "Unresolved" in invalid-expression;
+}
+static method main() → dynamic {
+ core::print(let dynamic _ = null in throw new core::NoSuchMethodError::withInvocation(null, new core::_InvocationMirror::_withType(#Supertype, 32, const <core::Type>[], const <dynamic>[], core::Map::unmodifiable<core::Symbol, dynamic>(const <core::Symbol, dynamic>{}))));
+}
diff --git a/pkg/front_end/testcases/regress/issue_35259.dart.outline.expect b/pkg/front_end/testcases/regress/issue_35259.dart.outline.expect
new file mode 100644
index 0000000..93650ba
--- /dev/null
+++ b/pkg/front_end/testcases/regress/issue_35259.dart.outline.expect
@@ -0,0 +1,36 @@
+// Formatted problems:
+//
+// pkg/front_end/testcases/regress/issue_35259.dart:7:11: Error: 'Supertype' is already declared in this scope.
+// factory Supertype() = Unresolved;
+// ^^^^^^^^^
+// pkg/front_end/testcases/regress/issue_35259.dart:6:11: Context: Previous declaration of 'Supertype'.
+// factory Supertype() = Unresolved;
+// ^^^^^^^^^
+//
+// pkg/front_end/testcases/regress/issue_35259.dart:6:25: Warning: Couldn't find constructor 'Unresolved'.
+// factory Supertype() = Unresolved;
+// ^
+//
+// pkg/front_end/testcases/regress/issue_35259.dart:7:25: Warning: Couldn't find constructor 'Unresolved'.
+// factory Supertype() = Unresolved;
+// ^
+//
+// pkg/front_end/testcases/regress/issue_35259.dart:7:11: Warning: Redirection constructor target not found: 'Unresolved'
+// factory Supertype() = Unresolved;
+// ^
+//
+// pkg/front_end/testcases/regress/issue_35259.dart:6:11: Warning: Redirection constructor target not found: 'Unresolved'
+// factory Supertype() = Unresolved;
+// ^
+
+library;
+import self as self;
+import "dart:core" as core;
+
+class Supertype extends core::Object {
+ static field dynamic _redirecting# = <dynamic>[self::Supertype::•];
+ static factory •() → self::Supertype
+ let dynamic #redirecting_factory = "Unresolved" in invalid-expression;
+}
+static method main() → dynamic
+ ;
diff --git a/pkg/front_end/testcases/regress/issue_35259.dart.strong.expect b/pkg/front_end/testcases/regress/issue_35259.dart.strong.expect
new file mode 100644
index 0000000..c803a06
--- /dev/null
+++ b/pkg/front_end/testcases/regress/issue_35259.dart.strong.expect
@@ -0,0 +1,65 @@
+// Formatted problems:
+//
+// pkg/front_end/testcases/regress/issue_35259.dart:7:11: Error: 'Supertype' is already declared in this scope.
+// factory Supertype() = Unresolved;
+// ^^^^^^^^^
+// pkg/front_end/testcases/regress/issue_35259.dart:6:11: Context: Previous declaration of 'Supertype'.
+// factory Supertype() = Unresolved;
+// ^^^^^^^^^
+//
+// pkg/front_end/testcases/regress/issue_35259.dart:6:25: Error: Couldn't find constructor 'Unresolved'.
+// factory Supertype() = Unresolved;
+// ^
+//
+// pkg/front_end/testcases/regress/issue_35259.dart:7:25: Error: Couldn't find constructor 'Unresolved'.
+// factory Supertype() = Unresolved;
+// ^
+//
+// pkg/front_end/testcases/regress/issue_35259.dart:7:11: Error: Redirection constructor target not found: 'Unresolved'
+// factory Supertype() = Unresolved;
+// ^
+//
+// pkg/front_end/testcases/regress/issue_35259.dart:6:11: Error: Redirection constructor target not found: 'Unresolved'
+// factory Supertype() = Unresolved;
+// ^
+//
+// pkg/front_end/testcases/regress/issue_35259.dart:11:13: Error: Can't use 'Supertype' because it is declared more than once.
+// print(new Supertype());
+// ^
+
+// Unhandled errors:
+//
+// pkg/front_end/testcases/regress/issue_35259.dart:7:11: Error: 'Supertype' is already declared in this scope.
+// factory Supertype() = Unresolved;
+// ^^^^^^^^^
+//
+// pkg/front_end/testcases/regress/issue_35259.dart:6:25: Error: Couldn't find constructor 'Unresolved'.
+// factory Supertype() = Unresolved;
+// ^
+//
+// pkg/front_end/testcases/regress/issue_35259.dart:7:25: Error: Couldn't find constructor 'Unresolved'.
+// factory Supertype() = Unresolved;
+// ^
+//
+// pkg/front_end/testcases/regress/issue_35259.dart:7:11: Error: Redirection constructor target not found: 'Unresolved'
+// factory Supertype() = Unresolved;
+// ^
+//
+// pkg/front_end/testcases/regress/issue_35259.dart:6:11: Error: Redirection constructor target not found: 'Unresolved'
+// factory Supertype() = Unresolved;
+// ^
+
+library;
+import self as self;
+import "dart:core" as core;
+
+class Supertype extends core::Object {
+ static field dynamic _redirecting# = <dynamic>[self::Supertype::•];
+ static factory •() → self::Supertype
+ let dynamic #redirecting_factory = "Unresolved" in invalid-expression;
+}
+static method main() → dynamic {
+ core::print(invalid-expression "pkg/front_end/testcases/regress/issue_35259.dart:11:13: Error: Can't use 'Supertype' because it is declared more than once.
+ print(new Supertype());
+ ^");
+}
diff --git a/pkg/front_end/testcases/regress/issue_35259.dart.strong.transformed.expect b/pkg/front_end/testcases/regress/issue_35259.dart.strong.transformed.expect
new file mode 100644
index 0000000..ff84c51
--- /dev/null
+++ b/pkg/front_end/testcases/regress/issue_35259.dart.strong.transformed.expect
@@ -0,0 +1,36 @@
+// Unhandled errors:
+//
+// pkg/front_end/testcases/regress/issue_35259.dart:7:11: Error: 'Supertype' is already declared in this scope.
+// factory Supertype() = Unresolved;
+// ^^^^^^^^^
+//
+// pkg/front_end/testcases/regress/issue_35259.dart:6:25: Error: Couldn't find constructor 'Unresolved'.
+// factory Supertype() = Unresolved;
+// ^
+//
+// pkg/front_end/testcases/regress/issue_35259.dart:7:25: Error: Couldn't find constructor 'Unresolved'.
+// factory Supertype() = Unresolved;
+// ^
+//
+// pkg/front_end/testcases/regress/issue_35259.dart:7:11: Error: Redirection constructor target not found: 'Unresolved'
+// factory Supertype() = Unresolved;
+// ^
+//
+// pkg/front_end/testcases/regress/issue_35259.dart:6:11: Error: Redirection constructor target not found: 'Unresolved'
+// factory Supertype() = Unresolved;
+// ^
+
+library;
+import self as self;
+import "dart:core" as core;
+
+class Supertype extends core::Object {
+ static field dynamic _redirecting# = <dynamic>[self::Supertype::•];
+ static factory •() → self::Supertype
+ let core::String #redirecting_factory = "Unresolved" in invalid-expression;
+}
+static method main() → dynamic {
+ core::print(invalid-expression "pkg/front_end/testcases/regress/issue_35259.dart:11:13: Error: Can't use 'Supertype' because it is declared more than once.
+ print(new Supertype());
+ ^");
+}
diff --git a/pkg/front_end/testcases/regress/issue_35260.dart b/pkg/front_end/testcases/regress/issue_35260.dart
new file mode 100644
index 0000000..ab79fbe
--- /dev/null
+++ b/pkg/front_end/testcases/regress/issue_35260.dart
@@ -0,0 +1,16 @@
+// Copyright (c) 2018, 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.
+
+class Supertype {
+ factory Supertype() = X;
+ factory Supertype() = X;
+}
+
+class X implements Supertype {
+ X();
+}
+
+main() {
+ X x = new Supertype();
+}
diff --git a/pkg/front_end/testcases/regress/issue_35260.dart.legacy.expect b/pkg/front_end/testcases/regress/issue_35260.dart.legacy.expect
new file mode 100644
index 0000000..87975f8
--- /dev/null
+++ b/pkg/front_end/testcases/regress/issue_35260.dart.legacy.expect
@@ -0,0 +1,36 @@
+// Formatted problems:
+//
+// pkg/front_end/testcases/regress/issue_35260.dart:7:11: Error: 'Supertype' is already declared in this scope.
+// factory Supertype() = X;
+// ^^^^^^^^^
+// pkg/front_end/testcases/regress/issue_35260.dart:6:11: Context: Previous declaration of 'Supertype'.
+// factory Supertype() = X;
+// ^^^^^^^^^
+//
+// pkg/front_end/testcases/regress/issue_35260.dart:15:13: Error: Can't use 'Supertype' because it is declared more than once.
+// X x = new Supertype();
+// ^
+
+// Unhandled errors:
+//
+// pkg/front_end/testcases/regress/issue_35260.dart:7:11: Error: 'Supertype' is already declared in this scope.
+// factory Supertype() = X;
+// ^^^^^^^^^
+
+library;
+import self as self;
+import "dart:core" as core;
+
+class Supertype extends core::Object {
+ static field dynamic _redirecting# = <dynamic>[self::Supertype::•];
+ static factory •() → self::Supertype
+ let dynamic #redirecting_factory = self::X::• in invalid-expression;
+}
+class X extends core::Object implements self::Supertype {
+ constructor •() → self::X
+ : super core::Object::•()
+ ;
+}
+static method main() → dynamic {
+ self::X x = let dynamic _ = null in throw new core::NoSuchMethodError::withInvocation(null, new core::_InvocationMirror::_withType(#Supertype, 32, const <core::Type>[], const <dynamic>[], core::Map::unmodifiable<core::Symbol, dynamic>(const <core::Symbol, dynamic>{})));
+}
diff --git a/pkg/front_end/testcases/regress/issue_35260.dart.legacy.transformed.expect b/pkg/front_end/testcases/regress/issue_35260.dart.legacy.transformed.expect
new file mode 100644
index 0000000..07ace47
--- /dev/null
+++ b/pkg/front_end/testcases/regress/issue_35260.dart.legacy.transformed.expect
@@ -0,0 +1,23 @@
+// Unhandled errors:
+//
+// pkg/front_end/testcases/regress/issue_35260.dart:7:11: Error: 'Supertype' is already declared in this scope.
+// factory Supertype() = X;
+// ^^^^^^^^^
+
+library;
+import self as self;
+import "dart:core" as core;
+
+class Supertype extends core::Object {
+ static field dynamic _redirecting# = <dynamic>[self::Supertype::•];
+ static factory •() → self::Supertype
+ let dynamic #redirecting_factory = self::X::• in invalid-expression;
+}
+class X extends core::Object implements self::Supertype {
+ constructor •() → self::X
+ : super core::Object::•()
+ ;
+}
+static method main() → dynamic {
+ self::X x = let dynamic _ = null in throw new core::NoSuchMethodError::withInvocation(null, new core::_InvocationMirror::_withType(#Supertype, 32, const <core::Type>[], const <dynamic>[], core::Map::unmodifiable<core::Symbol, dynamic>(const <core::Symbol, dynamic>{})));
+}
diff --git a/pkg/front_end/testcases/regress/issue_35260.dart.outline.expect b/pkg/front_end/testcases/regress/issue_35260.dart.outline.expect
new file mode 100644
index 0000000..4f6b056
--- /dev/null
+++ b/pkg/front_end/testcases/regress/issue_35260.dart.outline.expect
@@ -0,0 +1,24 @@
+// Formatted problems:
+//
+// pkg/front_end/testcases/regress/issue_35260.dart:7:11: Error: 'Supertype' is already declared in this scope.
+// factory Supertype() = X;
+// ^^^^^^^^^
+// pkg/front_end/testcases/regress/issue_35260.dart:6:11: Context: Previous declaration of 'Supertype'.
+// factory Supertype() = X;
+// ^^^^^^^^^
+
+library;
+import self as self;
+import "dart:core" as core;
+
+class Supertype extends core::Object {
+ static field dynamic _redirecting# = <dynamic>[self::Supertype::•];
+ static factory •() → self::Supertype
+ let dynamic #redirecting_factory = self::X::• in invalid-expression;
+}
+class X extends core::Object implements self::Supertype {
+ constructor •() → self::X
+ ;
+}
+static method main() → dynamic
+ ;
diff --git a/pkg/front_end/testcases/regress/issue_35260.dart.strong.expect b/pkg/front_end/testcases/regress/issue_35260.dart.strong.expect
new file mode 100644
index 0000000..25f0614
--- /dev/null
+++ b/pkg/front_end/testcases/regress/issue_35260.dart.strong.expect
@@ -0,0 +1,38 @@
+// Formatted problems:
+//
+// pkg/front_end/testcases/regress/issue_35260.dart:7:11: Error: 'Supertype' is already declared in this scope.
+// factory Supertype() = X;
+// ^^^^^^^^^
+// pkg/front_end/testcases/regress/issue_35260.dart:6:11: Context: Previous declaration of 'Supertype'.
+// factory Supertype() = X;
+// ^^^^^^^^^
+//
+// pkg/front_end/testcases/regress/issue_35260.dart:15:13: Error: Can't use 'Supertype' because it is declared more than once.
+// X x = new Supertype();
+// ^
+
+// Unhandled errors:
+//
+// pkg/front_end/testcases/regress/issue_35260.dart:7:11: Error: 'Supertype' is already declared in this scope.
+// factory Supertype() = X;
+// ^^^^^^^^^
+
+library;
+import self as self;
+import "dart:core" as core;
+
+class Supertype extends core::Object {
+ static field dynamic _redirecting# = <dynamic>[self::Supertype::•];
+ static factory •() → self::Supertype
+ let dynamic #redirecting_factory = self::X::• in invalid-expression;
+}
+class X extends core::Object implements self::Supertype {
+ constructor •() → self::X
+ : super core::Object::•()
+ ;
+}
+static method main() → dynamic {
+ self::X x = invalid-expression "pkg/front_end/testcases/regress/issue_35260.dart:15:13: Error: Can't use 'Supertype' because it is declared more than once.
+ X x = new Supertype();
+ ^" as{TypeError} self::X;
+}
diff --git a/pkg/front_end/testcases/regress/issue_35260.dart.strong.transformed.expect b/pkg/front_end/testcases/regress/issue_35260.dart.strong.transformed.expect
new file mode 100644
index 0000000..42e3f3a
--- /dev/null
+++ b/pkg/front_end/testcases/regress/issue_35260.dart.strong.transformed.expect
@@ -0,0 +1,25 @@
+// Unhandled errors:
+//
+// pkg/front_end/testcases/regress/issue_35260.dart:7:11: Error: 'Supertype' is already declared in this scope.
+// factory Supertype() = X;
+// ^^^^^^^^^
+
+library;
+import self as self;
+import "dart:core" as core;
+
+class Supertype extends core::Object {
+ static field dynamic _redirecting# = <dynamic>[self::Supertype::•];
+ static factory •() → self::Supertype
+ let<BottomType> #redirecting_factory = self::X::• in invalid-expression;
+}
+class X extends core::Object implements self::Supertype {
+ constructor •() → self::X
+ : super core::Object::•()
+ ;
+}
+static method main() → dynamic {
+ self::X x = invalid-expression "pkg/front_end/testcases/regress/issue_35260.dart:15:13: Error: Can't use 'Supertype' because it is declared more than once.
+ X x = new Supertype();
+ ^" as{TypeError} self::X;
+}
diff --git a/pkg/front_end/testcases/strong.status b/pkg/front_end/testcases/strong.status
index 6a2266f..1a7f335 100644
--- a/pkg/front_end/testcases/strong.status
+++ b/pkg/front_end/testcases/strong.status
@@ -133,6 +133,8 @@
regress/issue_34225: RuntimeError
regress/issue_34563: RuntimeError # Test execution after recovery
regress/issue_35177: RuntimeError
+regress/issue_35259: RuntimeError # Expected
+regress/issue_35260: RuntimeError # Expected
runtime_checks_new/contravariant_generic_return_with_compound_assign_implicit_downcast: RuntimeError
runtime_checks_new/mixin_forwarding_stub_field: TypeCheckError
runtime_checks_new/mixin_forwarding_stub_getter: TypeCheckError
diff --git a/tests/language_2/regress_35259_test.dart b/tests/language_2/regress_35259_test.dart
new file mode 100644
index 0000000..145a28e
--- /dev/null
+++ b/tests/language_2/regress_35259_test.dart
@@ -0,0 +1,12 @@
+// Copyright (c) 2018, 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.
+
+class Supertype {
+ factory Supertype() = Unresolved; //# 01: compile-time error
+ factory Supertype() = Unresolved; //# 01: compile-time error
+}
+
+main() {
+ print(new Supertype());
+}
diff --git a/tests/language_2/regress_35260_test.dart b/tests/language_2/regress_35260_test.dart
new file mode 100644
index 0000000..a5853ef
--- /dev/null
+++ b/tests/language_2/regress_35260_test.dart
@@ -0,0 +1,16 @@
+// Copyright (c) 2018, 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.
+
+class Supertype {
+ factory Supertype() = X;
+ factory Supertype() = X; //# 01: compile-time error
+}
+
+class X implements Supertype {
+ X();
+}
+
+main() {
+ X x = new Supertype();
+}