Skip to content

Commit

Permalink
Temporary revert to fix issue #35009 for 2.1. package:rpc relies on m…
Browse files Browse the repository at this point in the history
…irrors behaviour that is not valid for Dart 2, so these type checks cause the package to crash.

Revert "[ VM / Mirrors ] Added type checking to enforce strong mode semantics when using dart:mirrors"

This reverts commit 9f00eec.

Change-Id: I82ce07d388ba9402f20caf700815b39c9bc418f6
Reviewed-on: https://dart-review.googlesource.com/c/83225
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
  • Loading branch information
bkonyi committed Nov 6, 2018
1 parent d8d6835 commit 9c95624
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 448 deletions.
7 changes: 0 additions & 7 deletions runtime/lib/mirrors.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1434,13 +1434,6 @@ DEFINE_NATIVE_ENTRY(ClassMirror_invokeConstructor, 5) {
InvocationMirror::kMethod);
UNREACHABLE();
}
const Object& type_error =
Object::Handle(redirected_constructor.DoArgumentTypesMatch(
args, args_descriptor, type_arguments));
if (!type_error.IsNull()) {
Exceptions::PropagateError(Error::Cast(type_error));
UNREACHABLE();
}

Instance& new_object = Instance::Handle();
if (redirected_constructor.IsGenerativeConstructor()) {
Expand Down
1 change: 1 addition & 0 deletions runtime/tests/vm/vm.status
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ cc/IsolateReload_PendingStaticCall_NSMToDefined: Fail, Crash # Issue 32981. Fail
cc/IsolateReload_PendingUnqualifiedCall_InstanceToStatic: Fail # Issue 32981
cc/IsolateReload_PendingUnqualifiedCall_StaticToInstance: Fail # Issue 32981
cc/IsolateReload_RunNewFieldInitializersWithGenerics: Fail # Issue 32299
cc/Profiler_InliningIntervalBoundry: Skip # Differences in ia32, debug, release
cc/SNPrint_BadArgs: Crash, Fail # These tests are expected to crash on all platforms.
dart/data_uri_import_test/none: SkipByDesign
dart/snapshot_version_test: Skip # This test is a Dart1 test (script snapshot)
Expand Down
92 changes: 0 additions & 92 deletions runtime/vm/dart_api_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4184,16 +4184,6 @@ TEST_CASE(DartAPI_SetField_FunnyValue) {
EXPECT_STREQ("myerror", Dart_GetError(result));
}

TEST_CASE(DartAPI_SetField_BadType) {
const char* kScriptChars = "int foo;\n";
Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
Dart_Handle name = NewString("foo");
Dart_Handle result = Dart_SetField(lib, name, Dart_True());
EXPECT(Dart_IsError(result));
EXPECT_SUBSTRING("type 'bool' is not a subtype of type 'int' of 'foo'",
Dart_GetError(result));
}

void NativeFieldLookup(Dart_NativeArguments args) {
UNREACHABLE();
}
Expand Down Expand Up @@ -5178,88 +5168,6 @@ TEST_CASE(DartAPI_Invoke_FunnyArgs) {
EXPECT_STREQ("myerror", Dart_GetError(result));
}

TEST_CASE(DartAPI_Invoke_BadArgs) {
const char* kScriptChars =
"class BaseMethods {\n"
" inheritedMethod(int arg) => 'inherited $arg';\n"
" static nonInheritedMethod(int arg) => 'noninherited $arg';\n"
"}\n"
"\n"
"class Methods extends BaseMethods {\n"
" instanceMethod(int arg) => 'instance $arg';\n"
" _instanceMethod(int arg) => 'hidden instance $arg';\n"
" static staticMethod(int arg) => 'static $arg';\n"
" static _staticMethod(int arg) => 'hidden static $arg';\n"
"}\n"
"\n"
"topMethod(int arg) => 'top $arg';\n"
"_topMethod(int arg) => 'hidden top $arg';\n"
"\n"
"Methods test() {\n"
" return new Methods();\n"
"}\n";

#if defined(PRODUCT)
const char* error_msg =
"type '_OneByteString' is not a subtype of type 'int' of 'arg'";
#else
const char* error_msg =
"type 'String' is not a subtype of type 'int' of 'arg'";
#endif // defined(PRODUCT)

// Shared setup.
Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
Dart_Handle type = Dart_GetType(lib, NewString("Methods"), 0, NULL);
EXPECT_VALID(type);
Dart_Handle instance = Dart_Invoke(lib, NewString("test"), 0, NULL);
EXPECT_VALID(instance);
Dart_Handle args[1];
args[0] = NewString("!!!");
Dart_Handle result;
Dart_Handle name;

// Instance method.
name = NewString("instanceMethod");
result = Dart_Invoke(instance, name, 1, args);
EXPECT(Dart_IsError(result));
EXPECT_SUBSTRING(error_msg, Dart_GetError(result));

name = PrivateLibName(lib, "_instanceMethod");
result = Dart_Invoke(instance, name, 1, args);
EXPECT(Dart_IsError(result));
EXPECT_SUBSTRING(error_msg, Dart_GetError(result));

// Inherited method.
name = NewString("inheritedMethod");
result = Dart_Invoke(instance, name, 1, args);
EXPECT(Dart_IsError(result));
EXPECT_SUBSTRING(error_msg, Dart_GetError(result));

// Static method.
name = NewString("staticMethod");
result = Dart_Invoke(type, name, 1, args);
EXPECT(Dart_IsError(result));
EXPECT_SUBSTRING(error_msg, Dart_GetError(result));

// Hidden static method.
name = NewString("_staticMethod");
result = Dart_Invoke(type, name, 1, args);
EXPECT(Dart_IsError(result));
EXPECT_SUBSTRING(error_msg, Dart_GetError(result));

// Top-Level method.
name = NewString("topMethod");
result = Dart_Invoke(lib, name, 1, args);
EXPECT(Dart_IsError(result));
EXPECT_SUBSTRING(error_msg, Dart_GetError(result));

// Hidden top-level method.
name = NewString("_topMethod");
result = Dart_Invoke(lib, name, 1, args);
EXPECT(Dart_IsError(result));
EXPECT_SUBSTRING(error_msg, Dart_GetError(result));
}

TEST_CASE(DartAPI_Invoke_Null) {
Dart_Handle result = Dart_Invoke(Dart_Null(), NewString("toString"), 0, NULL);
EXPECT_VALID(result);
Expand Down
Loading

0 comments on commit 9c95624

Please sign in to comment.