Skip to content

Fix #10082: show friendly error message related to type inference #10100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions compiler/src/dotty/tools/dotc/typer/Inferencing.scala
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,8 @@ trait Inferencing { this: Typer =>
// found : Int(1)
// required: String
// val y: List[List[String]] = List(List(1))
val hasUnreportedErrors = state.reporter.hasUnreportedErrors
if state.reporter.hasUnreportedErrors then return tree

def constraint = state.constraint
type InstantiateQueue = mutable.ListBuffer[(TypeVar, Boolean)]
val toInstantiate = new InstantiateQueue
Expand All @@ -521,7 +522,7 @@ trait Inferencing { this: Typer =>
typr.println(i"interpolate non-occurring $tvar in $state in $tree: $tp, fromBelow = ${tvar.hasLowerBound}, $constraint")
toInstantiate += ((tvar, tvar.hasLowerBound))
}
else if (!hasUnreportedErrors)
else
if (v.intValue != 0) {
typr.println(i"interpolate $tvar in $state in $tree: $tp, fromBelow = ${v.intValue == 1}, $constraint")
toInstantiate += ((tvar, v.intValue == 1))
Expand Down
7 changes: 7 additions & 0 deletions tests/neg/i10082.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
object Kotlin:
def it[T](using t: T) = t
def fun[T, U](fn: T ?=> U)(x: T): U = fn(using x)

import Kotlin.{fun, it}

def Test = List(1).map(fun(it + 1)) // error
8 changes: 4 additions & 4 deletions tests/neg/i9568.check
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
-- Error: tests/neg/i9568.scala:13:10 ----------------------------------------------------------------------------------
13 | blaMonad.foo(bla) // error: diverges
| ^
|no implicit argument of type => Monad[([_$3] =>> Any)] was found for parameter ev of method blaMonad in object Test.
|I found:
| no implicit argument of type => Monad[F] was found for parameter ev of method blaMonad in object Test.
| I found:
|
| Test.blaMonad[Nothing, S](Test.blaMonad[F, S])
| Test.blaMonad[Nothing, S](Test.blaMonad[F, S])
|
|But method blaMonad in object Test does not match type => Monad[Nothing].
| But method blaMonad in object Test does not match type => Monad[Nothing].