diff --git a/pkg/dev_compiler/lib/src/compiler/code_generator.dart b/pkg/dev_compiler/lib/src/compiler/code_generator.dart index 43de895f24bd..b17ee5b5a1ab 100644 --- a/pkg/dev_compiler/lib/src/compiler/code_generator.dart +++ b/pkg/dev_compiler/lib/src/compiler/code_generator.dart @@ -3139,6 +3139,7 @@ class CodeGenerator extends GeneralizingAstVisitor // If the target may be an extension type, we also use static dispatch // as we don't symbolize object properties like hashCode. return isNullable(target) || + type.isDynamic || (_extensionTypes.contains(type.element) && target is! SuperExpression); } diff --git a/pkg/dev_compiler/test/codegen/expect/language-all.js b/pkg/dev_compiler/test/codegen/expect/language-all.js index 06e592f0ed20..aa8caf142bd8 100644 --- a/pkg/dev_compiler/test/codegen/expect/language-all.js +++ b/pkg/dev_compiler/test/codegen/expect/language-all.js @@ -67577,6 +67577,24 @@ dart_library.library('hash_map_null_key_foreach_test', null, /* Imports */[ // Exports: exports.hash_map_null_key_foreach_test = hash_map_null_key_foreach_test; }); +dart_library.library('hashcode_dynamic_test', null, /* Imports */[ + 'dart_sdk', + 'expect' +], function(exports, dart_sdk, expect) { + 'use strict'; + const core = dart_sdk.core; + const dart = dart_sdk.dart; + const dartx = dart_sdk.dartx; + const expect$ = expect.expect; + const hashcode_dynamic_test = Object.create(null); + hashcode_dynamic_test.main = function() { + let x = 3; + expect$.Expect.equals(3, dart.hashCode(x)); + }; + dart.fn(hashcode_dynamic_test.main, dart.void, []); + // Exports: + exports.hashcode_dynamic_test = hashcode_dynamic_test; +}); dart_library.library('hello_dart_test', null, /* Imports */[ 'dart_sdk' ], function(exports, dart_sdk) { diff --git a/pkg/dev_compiler/test/codegen/language/hashcode_dynamic_test.dart b/pkg/dev_compiler/test/codegen/language/hashcode_dynamic_test.dart new file mode 100644 index 000000000000..b705dd8afaaf --- /dev/null +++ b/pkg/dev_compiler/test/codegen/language/hashcode_dynamic_test.dart @@ -0,0 +1,10 @@ +// Copyright (c) 2016, 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. + +import "package:expect/expect.dart"; + +void main() { + dynamic x = 3; + Expect.equals(3, x.hashCode); +}