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

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

Issue 12837007: Revise duplicate interface check (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/vm/parser.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/flags.h" 7 #include "vm/flags.h"
8 #include "vm/heap.h" 8 #include "vm/heap.h"
9 #include "vm/isolate.h" 9 #include "vm/isolate.h"
10 #include "vm/longjump.h" 10 #include "vm/longjump.h"
(...skipping 1427 matching lines...) Expand 10 before | Expand all | Expand 10 after
1438 FinalizeType(cls, sig_type, kCanonicalizeWellFormed); 1438 FinalizeType(cls, sig_type, kCanonicalizeWellFormed);
1439 return; 1439 return;
1440 } 1440 }
1441 // Finalize interface types (but not necessarily interface classes). 1441 // Finalize interface types (but not necessarily interface classes).
1442 Array& interface_types = Array::Handle(cls.interfaces()); 1442 Array& interface_types = Array::Handle(cls.interfaces());
1443 AbstractType& interface_type = AbstractType::Handle(); 1443 AbstractType& interface_type = AbstractType::Handle();
1444 for (intptr_t i = 0; i < interface_types.Length(); i++) { 1444 for (intptr_t i = 0; i < interface_types.Length(); i++) {
1445 interface_type ^= interface_types.At(i); 1445 interface_type ^= interface_types.At(i);
1446 interface_type = FinalizeType(cls, interface_type, kCanonicalizeWellFormed); 1446 interface_type = FinalizeType(cls, interface_type, kCanonicalizeWellFormed);
1447 interface_types.SetAt(i, interface_type); 1447 interface_types.SetAt(i, interface_type);
1448
1449 // Check whether the interface is duplicated. We need to wait with
1450 // this check until the super type and interface types are finalized,
1451 // so that we can use Type::Equals() for the test.
1452 ASSERT(interface_type.IsFinalized());
1453 ASSERT(super_type.IsFinalized());
1454 if (interface_type.Equals(super_type)) {
1455 const Script& script = Script::Handle(cls.script());
1456 ReportError(script, cls.token_pos(),
1457 "super type '%s' may not be listed in "
1458 "implements clause of class '%s'",
1459 String::Handle(super_type.Name()).ToCString(),
1460 String::Handle(cls.Name()).ToCString());
1461 }
1462 AbstractType& seen_interf = AbstractType::Handle();
1463 for (intptr_t j = 0; j < i; j++) {
1464 seen_interf ^= interface_types.At(j);
1465 if (interface_type.Equals(seen_interf)) {
1466 const Script& script = Script::Handle(cls.script());
1467 ReportError(script, cls.token_pos(),
1468 "interface '%s' appears twice in "
1469 "implements clause of class '%s'",
1470 String::Handle(interface_type.Name()).ToCString(),
1471 String::Handle(cls.Name()).ToCString());
1472 }
1473 }
1448 } 1474 }
1449 // Mark as finalized before resolving type parameter upper bounds and member 1475 // Mark as finalized before resolving type parameter upper bounds and member
1450 // types in order to break cycles. 1476 // types in order to break cycles.
1451 cls.Finalize(); 1477 cls.Finalize();
1452 // Finalize bounds even if running in production mode, so that a snapshot 1478 // Finalize bounds even if running in production mode, so that a snapshot
1453 // contains them. 1479 // contains them.
1454 ResolveAndFinalizeUpperBounds(cls); 1480 ResolveAndFinalizeUpperBounds(cls);
1455 ResolveAndFinalizeMemberTypes(cls); 1481 ResolveAndFinalizeMemberTypes(cls);
1456 // Run additional checks after all types are finalized. 1482 // Run additional checks after all types are finalized.
1457 if (cls.is_const()) { 1483 if (cls.is_const()) {
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
1958 void ClassFinalizer::ReportError(const char* format, ...) { 1984 void ClassFinalizer::ReportError(const char* format, ...) {
1959 va_list args; 1985 va_list args;
1960 va_start(args, format); 1986 va_start(args, format);
1961 const Error& error = Error::Handle( 1987 const Error& error = Error::Handle(
1962 Parser::FormatError(Script::Handle(), -1, "Error", format, args)); 1988 Parser::FormatError(Script::Handle(), -1, "Error", format, args));
1963 va_end(args); 1989 va_end(args);
1964 ReportError(error); 1990 ReportError(error);
1965 } 1991 }
1966 1992
1967 } // namespace dart 1993 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698