aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dotty/tools/dotc/ast/Desugar.scala4
-rw-r--r--src/dotty/tools/dotc/typer/Applications.scala7
-rw-r--r--src/dotty/tools/dotc/typer/Typer.scala8
3 files changed, 13 insertions, 6 deletions
diff --git a/src/dotty/tools/dotc/ast/Desugar.scala b/src/dotty/tools/dotc/ast/Desugar.scala
index e6c43acbb..f8f5972d1 100644
--- a/src/dotty/tools/dotc/ast/Desugar.scala
+++ b/src/dotty/tools/dotc/ast/Desugar.scala
@@ -258,7 +258,9 @@ object desugar {
else (vparamss :\ classTypeRef) ((vparams, restpe) => Function(vparams map (_.tpt), restpe))
val applyMeths =
if (mods is Abstract) Nil
- else DefDef(synthetic, nme.apply, tparams, vparamss, TypeTree(), creatorExpr) :: Nil
+ else DefDef(
+ synthetic | (constr1.mods.flags & DefaultParameterized), nme.apply,
+ tparams, vparamss, TypeTree(), creatorExpr) :: Nil
val unapplyMeth = {
val unapplyParam = makeSyntheticParameter(tpt = classTypeRef)
DefDef(synthetic, nme.unapply, tparams, (unapplyParam :: Nil) :: Nil,
diff --git a/src/dotty/tools/dotc/typer/Applications.scala b/src/dotty/tools/dotc/typer/Applications.scala
index 9efa7d49e..27e142e55 100644
--- a/src/dotty/tools/dotc/typer/Applications.scala
+++ b/src/dotty/tools/dotc/typer/Applications.scala
@@ -193,10 +193,12 @@ trait Applications extends Compatibility { self: Typer =>
* parameter list, or NoType if none was found
*/
def findDefaultGetter(n: Int)(implicit ctx: Context): Type = {
- def getterName = methRef.name.toTermName.defaultGetterName(n)
+ val meth = methRef.symbol
+ val prefix =
+ if ((meth is Synthetic) && meth.name == nme.apply) nme.CONSTRUCTOR else methRef.name
+ def getterName = prefix.defaultGetterName(n)
def ref(pre: Type, sym: Symbol): Type =
if (pre.exists && sym.isTerm) pre select sym else NoType
- val meth = methRef.symbol
if (meth.hasDefaultParams)
methRef.prefix match {
case NoPrefix =>
@@ -221,7 +223,6 @@ trait Applications extends Compatibility { self: Typer =>
}
} else mpre
val getter = pre.member(getterName)
- assert(getter.exists, getterName)
ref(pre, getter.symbol)
}
else NoType
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala
index 99d5f6b98..016229bc2 100644
--- a/src/dotty/tools/dotc/typer/Typer.scala
+++ b/src/dotty/tools/dotc/typer/Typer.scala
@@ -1143,8 +1143,12 @@ class Typer extends Namer with Applications with Implicits {
}
case wtp =>
pt match {
- case pt: FunProto => adaptToArgs(wtp, pt)
- case pt: PolyProto => tree // error will be reported in typedTypeApply
+ case pt: FunProto =>
+ adaptToArgs(wtp, pt)
+ case pt: PolyProto =>
+ tryInsertApply(tree, pt) {
+ (_, _) => tree // error will be reported in typedTypeApply
+ }
case _ =>
if (ctx.mode is Mode.Type)
if (tree.tpe <:< pt) tree