aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/typer/Typer.scala
diff options
context:
space:
mode:
authorFelix Mulder <felix.mulder@gmail.com>2016-08-25 16:27:06 +0200
committerFelix Mulder <felix.mulder@gmail.com>2016-10-06 17:09:08 +0200
commit7a5244027cb7257b3e350a37fc2f48e263c4ca7e (patch)
treeb2356b023a8ea9b8f16d2f266077c86095e95006 /src/dotty/tools/dotc/typer/Typer.scala
parent1e61c8c4cd7362331cff60245d1a5451f299d674 (diff)
downloaddotty-7a5244027cb7257b3e350a37fc2f48e263c4ca7e.tar.gz
dotty-7a5244027cb7257b3e350a37fc2f48e263c4ca7e.tar.bz2
dotty-7a5244027cb7257b3e350a37fc2f48e263c4ca7e.zip
Fix type parameters not getting properly typed
Diffstat (limited to 'src/dotty/tools/dotc/typer/Typer.scala')
-rw-r--r--src/dotty/tools/dotc/typer/Typer.scala19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala
index 56571116a..d633e5653 100644
--- a/src/dotty/tools/dotc/typer/Typer.scala
+++ b/src/dotty/tools/dotc/typer/Typer.scala
@@ -1182,9 +1182,6 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
tpt1 = tpt1.withType(avoid(tpt1.tpe, vparamss1.flatMap(_.map(_.symbol))))
}
- /** Type usecases */
- ctx.docbase.docstring(sym).map(_.usecases.map(_.typeTree()))
-
assignType(cpy.DefDef(ddef)(name, tparams1, vparamss1, tpt1, rhs1), sym)
//todo: make sure dependent method types do not depend on implicits or by-name params
}
@@ -1523,7 +1520,9 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
buf += typed(stat)(ctx.exprContext(stat, exprOwner))
traverse(rest)
case nil =>
- buf.toList
+ val tpdStats = buf.toList
+ typedUsecases(tpdStats.map(_.symbol), exprOwner)
+ tpdStats
}
traverse(stats)
}
@@ -1536,6 +1535,18 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
tpd.cpy.DefDef(mdef)(rhs = Inliner.bodyToInline(mdef.symbol)) ::
Inliner.removeInlineAccessors(mdef.symbol)
+ def typedUsecases(syms: List[Symbol], owner: Symbol)(implicit ctx: Context): Unit =
+ for {
+ sym <- syms
+ usecase <- ctx.docbase.docstring(sym).map(_.usecases).getOrElse(Nil)
+ List(tpdTree) = typedStats(usecase.untpdCode :: Nil, owner)
+ } yield {
+ if (tpdTree.isInstanceOf[tpd.DefDef])
+ usecase.tpdCode = tpdTree.asInstanceOf[tpd.DefDef]
+ else
+ ctx.error("Couldn't compile `@usecase`", usecase.codePos)
+ }
+
def typedExpr(tree: untpd.Tree, pt: Type = WildcardType)(implicit ctx: Context): Tree =
typed(tree, pt)(ctx retractMode Mode.PatternOrType)
def typedType(tree: untpd.Tree, pt: Type = WildcardType)(implicit ctx: Context): Tree = // todo: retract mode between Type and Pattern?