Wrong compiler error message while using contextual functions
See original GitHub issueCompiler version
Example is at 3.0.0 but the problem still exists for the newest master (commit b3ade17
)
Minimized code
class I:
def runSth: Int = 1
abstract class A:
def myFun(op: I ?=> Unit) =
op(using I())
1
class B extends A
@main def hello: Unit =
B().myFun {
val res = summon[I].runSth
org.junit.Assert.assertEquals("", 1, res, "asd")
// org.junit.Assert.assertEquals("", 1, res)
println("Hello!")
}
Output
[error] -- Error: /home/aratajczak/Dokumenty/Praca/Scala/compiler-bug/src/main/scala/Main.scala:14:23
[error] 14 | val res = summon[I].runSth
[error] | ^
[error] |no implicit argument of type I was found for parameter x of method summon in object Predef
[error] one error found
[error] one error found
[error] (Compile / compileIncremental) Compilation failed
[error] Total time: 0 s, completed 25 cze 2021, 16:08:49
Expectation
Error should point to wrong assertEquals
dispatch instead of no implicit argument of type I
.
However, if we change commented line, Program succeedes
[info] running hello
Hello!
[success] Total time: 0 s, completed 25 cze 2021, 16:09:29
I think it only exists for calling Java
functions, however for scala function it returns BOTH no implicit
and None of the overloaded alternatives of method assertEquals in object Assert with types
errors which is somehow more correct. I’ll link clean repo with reproduction.
Issue Analytics
- State:
- Created 2 years ago
- Comments:11 (8 by maintainers)
Top Results From Across the Web
Understanding and fixing compiler and linker errors
How to fix common compiler and linker errors in C++.
Read more >c# - Wrong overload giving compiler error - Stack Overflow
In each case, it seems that the compiler becomes unable to determine which overload to use when it is being passed a reference...
Read more >On Compiler Error Messages: What They Say and ... - Hindawi
In this paper, we focus on compiler error messages. First, related literature is reviewed and the problem placed in the context of the...
Read more >Compiler Error C2672 - Microsoft Learn
In this article The compiler could not find an overloaded function that matches the specified function. No function was found that takes ...
Read more >SML/NJ Error Messages
This error message indicates how the parser attempted to "repair" the input (from a file foo.sml), and in this case indicates that the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Was exp:intermediate a joke?
Further minimized without the junit dependency: