Fix #28740 demangle constructors in stack traces (A.A becomes new A).
Regular constructors and unnamed factory constructors: - Were A.A, now are new A Named constructors (including factory constructors): - Were A.A.name, now are new A.name BUG= R=asiva@google.com, rmacnak@google.com Review-Url: https://codereview.chromium.org/2818933003 .
This commit is contained in:
+10
-5
@@ -7175,11 +7175,16 @@ RawString* Function::QualifiedName(NameVisibility name_visibility) const {
|
||||
}
|
||||
const Class& cls = Class::Handle(Owner());
|
||||
if (!cls.IsTopLevel()) {
|
||||
result = String::Concat(Symbols::Dot(), result, Heap::kOld);
|
||||
const String& cls_name = String::Handle(name_visibility == kScrubbedName
|
||||
? cls.ScrubbedName()
|
||||
: cls.UserVisibleName());
|
||||
result = String::Concat(cls_name, result, Heap::kOld);
|
||||
if (kind() == RawFunction::kConstructor) {
|
||||
result = String::Concat(Symbols::ConstructorStacktracePrefix(), result,
|
||||
Heap::kOld);
|
||||
} else {
|
||||
result = String::Concat(Symbols::Dot(), result, Heap::kOld);
|
||||
const String& cls_name = String::Handle(name_visibility == kScrubbedName
|
||||
? cls.ScrubbedName()
|
||||
: cls.UserVisibleName());
|
||||
result = String::Concat(cls_name, result, Heap::kOld);
|
||||
}
|
||||
}
|
||||
return result.raw();
|
||||
}
|
||||
|
||||
@@ -422,6 +422,7 @@ class ObjectPointerVisitor;
|
||||
V(removeLast, "removeLast") \
|
||||
V(add, "add") \
|
||||
V(ConstructorClosurePrefix, "new#") \
|
||||
V(ConstructorStacktracePrefix, "new ") \
|
||||
V(_runExtension, "_runExtension") \
|
||||
V(_runPendingImmediateCallback, "_runPendingImmediateCallback") \
|
||||
V(DartLibrary, "dart.library.") \
|
||||
|
||||
@@ -233,6 +233,7 @@ map_literal4_test: SkipByDesign # Requires checked mode.
|
||||
|
||||
vm/type_vm_test: Fail,OK # Expects exact type name.
|
||||
|
||||
stacktrace_demangle_ctors_test: SkipByDesign # Names are not scrubbed.
|
||||
|
||||
[ ($compiler == none || $compiler == precompiler || $compiler == app_jit) && $browser ]
|
||||
# The following tests are supposed to fail.
|
||||
|
||||
@@ -55,6 +55,8 @@ covariant_test/32: MissingCompileTimeError, OK # Accepts `covariant` for statics
|
||||
covariant_test/34: MissingCompileTimeError, OK # Accepts `covariant` for statics/top-level.
|
||||
covariant_test/36: MissingCompileTimeError, OK # Accepts `covariant` for statics/top-level.
|
||||
|
||||
stacktrace_demangle_ctors_test: Fail # dart2js stack traces are not always compliant.
|
||||
|
||||
[ $compiler == dart2js && $fast_startup ]
|
||||
const_evaluation_test/*: Fail # mirrors not supported
|
||||
deferred_constraints_constants_test/none: Fail # mirrors not supported
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
// Copyright (c) 2017, 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.
|
||||
|
||||
// Test that stack traces are properly demangled in constructors (#28740).
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
class SomeClass {
|
||||
SomeClass.namedConstructor() {
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
SomeClass() {
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
factory SomeClass.useFactory() {
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
|
||||
class OnlyHasFactory {
|
||||
factory OnlyHasFactory() {
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
try {
|
||||
new SomeClass();
|
||||
} on Exception catch (e, st) {
|
||||
final stString = st.toString();
|
||||
Expect.isTrue(stString.contains("new SomeClass"));
|
||||
Expect.isFalse(stString.contains("SomeClass."));
|
||||
}
|
||||
|
||||
try {
|
||||
new SomeClass.namedConstructor();
|
||||
} on Exception catch (e, st) {
|
||||
final stString = st.toString();
|
||||
Expect.isTrue(stString.contains("new SomeClass.namedConstructor"));
|
||||
}
|
||||
|
||||
try {
|
||||
new OnlyHasFactory();
|
||||
} on Exception catch (e, st) {
|
||||
final stString = st.toString();
|
||||
Expect.isTrue(stString.contains("new OnlyHasFactory"));
|
||||
Expect.isFalse(stString.contains("OnlyHasFactory."));
|
||||
}
|
||||
|
||||
try {
|
||||
new SomeClass.useFactory();
|
||||
} on Exception catch (e, st) {
|
||||
final stString = st.toString();
|
||||
Expect.isTrue(stString.contains("new SomeClass.useFactory"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user