aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/dotty/tools/dotc/transform
diff options
context:
space:
mode:
authorodersky <odersky@gmail.com>2017-03-14 17:05:30 +0100
committerGitHub <noreply@github.com>2017-03-14 17:05:30 +0100
commit934da77590dad2003fe850b48b2ae01b427508f0 (patch)
tree42ded3e03ed2c16e1680ebaf72a49ad2964b2026 /compiler/src/dotty/tools/dotc/transform
parent1aad0a1433e1261af252d2240d63f6f01da65cef (diff)
parent3c22580feccca384e83465afd38d3df689c61f88 (diff)
downloaddotty-934da77590dad2003fe850b48b2ae01b427508f0.tar.gz
dotty-934da77590dad2003fe850b48b2ae01b427508f0.tar.bz2
dotty-934da77590dad2003fe850b48b2ae01b427508f0.zip
Merge pull request #2079 from dotty-staging/depmeth2
Allow inter-parameter dependencies
Diffstat (limited to 'compiler/src/dotty/tools/dotc/transform')
-rw-r--r--compiler/src/dotty/tools/dotc/transform/CollectEntryPoints.scala6
-rw-r--r--compiler/src/dotty/tools/dotc/transform/ElimByName.scala4
-rw-r--r--compiler/src/dotty/tools/dotc/transform/ElimRepeated.scala4
-rw-r--r--compiler/src/dotty/tools/dotc/transform/Erasure.scala13
-rw-r--r--compiler/src/dotty/tools/dotc/transform/ExpandSAMs.scala2
-rw-r--r--compiler/src/dotty/tools/dotc/transform/ExplicitOuter.scala6
-rw-r--r--compiler/src/dotty/tools/dotc/transform/FirstTransform.scala12
-rw-r--r--compiler/src/dotty/tools/dotc/transform/FullParameterization.scala13
-rw-r--r--compiler/src/dotty/tools/dotc/transform/LambdaLift.scala4
-rw-r--r--compiler/src/dotty/tools/dotc/transform/ParamForwarding.scala2
10 files changed, 34 insertions, 32 deletions
diff --git a/compiler/src/dotty/tools/dotc/transform/CollectEntryPoints.scala b/compiler/src/dotty/tools/dotc/transform/CollectEntryPoints.scala
index 331fce46a..9f1e42e31 100644
--- a/compiler/src/dotty/tools/dotc/transform/CollectEntryPoints.scala
+++ b/compiler/src/dotty/tools/dotc/transform/CollectEntryPoints.scala
@@ -64,7 +64,7 @@ class CollectEntryPoints extends MiniPhaseTransform {
val hasApproximate = possibles exists {
m =>
m.info match {
- case MethodType(_, p :: Nil) =>
+ case MethodTpe(_, p :: Nil, _) =>
p.typeSymbol == defn.ArrayClass
case _ => false
}
@@ -87,8 +87,8 @@ class CollectEntryPoints extends MiniPhaseTransform {
m.symbol.info match {
case t: PolyType =>
fail("main methods cannot be generic.")
- case t@MethodType(paramNames, paramTypes) =>
- if (t.resultType :: paramTypes exists (_.typeSymbol.isAbstractType))
+ case t: MethodType =>
+ if (t.resultType :: t.paramTypes exists (_.typeSymbol.isAbstractType))
fail("main methods cannot refer to type parameters or abstract types.", m.symbol.pos)
else
javaPlatform.isJavaMainMethod(m.symbol) || fail("main method must have exact signature (Array[String])Unit", m.symbol.pos)
diff --git a/compiler/src/dotty/tools/dotc/transform/ElimByName.scala b/compiler/src/dotty/tools/dotc/transform/ElimByName.scala
index 0e187fc2e..59da78590 100644
--- a/compiler/src/dotty/tools/dotc/transform/ElimByName.scala
+++ b/compiler/src/dotty/tools/dotc/transform/ElimByName.scala
@@ -92,8 +92,8 @@ class ElimByName extends MiniPhaseTransform with InfoTransformer { thisTransform
arg
}
- val MethodType(_, formals) = tree.fun.tpe.widen
- val args1 = tree.args.zipWithConserve(formals)(transformArg)
+ val mt @ MethodType(_) = tree.fun.tpe.widen
+ val args1 = tree.args.zipWithConserve(mt.paramTypes)(transformArg)
cpy.Apply(tree)(tree.fun, args1)
}
diff --git a/compiler/src/dotty/tools/dotc/transform/ElimRepeated.scala b/compiler/src/dotty/tools/dotc/transform/ElimRepeated.scala
index d955628e3..ae3259509 100644
--- a/compiler/src/dotty/tools/dotc/transform/ElimRepeated.scala
+++ b/compiler/src/dotty/tools/dotc/transform/ElimRepeated.scala
@@ -48,8 +48,8 @@ class ElimRepeated extends MiniPhaseTransform with InfoTransformer with Annotati
private def overridesJava(sym: Symbol)(implicit ctx: Context) = sym.allOverriddenSymbols.exists(_ is JavaDefined)
private def elimRepeated(tp: Type)(implicit ctx: Context): Type = tp.stripTypeVar match {
- case tp @ MethodType(paramNames, paramTypes) =>
- val resultType1 = elimRepeated(tp.resultType)
+ case tp @ MethodTpe(paramNames, paramTypes, resultType) =>
+ val resultType1 = elimRepeated(resultType)
val paramTypes1 =
if (paramTypes.nonEmpty && paramTypes.last.isRepeatedParam) {
val last = paramTypes.last.underlyingIfRepeated(tp.isJava)
diff --git a/compiler/src/dotty/tools/dotc/transform/Erasure.scala b/compiler/src/dotty/tools/dotc/transform/Erasure.scala
index 3857b405f..f9c7a8e1e 100644
--- a/compiler/src/dotty/tools/dotc/transform/Erasure.scala
+++ b/compiler/src/dotty/tools/dotc/transform/Erasure.scala
@@ -40,8 +40,8 @@ class Erasure extends Phase with DenotTransformer { thisTransformer =>
def isCompacted(sym: Symbol) =
sym.isAnonymousFunction && {
sym.info(ctx.withPhase(ctx.phase.next)) match {
- case MethodType(nme.ALLARGS :: Nil, _) => true
- case _ => false
+ case MethodType(nme.ALLARGS :: Nil) => true
+ case _ => false
}
}
@@ -269,7 +269,7 @@ object Erasure extends TypeTestsCasts{
def adaptToType(tree: Tree, pt: Type)(implicit ctx: Context): Tree =
if (pt.isInstanceOf[FunProto]) tree
else tree.tpe.widen match {
- case MethodType(Nil, _) if tree.isTerm =>
+ case MethodType(Nil) if tree.isTerm =>
adaptToType(tree.appliedToNone, pt)
case tpw =>
if (pt.isInstanceOf[ProtoType] || tree.tpe <:< pt)
@@ -697,9 +697,10 @@ object Erasure extends TypeTestsCasts{
val rhs = paramss.foldLeft(sel)((fun, vparams) =>
fun.tpe.widen match {
- case MethodType(names, types) => Apply(fun, (vparams, types).zipped.map(adapt(_, _, untpd.EmptyTree)))
- case a => error(s"can not resolve apply type $a")
-
+ case mt: MethodType =>
+ Apply(fun, (vparams, mt.paramTypes).zipped.map(adapt(_, _, untpd.EmptyTree)))
+ case a =>
+ error(s"can not resolve apply type $a")
})
adapt(rhs, resultType)
})
diff --git a/compiler/src/dotty/tools/dotc/transform/ExpandSAMs.scala b/compiler/src/dotty/tools/dotc/transform/ExpandSAMs.scala
index 91399f91a..7b15b7e54 100644
--- a/compiler/src/dotty/tools/dotc/transform/ExpandSAMs.scala
+++ b/compiler/src/dotty/tools/dotc/transform/ExpandSAMs.scala
@@ -53,7 +53,7 @@ class ExpandSAMs extends MiniPhaseTransform { thisTransformer =>
val applyRhs: Tree = applyDef.rhs
val applyFn = applyDef.symbol.asTerm
- val MethodType(paramNames, paramTypes) = applyFn.info
+ val MethodTpe(paramNames, paramTypes, _) = applyFn.info
val isDefinedAtFn = applyFn.copy(
name = nme.isDefinedAt,
flags = Synthetic | Method,
diff --git a/compiler/src/dotty/tools/dotc/transform/ExplicitOuter.scala b/compiler/src/dotty/tools/dotc/transform/ExplicitOuter.scala
index d75c32fcc..88c92685f 100644
--- a/compiler/src/dotty/tools/dotc/transform/ExplicitOuter.scala
+++ b/compiler/src/dotty/tools/dotc/transform/ExplicitOuter.scala
@@ -328,9 +328,9 @@ object ExplicitOuter {
/** If `cls` has an outer parameter add one to the method type `tp`. */
def addParam(cls: ClassSymbol, tp: Type): Type =
if (hasOuterParam(cls)) {
- val mt @ MethodType(pnames, ptypes) = tp
+ val mt @ MethodTpe(pnames, ptypes, restpe) = tp
mt.derivedMethodType(
- nme.OUTER :: pnames, cls.owner.enclosingClass.typeRef :: ptypes, mt.resultType)
+ nme.OUTER :: pnames, cls.owner.enclosingClass.typeRef :: ptypes, restpe)
} else tp
/** If function in an apply node is a constructor that needs to be passed an
@@ -389,7 +389,7 @@ object ExplicitOuter {
/** The outer parameter definition of a constructor if it needs one */
def paramDefs(constr: Symbol): List[ValDef] =
if (constr.isConstructor && hasOuterParam(constr.owner.asClass)) {
- val MethodType(outerName :: _, outerType :: _) = constr.info
+ val MethodTpe(outerName :: _, outerType :: _, _) = constr.info
val outerSym = ctx.newSymbol(constr, outerName, Param, outerType)
ValDef(outerSym) :: Nil
}
diff --git a/compiler/src/dotty/tools/dotc/transform/FirstTransform.scala b/compiler/src/dotty/tools/dotc/transform/FirstTransform.scala
index 9e71fda5d..8328e43de 100644
--- a/compiler/src/dotty/tools/dotc/transform/FirstTransform.scala
+++ b/compiler/src/dotty/tools/dotc/transform/FirstTransform.scala
@@ -29,7 +29,7 @@ import StdNames._
* - eliminates some kinds of trees: Imports, NamedArgs
* - stubs out native methods
* - eliminates self tree in Template and self symbol in ClassInfo
- * - collapsess all type trees to trees of class TypeTree
+ * - collapses all type trees to trees of class TypeTree
* - converts idempotent expressions with constant types
* - drops branches of ifs using the rules
* if (true) A else B --> A
@@ -151,7 +151,7 @@ class FirstTransform extends MiniPhaseTransform with InfoTransformer with Annota
override def transformTemplate(impl: Template)(implicit ctx: Context, info: TransformerInfo): Tree = {
cpy.Template(impl)(self = EmptyValDef)
}
-
+
override def transformDefDef(ddef: DefDef)(implicit ctx: Context, info: TransformerInfo) = {
if (ddef.symbol.hasAnnotation(defn.NativeAnnot)) {
ddef.symbol.resetFlag(Deferred)
@@ -171,13 +171,13 @@ class FirstTransform extends MiniPhaseTransform with InfoTransformer with Annota
}
override def transformIdent(tree: Ident)(implicit ctx: Context, info: TransformerInfo) =
- if (tree.isType) TypeTree(tree.tpe).withPos(tree.pos)
+ if (tree.isType) TypeTree(tree.tpe).withPos(tree.pos)
else constToLiteral(tree)
override def transformSelect(tree: Select)(implicit ctx: Context, info: TransformerInfo) =
- if (tree.isType) TypeTree(tree.tpe).withPos(tree.pos)
+ if (tree.isType) TypeTree(tree.tpe).withPos(tree.pos)
else constToLiteral(tree)
-
+
override def transformTypeApply(tree: TypeApply)(implicit ctx: Context, info: TransformerInfo) =
constToLiteral(tree)
@@ -186,7 +186,7 @@ class FirstTransform extends MiniPhaseTransform with InfoTransformer with Annota
override def transformTyped(tree: Typed)(implicit ctx: Context, info: TransformerInfo) =
constToLiteral(tree)
-
+
override def transformBlock(tree: Block)(implicit ctx: Context, info: TransformerInfo) =
constToLiteral(tree)
diff --git a/compiler/src/dotty/tools/dotc/transform/FullParameterization.scala b/compiler/src/dotty/tools/dotc/transform/FullParameterization.scala
index 5609817d8..0cb453b4c 100644
--- a/compiler/src/dotty/tools/dotc/transform/FullParameterization.scala
+++ b/compiler/src/dotty/tools/dotc/transform/FullParameterization.scala
@@ -105,8 +105,9 @@ trait FullParameterization {
def resultType(mapClassParams: Type => Type) = {
val thisParamType = mapClassParams(clazz.classInfo.selfType)
val firstArgType = if (liftThisType) thisParamType & clazz.thisType else thisParamType
- MethodType(nme.SELF :: Nil, firstArgType :: Nil)(mt =>
- mapClassParams(origResult).substThisUnlessStatic(clazz, MethodParam(mt, 0)))
+ MethodType(nme.SELF :: Nil)(
+ mt => firstArgType :: Nil,
+ mt => mapClassParams(origResult).substThisUnlessStatic(clazz, MethodParam(mt, 0)))
}
/** Replace class type parameters by the added type parameters of the polytype `pt` */
@@ -252,10 +253,10 @@ object FullParameterization {
def memberSignature(info: Type)(implicit ctx: Context): Signature = info match {
case info: PolyType =>
memberSignature(info.resultType)
- case info @ MethodType(nme.SELF :: Nil, _) =>
- info.resultType.ensureMethodic.signature
- case info @ MethodType(nme.SELF :: otherNames, thisType :: otherTypes) =>
- info.derivedMethodType(otherNames, otherTypes, info.resultType).signature
+ case MethodTpe(nme.SELF :: Nil, _, restpe) =>
+ restpe.ensureMethodic.signature
+ case info @ MethodTpe(nme.SELF :: otherNames, thisType :: otherTypes, restpe) =>
+ info.derivedMethodType(otherNames, otherTypes, restpe).signature
case _ =>
Signature.NotAMethod
}
diff --git a/compiler/src/dotty/tools/dotc/transform/LambdaLift.scala b/compiler/src/dotty/tools/dotc/transform/LambdaLift.scala
index b603a53dc..7578b57f1 100644
--- a/compiler/src/dotty/tools/dotc/transform/LambdaLift.scala
+++ b/compiler/src/dotty/tools/dotc/transform/LambdaLift.scala
@@ -352,12 +352,12 @@ class LambdaLift extends MiniPhase with IdentityDenotTransformer { thisTransform
}
private def liftedInfo(local: Symbol)(implicit ctx: Context): Type = local.info match {
- case mt @ MethodType(pnames, ptypes) =>
+ case MethodTpe(pnames, ptypes, restpe) =>
val ps = proxies(local)
MethodType(
ps.map(_.name.asTermName) ++ pnames,
ps.map(_.info) ++ ptypes,
- mt.resultType)
+ restpe)
case info => info
}
diff --git a/compiler/src/dotty/tools/dotc/transform/ParamForwarding.scala b/compiler/src/dotty/tools/dotc/transform/ParamForwarding.scala
index a72e10681..859ac8b06 100644
--- a/compiler/src/dotty/tools/dotc/transform/ParamForwarding.scala
+++ b/compiler/src/dotty/tools/dotc/transform/ParamForwarding.scala
@@ -27,7 +27,7 @@ class ParamForwarding(thisTransformer: DenotTransformer) {
val (superArgs, superParamNames) = impl.parents match {
case superCall @ Apply(fn, args) :: _ =>
fn.tpe.widen match {
- case MethodType(paramNames, _) => (args, paramNames)
+ case MethodType(paramNames) => (args, paramNames)
case _ => (Nil, Nil)
}
case _ => (Nil, Nil)