| OLD | NEW |
| 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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 } else { | 160 } else { |
| 161 return false; | 161 return false; |
| 162 } | 162 } |
| 163 UNREACHABLE(); | 163 UNREACHABLE(); |
| 164 return true; | 164 return true; |
| 165 } | 165 } |
| 166 | 166 |
| 167 | 167 |
| 168 // Adds all interfaces of cls into 'collected'. Duplicate entries may occur. | 168 // Adds all interfaces of cls into 'collected'. Duplicate entries may occur. |
| 169 // No cycles are allowed. | 169 // No cycles are allowed. |
| 170 void ClassFinalizer::CollectInterfaces(const Class& cls, | 170 void ClassFinalizer::CollectInterfaces( |
| 171 const GrowableObjectArray& collected) { | 171 const Class& cls, GrowableArray<const Class*>* collected) { |
| 172 const Array& interface_array = Array::Handle(cls.interfaces()); | 172 Zone* zone = Thread::Current()->zone(); |
| 173 AbstractType& interface = AbstractType::Handle(); | 173 const Array& interface_array = Array::Handle(zone, cls.interfaces()); |
| 174 Class& interface_class = Class::Handle(); | 174 AbstractType& interface = AbstractType::Handle(zone); |
| 175 Class& interface_class = Class::Handle(zone); |
| 175 for (intptr_t i = 0; i < interface_array.Length(); i++) { | 176 for (intptr_t i = 0; i < interface_array.Length(); i++) { |
| 176 interface ^= interface_array.At(i); | 177 interface ^= interface_array.At(i); |
| 177 interface_class = interface.type_class(); | 178 interface_class = interface.type_class(); |
| 178 collected.Add(interface_class); | 179 collected->Add(&Class::ZoneHandle(zone, interface_class.raw())); |
| 179 CollectInterfaces(interface_class, collected); | 180 CollectInterfaces(interface_class, collected); |
| 180 } | 181 } |
| 181 } | 182 } |
| 182 | 183 |
| 183 | 184 |
| 184 #if defined(DART_NO_SNAPSHOT) | 185 #if defined(DART_NO_SNAPSHOT) |
| 185 void ClassFinalizer::VerifyBootstrapClasses() { | 186 void ClassFinalizer::VerifyBootstrapClasses() { |
| 186 if (FLAG_trace_class_finalization) { | 187 if (FLAG_trace_class_finalization) { |
| 187 OS::Print("VerifyBootstrapClasses START.\n"); | 188 OS::Print("VerifyBootstrapClasses START.\n"); |
| 188 } | 189 } |
| (...skipping 1105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1294 // conflict with an accessible static setter 'v=' of a super class). | 1295 // conflict with an accessible static setter 'v=' of a super class). |
| 1295 // The compile-time errors we report are: | 1296 // The compile-time errors we report are: |
| 1296 // - a static member 'v' conflicting with an inherited instance member 'v'. | 1297 // - a static member 'v' conflicting with an inherited instance member 'v'. |
| 1297 // - a static setter 'v=' conflicting with an inherited instance setter 'v='. | 1298 // - a static setter 'v=' conflicting with an inherited instance setter 'v='. |
| 1298 // - an instance method conflicting with an inherited instance field or | 1299 // - an instance method conflicting with an inherited instance field or |
| 1299 // instance getter. | 1300 // instance getter. |
| 1300 // - an instance field or instance getter conflicting with an inherited | 1301 // - an instance field or instance getter conflicting with an inherited |
| 1301 // instance method. | 1302 // instance method. |
| 1302 | 1303 |
| 1303 // Resolve type of fields and check for conflicts in super classes. | 1304 // Resolve type of fields and check for conflicts in super classes. |
| 1304 Isolate* I = Isolate::Current(); | 1305 Zone* Z = Thread::Current()->zone(); |
| 1305 Array& array = Array::Handle(I, cls.fields()); | 1306 Array& array = Array::Handle(Z, cls.fields()); |
| 1306 Field& field = Field::Handle(I); | 1307 Field& field = Field::Handle(Z); |
| 1307 AbstractType& type = AbstractType::Handle(I); | 1308 AbstractType& type = AbstractType::Handle(Z); |
| 1308 String& name = String::Handle(I); | 1309 String& name = String::Handle(Z); |
| 1309 String& getter_name = String::Handle(I); | 1310 String& getter_name = String::Handle(Z); |
| 1310 String& setter_name = String::Handle(I); | 1311 String& setter_name = String::Handle(Z); |
| 1311 Class& super_class = Class::Handle(I); | 1312 Class& super_class = Class::Handle(Z); |
| 1312 const intptr_t num_fields = array.Length(); | 1313 const intptr_t num_fields = array.Length(); |
| 1313 for (intptr_t i = 0; i < num_fields; i++) { | 1314 for (intptr_t i = 0; i < num_fields; i++) { |
| 1314 field ^= array.At(i); | 1315 field ^= array.At(i); |
| 1315 type = field.type(); | 1316 type = field.type(); |
| 1316 type = FinalizeType(cls, type, kCanonicalize); | 1317 type = FinalizeType(cls, type, kCanonicalize); |
| 1317 field.set_type(type); | 1318 field.set_type(type); |
| 1318 name = field.name(); | 1319 name = field.name(); |
| 1319 if (field.is_static()) { | 1320 if (field.is_static()) { |
| 1320 getter_name = Field::GetterSymbol(name); | 1321 getter_name = Field::GetterSymbol(name); |
| 1321 super_class = FindSuperOwnerOfInstanceMember(cls, name, getter_name); | 1322 super_class = FindSuperOwnerOfInstanceMember(cls, name, getter_name); |
| 1322 if (!super_class.IsNull()) { | 1323 if (!super_class.IsNull()) { |
| 1323 const String& class_name = String::Handle(I, cls.Name()); | 1324 const String& class_name = String::Handle(Z, cls.Name()); |
| 1324 const String& super_class_name = String::Handle(I, super_class.Name()); | 1325 const String& super_class_name = String::Handle(Z, super_class.Name()); |
| 1325 ReportError(cls, field.token_pos(), | 1326 ReportError(cls, field.token_pos(), |
| 1326 "static field '%s' of class '%s' conflicts with " | 1327 "static field '%s' of class '%s' conflicts with " |
| 1327 "instance member '%s' of super class '%s'", | 1328 "instance member '%s' of super class '%s'", |
| 1328 name.ToCString(), | 1329 name.ToCString(), |
| 1329 class_name.ToCString(), | 1330 class_name.ToCString(), |
| 1330 name.ToCString(), | 1331 name.ToCString(), |
| 1331 super_class_name.ToCString()); | 1332 super_class_name.ToCString()); |
| 1332 } | 1333 } |
| 1333 // An implicit setter is not generated for a static field, therefore, we | 1334 // An implicit setter is not generated for a static field, therefore, we |
| 1334 // cannot rely on the code below handling the static setter case to report | 1335 // cannot rely on the code below handling the static setter case to report |
| 1335 // a conflict with an instance setter. So we check explicitly here. | 1336 // a conflict with an instance setter. So we check explicitly here. |
| 1336 setter_name = Field::SetterSymbol(name); | 1337 setter_name = Field::SetterSymbol(name); |
| 1337 super_class = FindSuperOwnerOfFunction(cls, setter_name); | 1338 super_class = FindSuperOwnerOfFunction(cls, setter_name); |
| 1338 if (!super_class.IsNull()) { | 1339 if (!super_class.IsNull()) { |
| 1339 const String& class_name = String::Handle(I, cls.Name()); | 1340 const String& class_name = String::Handle(Z, cls.Name()); |
| 1340 const String& super_class_name = String::Handle(I, super_class.Name()); | 1341 const String& super_class_name = String::Handle(Z, super_class.Name()); |
| 1341 ReportError(cls, field.token_pos(), | 1342 ReportError(cls, field.token_pos(), |
| 1342 "static field '%s' of class '%s' conflicts with " | 1343 "static field '%s' of class '%s' conflicts with " |
| 1343 "instance setter '%s=' of super class '%s'", | 1344 "instance setter '%s=' of super class '%s'", |
| 1344 name.ToCString(), | 1345 name.ToCString(), |
| 1345 class_name.ToCString(), | 1346 class_name.ToCString(), |
| 1346 name.ToCString(), | 1347 name.ToCString(), |
| 1347 super_class_name.ToCString()); | 1348 super_class_name.ToCString()); |
| 1348 } | 1349 } |
| 1349 | 1350 |
| 1350 } else { | 1351 } else { |
| 1351 // Instance field. Check whether the field overrides a method | 1352 // Instance field. Check whether the field overrides a method |
| 1352 // (but not getter). | 1353 // (but not getter). |
| 1353 super_class = FindSuperOwnerOfFunction(cls, name); | 1354 super_class = FindSuperOwnerOfFunction(cls, name); |
| 1354 if (!super_class.IsNull()) { | 1355 if (!super_class.IsNull()) { |
| 1355 const String& class_name = String::Handle(I, cls.Name()); | 1356 const String& class_name = String::Handle(Z, cls.Name()); |
| 1356 const String& super_class_name = String::Handle(I, super_class.Name()); | 1357 const String& super_class_name = String::Handle(Z, super_class.Name()); |
| 1357 ReportError(cls, field.token_pos(), | 1358 ReportError(cls, field.token_pos(), |
| 1358 "field '%s' of class '%s' conflicts with method '%s' " | 1359 "field '%s' of class '%s' conflicts with method '%s' " |
| 1359 "of super class '%s'", | 1360 "of super class '%s'", |
| 1360 name.ToCString(), | 1361 name.ToCString(), |
| 1361 class_name.ToCString(), | 1362 class_name.ToCString(), |
| 1362 name.ToCString(), | 1363 name.ToCString(), |
| 1363 super_class_name.ToCString()); | 1364 super_class_name.ToCString()); |
| 1364 } | 1365 } |
| 1365 } | 1366 } |
| 1366 if (field.is_static() && | 1367 if (field.is_static() && |
| 1367 (field.value() != Object::null()) && | 1368 (field.value() != Object::null()) && |
| 1368 (field.value() != Object::sentinel().raw())) { | 1369 (field.value() != Object::sentinel().raw())) { |
| 1369 // The parser does not preset the value if the type is a type parameter or | 1370 // The parser does not preset the value if the type is a type parameter or |
| 1370 // is parameterized unless the value is null. | 1371 // is parameterized unless the value is null. |
| 1371 Error& error = Error::Handle(I); | 1372 Error& error = Error::Handle(Z); |
| 1372 if (type.IsMalformedOrMalbounded()) { | 1373 if (type.IsMalformedOrMalbounded()) { |
| 1373 error = type.error(); | 1374 error = type.error(); |
| 1374 } else { | 1375 } else { |
| 1375 ASSERT(type.IsInstantiated()); | 1376 ASSERT(type.IsInstantiated()); |
| 1376 } | 1377 } |
| 1377 const Instance& const_value = Instance::Handle(I, field.value()); | 1378 const Instance& const_value = Instance::Handle(Z, field.value()); |
| 1378 if (!error.IsNull() || | 1379 if (!error.IsNull() || |
| 1379 (!type.IsDynamicType() && | 1380 (!type.IsDynamicType() && |
| 1380 !const_value.IsInstanceOf(type, | 1381 !const_value.IsInstanceOf(type, |
| 1381 Object::null_type_arguments(), | 1382 Object::null_type_arguments(), |
| 1382 &error))) { | 1383 &error))) { |
| 1383 if (Isolate::Current()->flags().error_on_bad_type()) { | 1384 if (Isolate::Current()->flags().error_on_bad_type()) { |
| 1384 const AbstractType& const_value_type = AbstractType::Handle( | 1385 const AbstractType& const_value_type = AbstractType::Handle( |
| 1385 I, const_value.GetType()); | 1386 Z, const_value.GetType()); |
| 1386 const String& const_value_type_name = String::Handle( | 1387 const String& const_value_type_name = String::Handle( |
| 1387 I, const_value_type.UserVisibleName()); | 1388 Z, const_value_type.UserVisibleName()); |
| 1388 const String& type_name = String::Handle(I, type.UserVisibleName()); | 1389 const String& type_name = String::Handle(Z, type.UserVisibleName()); |
| 1389 ReportErrors(error, cls, field.token_pos(), | 1390 ReportErrors(error, cls, field.token_pos(), |
| 1390 "error initializing static %s field '%s': " | 1391 "error initializing static %s field '%s': " |
| 1391 "type '%s' is not a subtype of type '%s'", | 1392 "type '%s' is not a subtype of type '%s'", |
| 1392 field.is_const() ? "const" : "final", | 1393 field.is_const() ? "const" : "final", |
| 1393 name.ToCString(), | 1394 name.ToCString(), |
| 1394 const_value_type_name.ToCString(), | 1395 const_value_type_name.ToCString(), |
| 1395 type_name.ToCString()); | 1396 type_name.ToCString()); |
| 1396 } else { | 1397 } else { |
| 1397 // Do not report an error yet, even in checked mode, since the field | 1398 // Do not report an error yet, even in checked mode, since the field |
| 1398 // may not actually be used. | 1399 // may not actually be used. |
| 1399 // Also, we may be generating a snapshot in production mode that will | 1400 // Also, we may be generating a snapshot in production mode that will |
| 1400 // later be executed in checked mode, in which case an error needs to | 1401 // later be executed in checked mode, in which case an error needs to |
| 1401 // be reported, should the field be accessed. | 1402 // be reported, should the field be accessed. |
| 1402 // Therefore, we undo the optimization performed by the parser, i.e. | 1403 // Therefore, we undo the optimization performed by the parser, i.e. |
| 1403 // we create an implicit static final getter and reset the field value | 1404 // we create an implicit static final getter and reset the field value |
| 1404 // to the sentinel value. | 1405 // to the sentinel value. |
| 1405 const Function& getter = Function::Handle( | 1406 const Function& getter = Function::Handle( |
| 1406 I, | 1407 Z, |
| 1407 Function::New(getter_name, | 1408 Function::New(getter_name, |
| 1408 RawFunction::kImplicitStaticFinalGetter, | 1409 RawFunction::kImplicitStaticFinalGetter, |
| 1409 /* is_static = */ true, | 1410 /* is_static = */ true, |
| 1410 /* is_const = */ field.is_const(), | 1411 /* is_const = */ field.is_const(), |
| 1411 /* is_abstract = */ false, | 1412 /* is_abstract = */ false, |
| 1412 /* is_external = */ false, | 1413 /* is_external = */ false, |
| 1413 /* is_native = */ false, | 1414 /* is_native = */ false, |
| 1414 cls, | 1415 cls, |
| 1415 field.token_pos())); | 1416 field.token_pos())); |
| 1416 getter.set_result_type(type); | 1417 getter.set_result_type(type); |
| 1417 getter.set_is_debuggable(false); | 1418 getter.set_is_debuggable(false); |
| 1418 cls.AddFunction(getter); | 1419 cls.AddFunction(getter); |
| 1419 field.set_value(Object::sentinel()); | 1420 field.set_value(Object::sentinel()); |
| 1420 } | 1421 } |
| 1421 } | 1422 } |
| 1422 } | 1423 } |
| 1423 } | 1424 } |
| 1424 // Collect interfaces, super interfaces, and super classes of this class. | 1425 // Collect interfaces, super interfaces, and super classes of this class. |
| 1425 const GrowableObjectArray& interfaces = | 1426 GrowableArray<const Class*> interfaces(Z, 4); |
| 1426 GrowableObjectArray::Handle(I, GrowableObjectArray::New()); | 1427 CollectInterfaces(cls, &interfaces); |
| 1427 CollectInterfaces(cls, interfaces); | |
| 1428 // Include superclasses in list of interfaces and super interfaces. | 1428 // Include superclasses in list of interfaces and super interfaces. |
| 1429 super_class = cls.SuperClass(); | 1429 super_class = cls.SuperClass(); |
| 1430 while (!super_class.IsNull()) { | 1430 while (!super_class.IsNull()) { |
| 1431 interfaces.Add(super_class); | 1431 interfaces.Add(&Class::ZoneHandle(Z, super_class.raw())); |
| 1432 CollectInterfaces(super_class, interfaces); | 1432 CollectInterfaces(super_class, &interfaces); |
| 1433 super_class = super_class.SuperClass(); | 1433 super_class = super_class.SuperClass(); |
| 1434 } | 1434 } |
| 1435 // Resolve function signatures and check for conflicts in super classes and | 1435 // Resolve function signatures and check for conflicts in super classes and |
| 1436 // interfaces. | 1436 // interfaces. |
| 1437 array = cls.functions(); | 1437 array = cls.functions(); |
| 1438 Function& function = Function::Handle(I); | 1438 Function& function = Function::Handle(Z); |
| 1439 Function& overridden_function = Function::Handle(I); | 1439 Function& overridden_function = Function::Handle(Z); |
| 1440 const intptr_t num_functions = array.Length(); | 1440 const intptr_t num_functions = array.Length(); |
| 1441 Error& error = Error::Handle(I); | 1441 Error& error = Error::Handle(Z); |
| 1442 for (intptr_t i = 0; i < num_functions; i++) { | 1442 for (intptr_t i = 0; i < num_functions; i++) { |
| 1443 function ^= array.At(i); | 1443 function ^= array.At(i); |
| 1444 ResolveAndFinalizeSignature(cls, function); | 1444 ResolveAndFinalizeSignature(cls, function); |
| 1445 name = function.name(); | 1445 name = function.name(); |
| 1446 // Report signature conflicts only. | 1446 // Report signature conflicts only. |
| 1447 if (Isolate::Current()->flags().error_on_bad_override() && | 1447 if (Isolate::Current()->flags().error_on_bad_override() && |
| 1448 !function.is_static() && !function.IsGenerativeConstructor()) { | 1448 !function.is_static() && !function.IsGenerativeConstructor()) { |
| 1449 // A constructor cannot override anything. | 1449 // A constructor cannot override anything. |
| 1450 for (intptr_t i = 0; i < interfaces.Length(); i++) { | 1450 for (intptr_t i = 0; i < interfaces.length(); i++) { |
| 1451 super_class ^= interfaces.At(i); | 1451 const Class* super_class = interfaces.At(i); |
| 1452 // Finalize superclass since overrides check relies on all members | 1452 // Finalize superclass since overrides check relies on all members |
| 1453 // of the superclass to be finalized. | 1453 // of the superclass to be finalized. |
| 1454 FinalizeClass(super_class); | 1454 FinalizeClass(*super_class); |
| 1455 overridden_function = super_class.LookupDynamicFunction(name); | 1455 overridden_function = super_class->LookupDynamicFunction(name); |
| 1456 if (!overridden_function.IsNull() && | 1456 if (!overridden_function.IsNull() && |
| 1457 !function.HasCompatibleParametersWith(overridden_function, | 1457 !function.HasCompatibleParametersWith(overridden_function, |
| 1458 &error)) { | 1458 &error)) { |
| 1459 const String& class_name = String::Handle(I, cls.Name()); | 1459 const String& class_name = String::Handle(Z, cls.Name()); |
| 1460 const String& super_class_name = | 1460 const String& super_class_name = |
| 1461 String::Handle(I, super_class.Name()); | 1461 String::Handle(Z, super_class->Name()); |
| 1462 ReportErrors(error, cls, function.token_pos(), | 1462 ReportErrors(error, cls, function.token_pos(), |
| 1463 "class '%s' overrides method '%s' of super " | 1463 "class '%s' overrides method '%s' of super " |
| 1464 "class '%s' with incompatible parameters", | 1464 "class '%s' with incompatible parameters", |
| 1465 class_name.ToCString(), | 1465 class_name.ToCString(), |
| 1466 name.ToCString(), | 1466 name.ToCString(), |
| 1467 super_class_name.ToCString()); | 1467 super_class_name.ToCString()); |
| 1468 } | 1468 } |
| 1469 } | 1469 } |
| 1470 } | 1470 } |
| 1471 if (function.IsSetterFunction() || function.IsImplicitSetterFunction()) { | 1471 if (function.IsSetterFunction() || function.IsImplicitSetterFunction()) { |
| 1472 if (function.is_static()) { | 1472 if (function.is_static()) { |
| 1473 super_class = FindSuperOwnerOfFunction(cls, name); | 1473 super_class = FindSuperOwnerOfFunction(cls, name); |
| 1474 if (!super_class.IsNull()) { | 1474 if (!super_class.IsNull()) { |
| 1475 const String& class_name = String::Handle(I, cls.Name()); | 1475 const String& class_name = String::Handle(Z, cls.Name()); |
| 1476 const String& super_class_name = | 1476 const String& super_class_name = |
| 1477 String::Handle(I, super_class.Name()); | 1477 String::Handle(Z, super_class.Name()); |
| 1478 ReportError(cls, function.token_pos(), | 1478 ReportError(cls, function.token_pos(), |
| 1479 "static setter '%s=' of class '%s' conflicts with " | 1479 "static setter '%s=' of class '%s' conflicts with " |
| 1480 "instance setter '%s=' of super class '%s'", | 1480 "instance setter '%s=' of super class '%s'", |
| 1481 name.ToCString(), | 1481 name.ToCString(), |
| 1482 class_name.ToCString(), | 1482 class_name.ToCString(), |
| 1483 name.ToCString(), | 1483 name.ToCString(), |
| 1484 super_class_name.ToCString()); | 1484 super_class_name.ToCString()); |
| 1485 } | 1485 } |
| 1486 } | 1486 } |
| 1487 continue; | 1487 continue; |
| 1488 } | 1488 } |
| 1489 if (function.IsGetterFunction() || function.IsImplicitGetterFunction()) { | 1489 if (function.IsGetterFunction() || function.IsImplicitGetterFunction()) { |
| 1490 getter_name = name.raw(); | 1490 getter_name = name.raw(); |
| 1491 name = Field::NameFromGetter(getter_name); | 1491 name = Field::NameFromGetter(getter_name); |
| 1492 } else { | 1492 } else { |
| 1493 getter_name = Field::GetterSymbol(name); | 1493 getter_name = Field::GetterSymbol(name); |
| 1494 } | 1494 } |
| 1495 if (function.is_static()) { | 1495 if (function.is_static()) { |
| 1496 super_class = FindSuperOwnerOfInstanceMember(cls, name, getter_name); | 1496 super_class = FindSuperOwnerOfInstanceMember(cls, name, getter_name); |
| 1497 if (!super_class.IsNull()) { | 1497 if (!super_class.IsNull()) { |
| 1498 const String& class_name = String::Handle(I, cls.Name()); | 1498 const String& class_name = String::Handle(Z, cls.Name()); |
| 1499 const String& super_class_name = String::Handle(I, super_class.Name()); | 1499 const String& super_class_name = String::Handle(Z, super_class.Name()); |
| 1500 ReportError(cls, function.token_pos(), | 1500 ReportError(cls, function.token_pos(), |
| 1501 "static %s '%s' of class '%s' conflicts with " | 1501 "static %s '%s' of class '%s' conflicts with " |
| 1502 "instance member '%s' of super class '%s'", | 1502 "instance member '%s' of super class '%s'", |
| 1503 (function.IsGetterFunction() || | 1503 (function.IsGetterFunction() || |
| 1504 function.IsImplicitGetterFunction()) ? "getter" : "method", | 1504 function.IsImplicitGetterFunction()) ? "getter" : "method", |
| 1505 name.ToCString(), | 1505 name.ToCString(), |
| 1506 class_name.ToCString(), | 1506 class_name.ToCString(), |
| 1507 name.ToCString(), | 1507 name.ToCString(), |
| 1508 super_class_name.ToCString()); | 1508 super_class_name.ToCString()); |
| 1509 } | 1509 } |
| 1510 if (function.IsRedirectingFactory()) { | 1510 if (function.IsRedirectingFactory()) { |
| 1511 // The function may be a still unresolved redirecting factory. Do not | 1511 // The function may be a still unresolved redirecting factory. Do not |
| 1512 // yet try to resolve it in order to avoid cycles in class finalization. | 1512 // yet try to resolve it in order to avoid cycles in class finalization. |
| 1513 // However, the redirection type should be finalized. | 1513 // However, the redirection type should be finalized. |
| 1514 // If the redirection type is from a deferred library and is not | 1514 // If the redirection type is from a deferred library and is not |
| 1515 // yet loaded, do not attempt to resolve. | 1515 // yet loaded, do not attempt to resolve. |
| 1516 Type& type = Type::Handle(I, function.RedirectionType()); | 1516 Type& type = Type::Handle(Z, function.RedirectionType()); |
| 1517 if (IsLoaded(type)) { | 1517 if (IsLoaded(type)) { |
| 1518 type ^= FinalizeType(cls, type, kCanonicalize); | 1518 type ^= FinalizeType(cls, type, kCanonicalize); |
| 1519 function.SetRedirectionType(type); | 1519 function.SetRedirectionType(type); |
| 1520 } | 1520 } |
| 1521 } | 1521 } |
| 1522 } else if (function.IsGetterFunction() || | 1522 } else if (function.IsGetterFunction() || |
| 1523 function.IsImplicitGetterFunction()) { | 1523 function.IsImplicitGetterFunction()) { |
| 1524 super_class = FindSuperOwnerOfFunction(cls, name); | 1524 super_class = FindSuperOwnerOfFunction(cls, name); |
| 1525 if (!super_class.IsNull()) { | 1525 if (!super_class.IsNull()) { |
| 1526 const String& class_name = String::Handle(I, cls.Name()); | 1526 const String& class_name = String::Handle(Z, cls.Name()); |
| 1527 const String& super_class_name = String::Handle(I, super_class.Name()); | 1527 const String& super_class_name = String::Handle(Z, super_class.Name()); |
| 1528 ReportError(cls, function.token_pos(), | 1528 ReportError(cls, function.token_pos(), |
| 1529 "getter '%s' of class '%s' conflicts with " | 1529 "getter '%s' of class '%s' conflicts with " |
| 1530 "method '%s' of super class '%s'", | 1530 "method '%s' of super class '%s'", |
| 1531 name.ToCString(), | 1531 name.ToCString(), |
| 1532 class_name.ToCString(), | 1532 class_name.ToCString(), |
| 1533 name.ToCString(), | 1533 name.ToCString(), |
| 1534 super_class_name.ToCString()); | 1534 super_class_name.ToCString()); |
| 1535 } | 1535 } |
| 1536 } else if (!function.IsSetterFunction() && | 1536 } else if (!function.IsSetterFunction() && |
| 1537 !function.IsImplicitSetterFunction()) { | 1537 !function.IsImplicitSetterFunction()) { |
| 1538 // A function cannot conflict with a setter, since they cannot | 1538 // A function cannot conflict with a setter, since they cannot |
| 1539 // have the same name. Thus, we do not need to check setters. | 1539 // have the same name. Thus, we do not need to check setters. |
| 1540 super_class = FindSuperOwnerOfFunction(cls, getter_name); | 1540 super_class = FindSuperOwnerOfFunction(cls, getter_name); |
| 1541 if (!super_class.IsNull()) { | 1541 if (!super_class.IsNull()) { |
| 1542 const String& class_name = String::Handle(I, cls.Name()); | 1542 const String& class_name = String::Handle(Z, cls.Name()); |
| 1543 const String& super_class_name = String::Handle(I, super_class.Name()); | 1543 const String& super_class_name = String::Handle(Z, super_class.Name()); |
| 1544 ReportError(cls, function.token_pos(), | 1544 ReportError(cls, function.token_pos(), |
| 1545 "method '%s' of class '%s' conflicts with " | 1545 "method '%s' of class '%s' conflicts with " |
| 1546 "getter '%s' of super class '%s'", | 1546 "getter '%s' of super class '%s'", |
| 1547 name.ToCString(), | 1547 name.ToCString(), |
| 1548 class_name.ToCString(), | 1548 class_name.ToCString(), |
| 1549 name.ToCString(), | 1549 name.ToCString(), |
| 1550 super_class_name.ToCString()); | 1550 super_class_name.ToCString()); |
| 1551 } | 1551 } |
| 1552 } | 1552 } |
| 1553 } | 1553 } |
| (...skipping 1662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3216 ASSERT(fields_array.Length() == ByteBuffer::NumberOfFields()); | 3216 ASSERT(fields_array.Length() == ByteBuffer::NumberOfFields()); |
| 3217 field ^= fields_array.At(0); | 3217 field ^= fields_array.At(0); |
| 3218 ASSERT(field.Offset() == ByteBuffer::data_offset()); | 3218 ASSERT(field.Offset() == ByteBuffer::data_offset()); |
| 3219 name ^= field.name(); | 3219 name ^= field.name(); |
| 3220 expected_name ^= String::New("_data"); | 3220 expected_name ^= String::New("_data"); |
| 3221 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name)); | 3221 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name)); |
| 3222 #endif | 3222 #endif |
| 3223 } | 3223 } |
| 3224 | 3224 |
| 3225 } // namespace dart | 3225 } // namespace dart |
| OLD | NEW |