aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Martres <smarter@ubuntu.com>2016-02-18 18:44:00 +0100
committerGuillaume Martres <smarter@ubuntu.com>2016-02-18 18:54:54 +0100
commit48cd10159573150ed41c86d45c259cf6ad1a0c8e (patch)
tree04728f51325eef76743db0477617731acfdc73cc
parent4be70a5a8469c1355c84bef70936a81f899a9678 (diff)
downloaddotty-48cd10159573150ed41c86d45c259cf6ad1a0c8e.tar.gz
dotty-48cd10159573150ed41c86d45c259cf6ad1a0c8e.tar.bz2
dotty-48cd10159573150ed41c86d45c259cf6ad1a0c8e.zip
ProtoTypes#wildApprox: fix LazyRef approximation
Before this commit, the output of `wildApprox(A)` where `A <: Sys[LazyRef(A)]` was `? <: Sys[LazyRef(() => wildApprox(A))]`. This lead to infinite subtyping checks. This is fixed by always approximating a LazyRef by an unbounded wildcard. Since we only create LazyRefs when we encounter a cycle, this should be safe. Fix #1103.
-rw-r--r--src/dotty/tools/dotc/typer/ProtoTypes.scala2
-rw-r--r--tests/pos/i1103.scala5
2 files changed, 7 insertions, 0 deletions
diff --git a/src/dotty/tools/dotc/typer/ProtoTypes.scala b/src/dotty/tools/dotc/typer/ProtoTypes.scala
index 8a758bcc8..7997d1cf4 100644
--- a/src/dotty/tools/dotc/typer/ProtoTypes.scala
+++ b/src/dotty/tools/dotc/typer/ProtoTypes.scala
@@ -420,6 +420,8 @@ object ProtoTypes {
WildcardType(tp1a.bounds | tp2a.bounds)
else
tp.derivedOrType(tp1a, tp2a)
+ case tp: LazyRef =>
+ WildcardType
case tp: SelectionProto =>
tp.derivedSelectionProto(tp.name, wildApprox(tp.memberProto), NoViewsAllowed)
case tp: ViewProto =>
diff --git a/tests/pos/i1103.scala b/tests/pos/i1103.scala
new file mode 100644
index 000000000..dcc391a6a
--- /dev/null
+++ b/tests/pos/i1103.scala
@@ -0,0 +1,5 @@
+class Sys[S]
+class Foo[T <: Sys[T]] {
+ val t: T = ???
+ def foo[A <: Sys[A]](x: A = t) = x
+}