-
Notifications
You must be signed in to change notification settings - Fork 1k
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
undefined
error if enable coverage
#21695
Comments
Scala CLI example, for convenience: //> using options -coverage-out:coverage-out
//> using dep io.grpc:grpc-services:1.68.0
import io.grpc.Server
import io.grpc.ServerBuilder
import io.grpc.ServerInterceptors
import io.grpc.ServerServiceDefinition
import io.grpc.protobuf.services.ProtoReflectionService
import io.grpc.util.TransmitStatusRuntimeExceptionInterceptor
object MyServer {
def createServer(
port: Int,
services: List[ServerServiceDefinition]
): Server = {
services
.foldLeft(ServerBuilder.forPort(port))((builder, service) =>
builder.addService(
ServerInterceptors.intercept(
service,
TransmitStatusRuntimeExceptionInterceptor.instance()
)
)
)
.addService(ProtoReflectionService.newInstance())
.build()
}
} BTW it's not actually a compiler crash, we get an actual (if cryptic) error. |
package example;
public abstract class Builder<T extends Builder<T>> {
public abstract String build();
public abstract T addService(Service service);
}
package example;
public class Service{}
package example
trait A {
def x1: Builder[?]
def x2: Service
def create: String =
x1.addService(x2).build()
}
|
The error is procduced in Line 170 of ErrorReporting.scala: def takesNoParamsMsg(tree: Tree, kind: String): Message =
if (tree.tpe.widen.exists)
em"${exprStr(tree)} does not take ${kind}parameters"
else {
em"undefined: $tree # ${tree.uniqueId}: ${tree.tpe.toString} at ${ctx.phase}"
} That happens if something that gets applied does not have a valid type (which should not happen). We can try to improve the error message to explain this. But it would be better to figure out who produced this tree without a valid type. Looking at the stacktrace after -Xprompt would help. |
Compiler version
Minimized code
build.sbt
MyServer.scala
Output (click arrow to expand)
The text was updated successfully, but these errors were encountered: