Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(247)

Side by Side Diff: runtime/vm/class_finalizer.cc

Issue 1699233002: Revert "Compile-time error if mixin class has a fact (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/class_finalizer.h" 5 #include "vm/class_finalizer.h"
6 6
7 #include "vm/code_generator.h" 7 #include "vm/code_generator.h"
8 #include "vm/flags.h" 8 #include "vm/flags.h"
9 #include "vm/heap.h" 9 #include "vm/heap.h"
10 #include "vm/isolate.h" 10 #include "vm/isolate.h"
(...skipping 2209 matching lines...) Expand 10 before | Expand all | Expand 10 after
2220 2220
2221 Array& functions = Array::Handle(zone); 2221 Array& functions = Array::Handle(zone);
2222 Function& func = Function::Handle(zone); 2222 Function& func = Function::Handle(zone);
2223 // The parser creates the mixin application class with no functions. 2223 // The parser creates the mixin application class with no functions.
2224 ASSERT((functions = cls.functions(), functions.Length() == 0)); 2224 ASSERT((functions = cls.functions(), functions.Length() == 0));
2225 // Now clone the functions from the mixin class. 2225 // Now clone the functions from the mixin class.
2226 functions = mixin_cls.functions(); 2226 functions = mixin_cls.functions();
2227 const intptr_t num_functions = functions.Length(); 2227 const intptr_t num_functions = functions.Length();
2228 for (intptr_t i = 0; i < num_functions; i++) { 2228 for (intptr_t i = 0; i < num_functions; i++) {
2229 func ^= functions.At(i); 2229 func ^= functions.At(i);
2230 if (func.IsFactory() || func.IsGenerativeConstructor()) { 2230 if (func.IsGenerativeConstructor()) {
2231 // A mixin class must not have explicit constructors. 2231 // A mixin class must not have explicit constructors.
2232 if (!func.IsImplicitConstructor()) { 2232 if (!func.IsImplicitConstructor()) {
2233 const char* ctr_kind = func.IsFactory() ? "factory" : "constructor"; 2233 ReportError(cls, cls.token_pos(),
Ivan Posva 2016/02/17 07:51:26 You need to preserve the improved error message be
Jacob 2016/02/19 20:53:03 Done.
2234 const Script& script = Script::Handle(cls.script()); 2234 "mixin class '%s' must not have constructors\n",
2235 const Error& error = Error::Handle( 2235 String::Handle(zone, mixin_cls.Name()).ToCString());
2236 LanguageError::NewFormatted(Error::Handle(),
2237 script, func.token_pos(), Report::AtLocation,
2238 Report::kError, Heap::kNew,
2239 "%s '%s' is illegal in mixin class %s",
2240 ctr_kind,
2241 String::Handle(func.PrettyName()).ToCString(),
2242 String::Handle(zone, mixin_cls.Name()).ToCString()));
2243
2244 ReportErrors(error, cls, cls.token_pos(),
2245 "mixin class '%s' must not have constructors",
2246 String::Handle(zone, mixin_cls.Name()).ToCString());
2247 } 2236 }
2248 continue; // Skip the implicit constructor. 2237 continue; // Skip the implicit constructor.
2249 } 2238 }
2250 if (!func.is_static() && 2239 if (!func.is_static() &&
2251 !func.IsMethodExtractor() && 2240 !func.IsMethodExtractor() &&
2252 !func.IsNoSuchMethodDispatcher() && 2241 !func.IsNoSuchMethodDispatcher() &&
2253 !func.IsInvokeFieldDispatcher()) { 2242 !func.IsInvokeFieldDispatcher()) {
2254 func = func.Clone(cls); 2243 func = func.Clone(cls);
2255 cloned_funcs.Add(func); 2244 cloned_funcs.Add(func);
2256 } 2245 }
(...skipping 1037 matching lines...) Expand 10 before | Expand all | Expand 10 after
3294 ASSERT(fields_array.Length() == ByteBuffer::NumberOfFields()); 3283 ASSERT(fields_array.Length() == ByteBuffer::NumberOfFields());
3295 field ^= fields_array.At(0); 3284 field ^= fields_array.At(0);
3296 ASSERT(field.Offset() == ByteBuffer::data_offset()); 3285 ASSERT(field.Offset() == ByteBuffer::data_offset());
3297 name ^= field.name(); 3286 name ^= field.name();
3298 expected_name ^= String::New("_data"); 3287 expected_name ^= String::New("_data");
3299 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name)); 3288 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name));
3300 #endif 3289 #endif
3301 } 3290 }
3302 3291
3303 } // namespace dart 3292 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | tests/language/language_analyzer2.status » ('j') | tests/language/mixin_illegal_constructor_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698