Subject: weirdness in typechecking call on overloaded java method - msg#00099
List: lang.scala
Hi,
I've stumbled upon a typing issue I'm at a loss to explain. Following is a minimal test case:
---------------------------------------------
// ScalaMenuTest.scala
object ScalaMenuTest {
def main(args: Array[String]): Unit = {
val v = new javax.swing.JMenu()
v.add(new javax.swing.JMenuItem())
//v.add(new java.awt.PopupMenu());
}
}
//==> compiling with scalac2 results in
//
// found : javax.swing.JMenuItem
// required: java.awt.PopupMenu
// v.add(new javax.swing.JMenuItem())
// ^
//one error found
---------------------------------------------
As a sanity check, here is the equivalent Java code:
---------------------------------------------
// JavaMenuTest.java
class JavaMenuTest {
public static void main(String[] args) {
javax.swing.JMenu v = new javax.swing.JMenu();
v.add(new javax.swing.JMenuItem());
//v.add(new java.awt.PopupMenu());
}
}
---------------------------------------------
I'd greatly appreciate if someone could verify; perhaps it's a
environment-related issue on my end?? If not, is it perhaps a compiler bug?
What I find truly bizarre is that if
the call adding a PopupMenu is uncommented, it then typechecks just
fine.
Many thanks,
Jason
Was this page helpful?
Thread at a glance:
Previous Message by Date:
click to view message preview
Re: gadt
Niels Hoogeveen wrote:
I'm trying to toy around with Scala2 within Eclipse, but I can's seem to find a
proper way to set the -Xgadt flag, any suggestions?
If you want to play with GADT's there is acturaly no need to change the
flag. Gadts are already enabled for function paramters in Scala 2. The -
Xgadt flag enables them also for class constructor parameters, but this
is not working completely right now.
Cheers
-- Martin
Next Message by Date:
click to view message preview
Re: weirdness in typechecking call on overloaded java method
"Jason Kinzer" <jmkinzer@xxxxxxxxx> writes:
> I've stumbled upon a typing issue I'm at a loss to explain. Following is a
> minimal test case:
>
> ---------------------------------------------
> // ScalaMenuTest.scala
> object ScalaMenuTest {
> def main(args: Array[String]): Unit = {
> val v = new javax.swing.JMenu()
> v.add(new javax.swing.JMenuItem())
> //v.add(new java.awt.PopupMenu());
> }
> }
>
> //==> compiling with scalac2 results in
> //
> // found : javax.swing.JMenuItem
> // required: java.awt.PopupMenu
> // v.add(new javax.swing.JMenuItem())
> // ^
> //one error found
> ---------------------------------------------
There have been problems like this, but your example compiles for
me using version 2.0.5843 and 2.0.5774 . Can you check your
version (scalac -version), and upgrade if it is older than these?
Otherwise, maybe it is environmental. I am using a 1.5 Sun SDK.
-Lex
Previous Message by Thread:
click to view message preview
gadt
I'm trying to toy around with Scala2 within Eclipse, but I can's seem to find a
proper way to set the -Xgadt flag, any suggestions?
k.r.
Niels
Next Message by Thread:
click to view message preview
Re: weirdness in typechecking call on overloaded java method
"Jason Kinzer" <jmkinzer@xxxxxxxxx> writes:
> I've stumbled upon a typing issue I'm at a loss to explain. Following is a
> minimal test case:
>
> ---------------------------------------------
> // ScalaMenuTest.scala
> object ScalaMenuTest {
> def main(args: Array[String]): Unit = {
> val v = new javax.swing.JMenu()
> v.add(new javax.swing.JMenuItem())
> //v.add(new java.awt.PopupMenu());
> }
> }
>
> //==> compiling with scalac2 results in
> //
> // found : javax.swing.JMenuItem
> // required: java.awt.PopupMenu
> // v.add(new javax.swing.JMenuItem())
> // ^
> //one error found
> ---------------------------------------------
There have been problems like this, but your example compiles for
me using version 2.0.5843 and 2.0.5774 . Can you check your
version (scalac -version), and upgrade if it is older than these?
Otherwise, maybe it is environmental. I am using a 1.5 Sun SDK.
-Lex