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

Unified Diff: sdk/lib/_internal/compiler/implementation/resolution/members.dart

Issue 25844002: Check mixin of black-listed types. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/compiler/implementation/resolution/members.dart
diff --git a/sdk/lib/_internal/compiler/implementation/resolution/members.dart b/sdk/lib/_internal/compiler/implementation/resolution/members.dart
index 7a27b1d398e436ca27dc88b2d924da81808c55bf..2357d2aa242a914dded2feb81fd30eca0971f81b 100644
--- a/sdk/lib/_internal/compiler/implementation/resolution/members.dart
+++ b/sdk/lib/_internal/compiler/implementation/resolution/members.dart
@@ -3606,7 +3606,9 @@ class ClassResolverVisitor extends TypeDefinitionVisitor {
DartType supertype = resolveSupertype(element, superMixin.superclass);
Link<Node> link = superMixin.mixins.nodes;
while (!link.isEmpty) {
- supertype = applyMixin(supertype, resolveType(link.head), node);
karlklose 2013/10/03 07:50:01 How about: 'resolveType' -> 'checkMixinType'?
Johnni Winther 2013/10/03 08:00:26 Done.
+ TypeAnnotation mixinNode = link.head;
+ DartType mixinType = checkMixinType(mixinNode);
+ supertype = applyMixin(supertype, mixinType, mixinNode);
link = link.tail;
}
element.supertype = supertype;
@@ -3657,6 +3659,17 @@ class ClassResolverVisitor extends TypeDefinitionVisitor {
return element.computeType(compiler);
}
+ /// Resolves the mixed type for [mixinNode] and checks that the the mixin type
+ /// is not black-listed. The mixin type is returned.
+ DartType checkMixinType(TypeAnnotation mixinNode) {
+ DartType mixinType = resolveType(mixinNode);
+ if (isBlackListed(mixinType)) {
+ compiler.reportError(mixinNode,
+ MessageKind.CANNOT_MIXIN, {'type': mixinType});
+ }
+ return mixinType;
+ }
+
DartType visitNamedMixinApplication(NamedMixinApplication node) {
compiler.ensure(element != null);
compiler.ensure(element.resolutionState == STATE_STARTED);
@@ -3670,10 +3683,12 @@ class ClassResolverVisitor extends TypeDefinitionVisitor {
DartType supertype = resolveSupertype(element, node.superclass);
Link<Node> link = node.mixins.nodes;
while (!link.tail.isEmpty) {
- supertype = applyMixin(supertype, resolveType(link.head), link.head);
karlklose 2013/10/03 07:50:01 Ditto.
Johnni Winther 2013/10/03 08:00:26 Done.
+ TypeAnnotation mixinNode = link.head;
+ DartType mixinType = checkMixinType(mixinNode);
+ supertype = applyMixin(supertype, mixinType, mixinNode);
link = link.tail;
}
- doApplyMixinTo(element, supertype, resolveType(link.head));
+ doApplyMixinTo(element, supertype, checkMixinType(link.head));
return element.computeType(compiler);
}
@@ -3706,6 +3721,7 @@ class ClassResolverVisitor extends TypeDefinitionVisitor {
void doApplyMixinTo(MixinApplicationElement mixinApplication,
DartType supertype,
DartType mixinType) {
+
karlklose 2013/10/03 07:50:01 Remove extra line.
Johnni Winther 2013/10/03 08:00:26 Done.
Node node = mixinApplication.parseNode(compiler);
if (mixinApplication.supertype != null) {
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/warnings.dart » ('j') | tests/language/constant_type_literal_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698