aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/Signature.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-06-29 20:26:08 +0200
committerMartin Odersky <odersky@gmail.com>2016-07-11 13:35:06 +0200
commitae360e93ad7f657992fc305e1b0755ef3ff0f166 (patch)
tree1470c75977f959f8552264fc006665bb97555fec /src/dotty/tools/dotc/core/Signature.scala
parent6bd7ba9ea4484ee2065dd16077cba6c26b2050d9 (diff)
downloaddotty-ae360e93ad7f657992fc305e1b0755ef3ff0f166.tar.gz
dotty-ae360e93ad7f657992fc305e1b0755ef3ff0f166.tar.bz2
dotty-ae360e93ad7f657992fc305e1b0755ef3ff0f166.zip
Handle signatures over uninstantiated type variables
Taking the signature over a type with uninstantiated type variables means that the signature can change later, once we instantiate the type variable. We handle this by recording uninstantiated positions of signatures and fixing them in PostTyper, when type variables are instantiated. - This allows to drop the kludge of "normalizing" in derivedRefinedType Dropping this initially revealed the problems with under-determined signatures. Now that these problems are fixed, we can drop for good.
Diffstat (limited to 'src/dotty/tools/dotc/core/Signature.scala')
-rw-r--r--src/dotty/tools/dotc/core/Signature.scala20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/dotty/tools/dotc/core/Signature.scala b/src/dotty/tools/dotc/core/Signature.scala
index 54771bae5..984315f18 100644
--- a/src/dotty/tools/dotc/core/Signature.scala
+++ b/src/dotty/tools/dotc/core/Signature.scala
@@ -29,6 +29,19 @@ case class Signature(paramsSig: List[TypeName], resSig: TypeName) {
/** Does this signature coincide with that signature on their parameter parts? */
final def sameParams(that: Signature): Boolean = this.paramsSig == that.paramsSig
+ /** Does this signature coincide with that signature on their parameter parts?
+ * This is the case if all parameter names are _consistent_, i.e. they are either
+ * equal or on of them is tpnme.Uninstantiated.
+ */
+ final def consistentParams(that: Signature): Boolean = {
+ def consistent(name1: TypeName, name2: TypeName) =
+ name1 == name2 || name1 == tpnme.Uninstantiated || name2 == tpnme.Uninstantiated
+ def loop(names1: List[TypeName], names2: List[TypeName]): Boolean =
+ if (names1.isEmpty) names2.isEmpty
+ else names2.nonEmpty && consistent(names1.head, names2.head) && loop(names1.tail, names2.tail)
+ loop(this.paramsSig, that.paramsSig)
+ }
+
/** The degree to which this signature matches `that`.
* If both parameter and result type names match (i.e. they are the same
* or one is a wildcard), the result is `FullMatch`.
@@ -52,6 +65,13 @@ case class Signature(paramsSig: List[TypeName], resSig: TypeName) {
def prepend(params: List[Type], isJava: Boolean)(implicit ctx: Context) =
Signature((params.map(sigName(_, isJava))) ++ paramsSig, resSig)
+ /** A signature is under-defined if its paramsSig part contains at least one
+ * `tpnme.Uninstantited`. Under-defined signatures arise when taking a signature
+ * of a type that still contains uninstantiated type variables. They are eliminated
+ * by `fixSignature` in `PostTyper`.
+ */
+ def isUnderDefined(implicit ctx: Context) =
+ paramsSig.contains(tpnme.Uninstantiated) || resSig == tpnme.Uninstantiated
}
object Signature {