summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2014-11-07 19:23:04 +1000
committerSom Snytt <som.snytt@gmail.com>2015-02-28 07:45:49 -0800
commitabc12d772c30e4e54f5740569950c730de008c2e (patch)
tree3f58fb984cf439f95bd0a7d5e6d0a09232bb161b
parentd30098c30de94e6ec07b5c8b6782357183e24179 (diff)
downloadscala-abc12d772c30e4e54f5740569950c730de008c2e.tar.gz
scala-abc12d772c30e4e54f5740569950c730de008c2e.tar.bz2
scala-abc12d772c30e4e54f5740569950c730de008c2e.zip
SI-7784 Allow a singleton type over a constant value defn.
When typechecking a `SingletonTypeTree`, we must `deconst` the type of the typechecked reference tree to avoid collapsing `a.type` into a constant type if `a` is a constant value definition.
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala2
-rw-r--r--test/files/neg/logImplicits.check2
-rw-r--r--test/files/pos/t7784.scala9
3 files changed, 11 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index e883bacc88..7f86a59164 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -5193,7 +5193,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
if (refTyped.isErrorTyped) {
setError(tree)
} else {
- tree setType refTyped.tpe.resultType
+ tree setType refTyped.tpe.resultType.deconst
if (refTyped.isErrorTyped || treeInfo.admitsTypeSelection(refTyped)) tree
else UnstableTreeError(tree)
}
diff --git a/test/files/neg/logImplicits.check b/test/files/neg/logImplicits.check
index 270882b71a..f9eb79645b 100644
--- a/test/files/neg/logImplicits.check
+++ b/test/files/neg/logImplicits.check
@@ -4,7 +4,7 @@ logImplicits.scala:2: applied implicit conversion from xs.type to ?{def size: ?}
logImplicits.scala:7: applied implicit conversion from String("abc") to ?{def map: ?} = implicit def augmentString(x: String): scala.collection.immutable.StringOps
def f = "abc" map (_ + 1)
^
-logImplicits.scala:15: inferred view from String("abc") to Int = C.this.convert:(p: String("abc"))Int
+logImplicits.scala:15: inferred view from String("abc") to Int = C.this.convert:(p: String)Int
math.max(122, x: Int)
^
logImplicits.scala:19: applied implicit conversion from Int(1) to ?{def ->: ?} = implicit def ArrowAssoc[A](self: A): ArrowAssoc[A]
diff --git a/test/files/pos/t7784.scala b/test/files/pos/t7784.scala
new file mode 100644
index 0000000000..4260ca26a2
--- /dev/null
+++ b/test/files/pos/t7784.scala
@@ -0,0 +1,9 @@
+object Test {
+ final val a = ""
+ var b: a.type = a
+ b = a
+
+ final val x = classOf[Object]
+ var y: x.type = x
+ y = x
+}