Skip to content
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

type inference fails with @remote annotation #150

Closed
scabug opened this issue Oct 3, 2007 · 3 comments
Closed

type inference fails with @remote annotation #150

scabug opened this issue Oct 3, 2007 · 3 comments
Assignees

Comments

@scabug
Copy link

scabug commented Oct 3, 2007

The code below

import java.rmi.Remote
import java.rmi.server.UnicastRemoteObject

import scala.runtime.ObjectRef

@remote
trait RemoteObjectRef { // extends Remote {
  def elem: ObjectRef
}

class RemoteObjectRefImpl(x: ObjectRef)
extends UnicastRemoteObject with RemoteObjectRef {
  def elem: ObjectRef = x
  override def toString() = x.toString()
}

object test extends Application {

  def bind(x: Remote): Remote = {
    println("RemoteRef.bind (Remote)"); x
  }

  def bind(x: RemoteObjectRef): RemoteObjectRef = {
    println("bind (RemoteObjectRef)"); x
  }

  bind(new RemoteObjectRefImpl(new ObjectRef()))
}

produces the following type error:

test.scala:27: error: ambiguous reference to overloaded definition,
both method bind in object test of type (RemoteObjectRef)RemoteObjectRef
and  method bind in object test of type (java.rmi.Remote)java.rmi.Remote
match argument types (RemoteObjectRefImpl)
  bind(new RemoteObjectRefImpl(new ObjectRef()))
  ^
one error found

but it compiles fine if you replace

@remote
trait RemoteObjectRef { def elem: ObjectRef }

by

trait RemoteObjectRef extends Remote { def elem: ObjectRef }
@scabug
Copy link
Author

scabug commented Oct 3, 2007

Imported From: https://issues.scala-lang.org/browse/SI-150?orig=1
Reporter: @michelou

@scabug
Copy link
Author

scabug commented Nov 11, 2007

@odersky said:
That's completely as speced. @Remote is not the same as `extends Remote' for the type checker.

@scabug
Copy link
Author

scabug commented Jan 14, 2009

@odersky said:
Milestone 2.6.1 deleted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants