diff options
author | Martin Odersky <odersky@gmail.com> | 2014-01-09 20:37:49 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2014-01-09 20:37:49 +0100 |
commit | 6135d51b35ec20199231984e978a6be99169d351 (patch) | |
tree | 49774cca22ae4701048c585ce3bd443f5d7410d0 /src/dotty/tools/dotc/typer/Applications.scala | |
parent | 5df489a794d5a7d0e70fcfeb968b6e4bb9cd9953 (diff) | |
download | dotty-6135d51b35ec20199231984e978a6be99169d351.tar.gz dotty-6135d51b35ec20199231984e978a6be99169d351.tar.bz2 dotty-6135d51b35ec20199231984e978a6be99169d351.zip |
Avoid dropping errors in typedApply
Previous logic dropped some errors on retry, when typedUnadapted did not change qual.
Also: Special case repeated parameters in isAsSpecific. Those have to be converted to the underlying parameters, so that
(xs: Int*)T
is as specific as
(xs: Long*)T
Diffstat (limited to 'src/dotty/tools/dotc/typer/Applications.scala')
-rw-r--r-- | src/dotty/tools/dotc/typer/Applications.scala | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/dotty/tools/dotc/typer/Applications.scala b/src/dotty/tools/dotc/typer/Applications.scala index af14fb72b..d70c19f96 100644 --- a/src/dotty/tools/dotc/typer/Applications.scala +++ b/src/dotty/tools/dotc/typer/Applications.scala @@ -449,11 +449,8 @@ trait Applications extends Compatibility { self: Typer => // implicit conversion around []. (an example is Int + BigInt). tryEither { implicit ctx => val qual1 = adaptInterpolated(qual, new SelectionProto(name, proto)) - if (qual1 eq qual) { - failedState.commit() - failedVal - } - else if (qual1.tpe.isError) qual1 + if (qual eq qual1) ctx.error("no progress") + if (ctx.reporter.hasErrors) qual1 else typedApply( cpy.Apply(tree, @@ -750,20 +747,21 @@ trait Applications extends Compatibility { self: Typer => * 2. `tp2` and `tp1` are method or poly types and `tp2` can be applied to the parameters of `tp1`. * 3. Neither `tp1` nor `tp2` are method or poly types and `tp1` is compatible with `tp2`. */ - def isAsSpecific(alt1: TermRef, tp1: Type, alt2: TermRef, tp2: Type): Boolean = tp1 match { + def isAsSpecific(alt1: TermRef, tp1: Type, alt2: TermRef, tp2: Type): Boolean = ctx.traceIndented(i"isAsSpecific $tp1 $tp2") { tp1 match { case tp1: PolyType => def bounds(tparamRefs: List[TypeRef]) = tp1.paramBounds map (_.substParams(tp1, tparamRefs)) val tparams = ctx.newTypeParams(alt1.symbol.owner, tp1.paramNames, EmptyFlags, bounds) isAsSpecific(alt1, tp1.instantiate(tparams map (_.typeRef)), alt2, tp2) case tp1: MethodType => - isApplicable(alt2, tp1.paramTypes, WildcardType) || + def repeatedToSingle(tp: Type) = if (tp.isRepeatedParam) tp.typeArgs.head else tp + isApplicable(alt2, tp1.paramTypes map repeatedToSingle, WildcardType) || tp1.paramTypes.isEmpty && tp2.isInstanceOf[MethodOrPoly] case _ => tp2 match { case tp2: MethodOrPoly => true case _ => isCompatible(tp1, tp2) } - } + }} val owner1 = alt1.symbol.owner val owner2 = alt2.symbol.owner |