2.8.0 - "method defined twice"

Hi all,

The following code is rejected in 2.8.0 with "method gettype is defined twice". I'm using the maven snapshot builds, so they should be pretty recent.

def gettype(tpe : Type) : nodes.Type = gettype_inner(tpe)
def gettype(tree : Tree) : nodes.Type = gettype_inner(tree.tpe)

This is definitely supported in Java, and I thought it worked with some other Scala code I had...

Thanks in advance,
Nicholas
https://ntung.com

Re: 2.8.0 - "method defined twice"

Nicholas Tung wrote:
> Hi all,
>
> The following code is rejected in 2.8.0 with "method gettype is
> defined twice". I'm using the maven snapshot builds, so they should be
> pretty recent.
>
> def gettype(tpe : Type) : nodes.Type = gettype_inner(tpe)
> def gettype(tree : Tree) : nodes.Type = gettype_inner(tree.tpe)
>
> This is definitely supported in Java, and I thought it worked with
> some other Scala code I had...

Overloading isn't possible if Type and Tree are erased to the same type.

There is no problem with the following:-

object nodes { type Type = Int }

abstract class TypeBase
abstract class TreeBase

class C {
type Type <: TypeBase
type Tree <: TreeBase

def gettype(tpe : Type) : nodes.Type = error("")
def gettype(tree : Tree) : nodes.Type = error("")
}

Re: Re: 2.8.0 - "method defined twice"

Btw, I always liked the fact that the return type is part of the method signature in the VM. The following compiles and works fine (just as in Java):
 class X {   def a(list: List[Int]): Number = 5    def a(list: List[Double]): AnyRef = null }
2009/7/30 Eric Willigers <ewilligers [at] gmail [dot] com>
Nicholas Tung wrote:
Hi all,

  The following code is rejected in 2.8.0 with "method gettype is defined twice". I'm using the maven snapshot builds, so they should be pretty recent.

def gettype(tpe : Type) : nodes.Type = gettype_inner(tpe)
def gettype(tree : Tree) : nodes.Type = gettype_inner(tree.tpe)

  This is definitely supported in Java, and I thought it worked with some other Scala code I had...

Overloading isn't possible if Type and Tree are erased to the same type.

There is no problem with the following:-

object nodes { type Type = Int }

abstract class TypeBase
abstract class TreeBase

class C {
   type Type <: TypeBase
   type Tree <: TreeBase

   def gettype(tpe : Type) : nodes.Type = error("")
   def gettype(tree : Tree) : nodes.Type = error("")
}


Copyright © 2013 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland