diff options
author | Martin Odersky <odersky@gmail.com> | 2014-11-21 15:55:07 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2014-11-24 14:57:49 +0100 |
commit | 832957339c850a64fb7093f3ed6b19c91c5bdfac (patch) | |
tree | 1ae369bd8b685c4ec017716a19e660b204e31cb8 /src | |
parent | 7427c671f9a5321dd13a74b5175bba512699b385 (diff) | |
download | dotty-832957339c850a64fb7093f3ed6b19c91c5bdfac.tar.gz dotty-832957339c850a64fb7093f3ed6b19c91c5bdfac.tar.bz2 dotty-832957339c850a64fb7093f3ed6b19c91c5bdfac.zip |
Fix to checkBounds
Need to account for the fact that some argument types may be TypeBoudns themselves.
The change makes Jason's latest example work.
Diffstat (limited to 'src')
-rw-r--r-- | src/dotty/tools/dotc/transform/FirstTransform.scala | 8 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/Checking.scala | 4 |
2 files changed, 8 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/transform/FirstTransform.scala b/src/dotty/tools/dotc/transform/FirstTransform.scala index 0dac38a78..a58e8a643 100644 --- a/src/dotty/tools/dotc/transform/FirstTransform.scala +++ b/src/dotty/tools/dotc/transform/FirstTransform.scala @@ -141,8 +141,12 @@ class FirstTransform extends MiniPhaseTransform with IdentityDenotTransformer wi val tparams = tycon.tpe.typeSymbol.typeParams val bounds = tparams.map(tparam => tparam.info.asSeenFrom(tycon.tpe.normalizedPrefix, tparam.owner.owner).bounds) - Checking.checkBounds( - args, bounds, (tp, argTypes) => tp.substDealias(tparams, argTypes)) + def instantiateUpperBound(tp: Type, argTypes: List[Type]): Type = { + tp.substDealias(tparams, argTypes).bounds.hi + // not that argTypes can contain a TypeBounds type for arguments that are + // not fully determined. In that case we need to check against the hi bound. + } + Checking.checkBounds(args, bounds, instantiateUpperBound) normalizeType(tree) case tree => normalizeType(tree) diff --git a/src/dotty/tools/dotc/typer/Checking.scala b/src/dotty/tools/dotc/typer/Checking.scala index 982b97f7e..fdc70e207 100644 --- a/src/dotty/tools/dotc/typer/Checking.scala +++ b/src/dotty/tools/dotc/typer/Checking.scala @@ -33,9 +33,9 @@ object Checking { /** A general checkBounds method that can be used for TypeApply nodes as * well as for AppliedTypeTree nodes. */ - def checkBounds(args: List[tpd.Tree], bounds: List[TypeBounds], instantiate: (Type, List[Type]) => Type)(implicit ctx: Context) = { + def checkBounds(args: List[tpd.Tree], boundss: List[TypeBounds], instantiate: (Type, List[Type]) => Type)(implicit ctx: Context) = { val argTypes = args.tpes - for ((arg, bounds) <- args zip bounds) { + for ((arg, bounds) <- args zip boundss) { def notConforms(which: String, bound: Type) = { ctx.error( d"Type argument ${arg.tpe} does not conform to $which bound $bound ${err.whyNoMatchStr(arg.tpe, bound)}", |