From 2711b4cd95e736d481a699cce2a534b141e6df59 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Fri, 26 Jan 2018 14:03:41 +0100 Subject: [PATCH 1/2] Fix #3901: Survive parameter dependencies on by-name parameters --- compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala | 2 +- tests/neg/i3901.scala | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 tests/neg/i3901.scala diff --git a/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala b/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala index 2764f6b98707..36e288fbc91a 100644 --- a/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala +++ b/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala @@ -418,7 +418,7 @@ object ProtoTypes { /** Create a new TypeVar that represents a dependent method parameter singleton */ def newDepTypeVar(tp: Type)(implicit ctx: Context): TypeVar = - newTypeVar(TypeBounds.upper(AndType(tp, defn.SingletonClass.typeRef))) + newTypeVar(TypeBounds.upper(AndType(tp.widenExpr, defn.SingletonClass.typeRef))) /** The result type of `mt`, where all references to parameters of `mt` are * replaced by either wildcards (if typevarsMissContext) or TypeParamRefs. diff --git a/tests/neg/i3901.scala b/tests/neg/i3901.scala new file mode 100644 index 000000000000..6d574cb6e60b --- /dev/null +++ b/tests/neg/i3901.scala @@ -0,0 +1,4 @@ +object Crash { + def f(cond: => Boolean): cond.type = ??? + f(true) +} From a0a45b69be1441ff268cb663ef258bec9892623c Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Fri, 26 Jan 2018 16:26:30 +0100 Subject: [PATCH 2/2] Fix test error annotation --- tests/neg/i3901.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/neg/i3901.scala b/tests/neg/i3901.scala index 6d574cb6e60b..8e1451d4628e 100644 --- a/tests/neg/i3901.scala +++ b/tests/neg/i3901.scala @@ -1,4 +1,4 @@ object Crash { - def f(cond: => Boolean): cond.type = ??? + def f(cond: => Boolean): cond.type = ??? // error: cond is not stable f(true) }