summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsources/scala/tools/nsc/CompilerRun.scala1
-rwxr-xr-xsources/scala/tools/nsc/Global.scala1
-rwxr-xr-xsources/scala/tools/nsc/transform/ExplicitOuter.scala12
-rwxr-xr-xsources/scala/tools/nsc/typechecker/Contexts.scala4
-rwxr-xr-xsources/scala/tools/nsc/typechecker/Infer.scala28
5 files changed, 38 insertions, 8 deletions
diff --git a/sources/scala/tools/nsc/CompilerRun.scala b/sources/scala/tools/nsc/CompilerRun.scala
index d41371f041..7677fc2cb8 100755
--- a/sources/scala/tools/nsc/CompilerRun.scala
+++ b/sources/scala/tools/nsc/CompilerRun.scala
@@ -11,6 +11,7 @@ class CompilerRun {
def namerPhase: Phase = NoPhase;
def typerPhase: Phase = NoPhase;
def refchecksPhase: Phase = NoPhase;
+ def explicitOuterPhase: Phase = NoPhase;
def erasurePhase: Phase = NoPhase;
def flattenPhase: Phase = NoPhase;
def mixinPhase: Phase = NoPhase;
diff --git a/sources/scala/tools/nsc/Global.scala b/sources/scala/tools/nsc/Global.scala
index 38d7032bce..b24d784d63 100755
--- a/sources/scala/tools/nsc/Global.scala
+++ b/sources/scala/tools/nsc/Global.scala
@@ -301,6 +301,7 @@ class Global(val settings: Settings, val reporter: Reporter) extends SymbolTable
override val namerPhase = phaseNamed("namer");
override val typerPhase = phaseNamed("typer");
override val refchecksPhase = phaseNamed("refchecks");
+ override val explicitOuterPhase = phaseNamed("explicitouter");
override val erasurePhase = phaseNamed("erasure");
override val flattenPhase = phaseNamed("flatten");
override val mixinPhase = phaseNamed("mixin");
diff --git a/sources/scala/tools/nsc/transform/ExplicitOuter.scala b/sources/scala/tools/nsc/transform/ExplicitOuter.scala
index 0aaa923b67..f3ac8d3c0a 100755
--- a/sources/scala/tools/nsc/transform/ExplicitOuter.scala
+++ b/sources/scala/tools/nsc/transform/ExplicitOuter.scala
@@ -182,9 +182,15 @@ abstract class ExplicitOuter extends InfoTransform {
/** The mixin constructor definition
* def $init$(): Unit = ()
*/
- def mixinConstructorDef(clazz: Symbol): Tree = localTyper.typed {
- DefDef(clazz.primaryConstructor, vparamss => Literal(()))
- }
+ def mixinConstructorDef(clazz: Symbol): Tree =
+ localTyper.typed {
+ val constr = clazz.primaryConstructor;
+ atPhase(currentRun.explicitOuterPhase) {
+ // necessary so that we do not include an outer parameter already here;
+ // this will be added later in transform.
+ DefDef(constr, vparamss => Literal(()))
+ }
+ }
/** Add calls to supermixin constructors
* super[mix].$init$()
diff --git a/sources/scala/tools/nsc/typechecker/Contexts.scala b/sources/scala/tools/nsc/typechecker/Contexts.scala
index e27af37e13..718b7655b8 100755
--- a/sources/scala/tools/nsc/typechecker/Contexts.scala
+++ b/sources/scala/tools/nsc/typechecker/Contexts.scala
@@ -62,6 +62,8 @@ import scala.tools.util.Position;
private var _undetparams: List[Symbol] = List(); // Undetermined type parameters
var depth: int = 0;
var imports: List[ImportInfo] = List();
+ var typeSubstFrom: List[Symbol] = List(); // The set of type parameters in scope.
+ var typeSubstTo: List[Type] = List(); // Types to which parameters are mapped.
var reportAmbiguousErrors = false;
var reportGeneralErrors = false;
@@ -86,6 +88,8 @@ import scala.tools.util.Position;
c.variance = this.variance;
c.depth = if (scope == this.scope) this.depth else this.depth + 1;
c.imports = imports;
+ c.typeSubstFrom = this.typeSubstFrom;
+ c.typeSubstTo = this.typeSubstTo;
c.reportAmbiguousErrors = this.reportAmbiguousErrors;
c.reportGeneralErrors = this.reportGeneralErrors;
c.checking = this.checking;
diff --git a/sources/scala/tools/nsc/typechecker/Infer.scala b/sources/scala/tools/nsc/typechecker/Infer.scala
index 9ffe4f9983..173e43cb36 100755
--- a/sources/scala/tools/nsc/typechecker/Infer.scala
+++ b/sources/scala/tools/nsc/typechecker/Infer.scala
@@ -469,11 +469,13 @@ package scala.tools.nsc.typechecker;
}
/** Substitite free type variables `undetparams' of type constructor `tree' in pattern,
- * given prototype `pt'. */
+ * given prototype `pt'.
+ * return type substitution for type parameters.
+ */
def inferConstructorInstance(tree: Tree, undetparams: List[Symbol], pt: Type): unit = {
- val tvars = undetparams map freshVar;
- val restpe = skipImplicit(tree.tpe.resultType);
- if (restpe.subst(undetparams, tvars) <:< pt)
+ var restpe = skipImplicit(tree.tpe.resultType);
+ var tvars = undetparams map freshVar;
+ def computeArgs =
try {
val targs = solve(tvars, undetparams, undetparams map varianceInType(restpe), true);
checkBounds(tree.pos, undetparams, targs, "inferred ");
@@ -484,7 +486,23 @@ package scala.tools.nsc.typechecker;
" can be instantiated in more than one way to expected type " + pt +
"\n --- because ---\n" + ex.getMessage());
}
- else {
+/*
+ if (!restpe.subst(undetparams, tvars) <:< pt) {
+ map all unbound type params to AnyVal;
+ tvars = undetparams map freshVar;
+ if (restpe.subst(undetparams, tvars) <:< pt) {
+ computeArgs;
+ restpe = skipImplicit(tree.tpe.resultType);
+ map all unbound type params tparams1 to freshVars tvars1
+ val targs1 = solve(tvars1, tparams1, ??, ??);
+ checkBounds(tparams1, targs1, "inferred");
+ return Pair(tparams, targs) where different
+ }
+ }
+*/
+ if (restpe.subst(undetparams, tvars) <:< pt) {
+ computeArgs
+ } else {
System.out.println("ici " + tree + " " + undetparams + " " + pt);//debug
errorTree(tree, "constructor cannot be instantiated to expected type" +
foundReqMsg(restpe, pt))