Skip to content

Commit 23cb435

Browse files
authored
Merge pull request #7771 from dotty-staging/fix-#7746
Fix #7746: Turn assertion into error
2 parents 443867f + b7520aa commit 23cb435

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,10 +1104,9 @@ class Typer extends Namer
11041104
TypeTree(targetTpe)
11051105
case _ =>
11061106
if (mt.isParamDependent)
1107-
throw new java.lang.Error(
1107+
errorTree(tree,
11081108
i"""internal error: cannot turn method type $mt into closure
1109-
|because it has internal parameter dependencies,
1110-
|position = ${tree.span}, raw type = ${mt.toString}""") // !!! DEBUG. Eventually, convert to an error?
1109+
|because it has internal parameter dependencies""")
11111110
else if ((tree.tpt `eq` untpd.ContextualEmptyTree) && mt.paramNames.isEmpty)
11121111
// Note implicitness of function in target type since there are no method parameters that indicate it.
11131112
TypeTree(defn.FunctionOf(Nil, mt.resType, isContextual = true, isErased = false))

tests/neg/i7746.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class A {
2+
def foo = (x : Int, y => x) => () // error // error
3+
}

tests/pending/neg/i7749.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
trait A {
2+
def foo = 4
3+
}
4+
object B extends A {
5+
private[this] def foo = 0
6+
}

0 commit comments

Comments
 (0)