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

Unified Diff: sdk/lib/_internal/compiler/implementation/ssa/builder.dart

Issue 246563006: Handle generic parameters in synthesized constructor for mixin applications. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comment Created 6 years, 8 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
« no previous file with comments | « no previous file | tests/language/generic_constructor_mixin2_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/ssa/builder.dart
diff --git a/sdk/lib/_internal/compiler/implementation/ssa/builder.dart b/sdk/lib/_internal/compiler/implementation/ssa/builder.dart
index 91b0977e722bdb92b70739138ee4b321fb4c70bb..5b72b5cb485710025c507c931db959145aa4fd7f 100644
--- a/sdk/lib/_internal/compiler/implementation/ssa/builder.dart
+++ b/sdk/lib/_internal/compiler/implementation/ssa/builder.dart
@@ -1615,10 +1615,34 @@ class SsaBuilder extends ResolvedVisitor {
* function.
*/
void potentiallyCheckInlinedParameterTypes(FunctionElement function) {
+ if (!compiler.enableTypeAssertions) return;
+
FunctionSignature signature = function.functionSignature;
+
+ InterfaceType contextType;
+ if (function.isSynthesized && function.isGenerativeConstructor()) {
+ // Synthesized constructors reuse the parameters from the
+ // [targetConstructor]. In face of generic types, the type variables
+ // occurring in the parameter types must be substituted by the type
+ // arguments of the enclosing class.
+ FunctionElement target = function;
+ while (target.targetConstructor != null) {
+ target = target.targetConstructor;
+ }
+ if (target != function) {
+ ClassElement functionClass = function.getEnclosingClass();
+ ClassElement targetClass = target.getEnclosingClass();
+ contextType = functionClass.thisType.asInstanceOf(targetClass);
+ }
+ }
+
signature.orderedForEachParameter((ParameterElement parameter) {
HInstruction argument = localsHandler.readLocal(parameter);
- potentiallyCheckType(argument, parameter.type);
+ DartType parameterType = parameter.type;
+ if (contextType != null) {
+ parameterType = parameterType.substByContext(contextType);
+ }
+ potentiallyCheckType(argument, parameterType);
});
}
« no previous file with comments | « no previous file | tests/language/generic_constructor_mixin2_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698