Skip to content

Commit 1793e86

Browse files
authored
Merge pull request #3924 from dotty-staging/fix-#3901
Fix #3901: Survive parameter dependencies on by-name parameters
2 parents 46956b0 + a0a45b6 commit 1793e86

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ object ProtoTypes {
418418

419419
/** Create a new TypeVar that represents a dependent method parameter singleton */
420420
def newDepTypeVar(tp: Type)(implicit ctx: Context): TypeVar =
421-
newTypeVar(TypeBounds.upper(AndType(tp, defn.SingletonClass.typeRef)))
421+
newTypeVar(TypeBounds.upper(AndType(tp.widenExpr, defn.SingletonClass.typeRef)))
422422

423423
/** The result type of `mt`, where all references to parameters of `mt` are
424424
* replaced by either wildcards (if typevarsMissContext) or TypeParamRefs.

tests/neg/i3901.scala

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
object Crash {
2+
def f(cond: => Boolean): cond.type = ??? // error: cond is not stable
3+
f(true)
4+
}

0 commit comments

Comments
 (0)