aboutsummaryrefslogtreecommitdiff
path: root/src/dotty
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-12-06 12:44:00 +0100
committerMartin Odersky <odersky@gmail.com>2015-12-06 16:17:44 +0100
commitf6d1153e193045ad4d8a1564e3c0cdb49b853a5b (patch)
treea013e385dc95774a843aa384cd8cdf81f31857b9 /src/dotty
parent50d265299ab99ace68e3813794559de2bbcdc91c (diff)
downloaddotty-f6d1153e193045ad4d8a1564e3c0cdb49b853a5b.tar.gz
dotty-f6d1153e193045ad4d8a1564e3c0cdb49b853a5b.tar.bz2
dotty-f6d1153e193045ad4d8a1564e3c0cdb49b853a5b.zip
Avoid false positives when extracting AppliedType
Diffstat (limited to 'src/dotty')
-rw-r--r--src/dotty/tools/dotc/core/TypeApplications.scala8
-rw-r--r--src/dotty/tools/dotc/core/Types.scala12
2 files changed, 18 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/core/TypeApplications.scala b/src/dotty/tools/dotc/core/TypeApplications.scala
index db7550402..ab15b3e1a 100644
--- a/src/dotty/tools/dotc/core/TypeApplications.scala
+++ b/src/dotty/tools/dotc/core/TypeApplications.scala
@@ -133,7 +133,13 @@ object TypeApplications {
def unapply(tp: Type)(implicit ctx: Context): Option[(Type, List[Type])] = tp match {
case TypeRef(prefix, tpnme.hkApply) => unapp(prefix)
- case _ => unapp(tp)
+ case _ =>
+ unapp(tp) match {
+ case Some((tycon: TypeRef, _)) if tycon.symbol.isLambdaTrait =>
+ // We are seeing part of a lambda abstraction, not an applied type
+ None
+ case x => x
+ }
}
private def unapp(tp: Type)(implicit ctx: Context): Option[(Type, List[Type])] = tp match {
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala
index 54e6397bb..b5d5c864b 100644
--- a/src/dotty/tools/dotc/core/Types.scala
+++ b/src/dotty/tools/dotc/core/Types.scala
@@ -1899,7 +1899,17 @@ object Types {
override def underlying(implicit ctx: Context) = parent
- private def checkInst(implicit ctx: Context): this.type = this
+ private def badInst =
+ throw new AssertionError(s"bad instantiation: $this")
+
+ def checkInst(implicit ctx: Context): this.type = {
+ if (refinedName == tpnme.hkApply)
+ parent.stripTypeVar match {
+ case RefinedType(_, name) if name.isHkArgName => // ok
+ case _ => badInst
+ }
+ this
+ }
def derivedRefinedType(parent: Type, refinedName: Name, refinedInfo: Type)(implicit ctx: Context): RefinedType =
if ((parent eq this.parent) && (refinedName eq this.refinedName) && (refinedInfo eq this.refinedInfo)) this