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..8e1451d4628e --- /dev/null +++ b/tests/neg/i3901.scala @@ -0,0 +1,4 @@ +object Crash { + def f(cond: => Boolean): cond.type = ??? // error: cond is not stable + f(true) +}