aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/transform/PostTyper.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/dotty/tools/dotc/transform/PostTyper.scala')
-rw-r--r--src/dotty/tools/dotc/transform/PostTyper.scala20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/transform/PostTyper.scala b/src/dotty/tools/dotc/transform/PostTyper.scala
index fcde59b24..b71284049 100644
--- a/src/dotty/tools/dotc/transform/PostTyper.scala
+++ b/src/dotty/tools/dotc/transform/PostTyper.scala
@@ -13,6 +13,7 @@ import Types._, Contexts._, Constants._, Names._, NameOps._, Flags._, DenotTrans
import SymDenotations._, Symbols._, StdNames._, Annotations._, Trees._, Scopes._, Denotations._
import util.Positions._
import Decorators._
+import config.Printers._
import Symbols._, TypeUtils._
/** A macro transform that runs immediately after typer and that performs the following functions:
@@ -115,6 +116,17 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisTran
}
}
+ /** If the type of `tree` is a TermRefWithSignature with an underdefined
+ * signature, narrow the type by re-computing the signature (which should
+ * be fully-defined by now).
+ */
+ private def fixSignature[T <: Tree](tree: T)(implicit ctx: Context): T = tree.tpe match {
+ case tpe: TermRefWithSignature if tpe.signature.isUnderDefined =>
+ typr.println(i"fixing $tree with type ${tree.tpe.widen.toString} with sig ${tpe.signature} to ${tpe.widen.signature}")
+ tree.withType(TermRef.withSig(tpe.prefix, tpe.name, tpe.widen.signature)).asInstanceOf[T]
+ case _ => tree
+ }
+
class PostTyperTransformer extends Transformer {
private var inJavaAnnot: Boolean = false
@@ -178,9 +190,9 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisTran
}
val (tycon, args) = decompose(tree)
tycon.tpe.widen match {
- case PolyType(pnames) =>
+ case tp: PolyType =>
val (namedArgs, otherArgs) = args.partition(isNamedArg)
- val args1 = reorderArgs(pnames, namedArgs.asInstanceOf[List[NamedArg]], otherArgs)
+ val args1 = reorderArgs(tp.paramNames, namedArgs.asInstanceOf[List[NamedArg]], otherArgs)
TypeApply(tycon, args1).withPos(tree.pos).withType(tree.tpe)
case _ =>
tree
@@ -192,10 +204,10 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisTran
case tree: Ident =>
tree.tpe match {
case tpe: ThisType => This(tpe.cls).withPos(tree.pos)
- case _ => paramFwd.adaptRef(tree)
+ case _ => paramFwd.adaptRef(fixSignature(tree))
}
case tree: Select =>
- transformSelect(paramFwd.adaptRef(tree), Nil)
+ transformSelect(paramFwd.adaptRef(fixSignature(tree)), Nil)
case tree: TypeApply =>
val tree1 @ TypeApply(fn, args) = normalizeTypeArgs(tree)
Checking.checkBounds(args, fn.tpe.widen.asInstanceOf[PolyType])