diff options
author | Martin Odersky <odersky@gmail.com> | 2016-03-19 19:46:47 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-03-30 09:51:02 +0200 |
commit | b49034715ac5dc5d3f8427b39e497d3e20c4c192 (patch) | |
tree | e0bfb21b474dc2b37e7a3d43b39ab8df0c1a32bc /src/dotty/tools/dotc/typer/TypeAssigner.scala | |
parent | 0855b071d913e7acd5271ab34062c69e25cd93cd (diff) | |
download | dotty-b49034715ac5dc5d3f8427b39e497d3e20c4c192.tar.gz dotty-b49034715ac5dc5d3f8427b39e497d3e20c4c192.tar.bz2 dotty-b49034715ac5dc5d3f8427b39e497d3e20c4c192.zip |
Simplify and fix avoid logic
The previous formulation broke for named parameters.
Test case in flowops1.scala.
Diffstat (limited to 'src/dotty/tools/dotc/typer/TypeAssigner.scala')
-rw-r--r-- | src/dotty/tools/dotc/typer/TypeAssigner.scala | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/src/dotty/tools/dotc/typer/TypeAssigner.scala b/src/dotty/tools/dotc/typer/TypeAssigner.scala index 84951fd2b..840346536 100644 --- a/src/dotty/tools/dotc/typer/TypeAssigner.scala +++ b/src/dotty/tools/dotc/typer/TypeAssigner.scala @@ -6,6 +6,7 @@ import core._ import ast._ import Scopes._, Contexts._, Constants._, Types._, Symbols._, Names._, Flags._, Decorators._ import ErrorReporting._, Annotations._, Denotations._, SymDenotations._, StdNames._, TypeErasure._ +import TypeApplications.AppliedType import util.Positions._ import config.Printers._ import ast.Trees._ @@ -93,27 +94,17 @@ trait TypeAssigner { case _ => mapOver(tp) } + case tp @ AppliedType(tycon, args) if toAvoid(tycon) => + val base = apply(tycon) + apply(base.appliedTo(tp.baseArgInfos(base.typeSymbol))) case tp @ RefinedType(parent, name) if variance > 0 => - // The naive approach here would be to first approximate the parent, - // but if the base type of the approximated parent is different from - // the current base type, then the current refinement won't be valid - // if it's a type parameter refinement. - // Therefore we first approximate the base type, then use `baseArgInfos` - // to get correct refinements for the approximated base type, then - // recursively approximate the resulting type. - val base = tp.unrefine - if (toAvoid(base)) { - val base1 = apply(base) - apply(base1.appliedTo(tp.baseArgInfos(base1.typeSymbol))) + val parent1 = apply(tp.parent) + val refinedInfo1 = apply(tp.refinedInfo) + if (toAvoid(refinedInfo1)) { + typr.println(s"dropping refinement from $tp") + parent1 } else { - val parent1 = apply(tp.parent) - val refinedInfo1 = apply(tp.refinedInfo) - if (toAvoid(refinedInfo1)) { - typr.println(s"dropping refinement from $tp") - parent1 - } else { - tp.derivedRefinedType(parent1, name, refinedInfo1) - } + tp.derivedRefinedType(parent1, name, refinedInfo1) } case tp: TypeVar if ctx.typerState.constraint.contains(tp) => val lo = ctx.typerState.constraint.fullLowerBound(tp.origin) |