Preserve type inference when errors exist in Scala source file

98 views
Skip to first unread message

virtualeyes

unread,
Oct 21, 2012, 8:22:41 AM10/21/12
to Scala IDE User
This may be a difficult problem to solve, but one event that annoys me
daily is, while hacking out some test code block (e.g. to figure out
why another piece of code is not working), type inference (that is,
hover cursor over class/property/method and see type information)
vanishes, and I then have to comment out/get working any errors in the
source file before type inference returns (sometimes I have to close/
re-open the file)

If this is a Juno issue let me know. Also, if it's just the way it is,
let me know, can live with it ;-)

Simon Schäfer

unread,
Oct 21, 2012, 9:17:24 AM10/21/12
to scala-i...@googlegroups.com
Can you provide a code example to show what is not working? I can't
follow your text in detail.

virtualeyes

unread,
Oct 22, 2012, 2:14:21 AM10/22/12
to Scala IDE User
Silly example, but you get the point:
val test = 1
1.flatMap{_.toString} // error
val list = List(1,2,3) // hover cursor over "list", no type info
displays

In fact, no type information displays anywhere in the source file
until error(s) are resolved.

Juno, Java 7, Scala IDE latest (yesterday's nightly)

Am curious to know if others are experiencing the same...

Mirco Dotta

unread,
Oct 22, 2012, 3:03:44 AM10/22/12
to scala-i...@googlegroups.com
val test = 1
1.flatMap{_.toString} // error
val list = List(1,2,3) // hover cursor over "list", no type info

This works for me on Indigo + latest Scala IDE 2.10 nightly. Are you on 2.9? Otherwise it looks like a Juno issue...

-- Mirco
---------------
Mirco Dotta
Typesafe - The software stack for applications that scale
PSE-D, 1015 Lausanne, Switzerland
Twitter: @mircodotta








iulian dragos

unread,
Oct 22, 2012, 6:40:41 AM10/22/12
to scala-i...@googlegroups.com
On Mon, Oct 22, 2012 at 8:14 AM, virtualeyes <sit...@gmail.com> wrote:
Silly example, but you get the point:
val test = 1
1.flatMap{_.toString} // error
val list = List(1,2,3) // hover cursor over "list", no type info
displays

In fact, no type information displays anywhere in the source file
until error(s) are resolved.

Juno, Java 7, Scala IDE latest (yesterday's nightly)

Am curious to know if others are experiencing the same...

Works for me in Indigo with 2.9, and also in Juno. Note that if you have too many errors, the compiler can't really infer much anymore.

Do you know about Show Type? Might be useful if you need to debug type errors this way (http://scala-ide.org/docs/helium/features/show-type.html)

iulian
 


On Oct 21, 3:17 pm, Simon Schäfer <m...@antoras.de> wrote:
> Can you provide a code example to show what is not working? I can't
> follow your text in detail.
>
> On Sun 21 Oct 2012 02:22:41 PM CEST, virtualeyes wrote:
>
>
>
>
>
>
>
> > This may be a difficult problem to solve, but one event that annoys me
> > daily is, while hacking out some test code block (e.g. to figure out
> > why another piece of code is not working), type inference (that is,
> > hover cursor over class/property/method and see type information)
> > vanishes, and I then have to comment out/get working any errors in the
> > source file before type inference returns (sometimes I have to close/
> > re-open the file)
>
> > If this is a Juno issue let me know. Also, if it's just the way it is,
> > let me know, can live with it ;-)



--
« Je déteste la montagne, ça cache le paysage »
Alphonse Allais

virtualeyes

unread,
Oct 23, 2012, 4:58:31 AM10/23/12
to Scala IDE User
It can actually happen without errors as well (although errors in
source file will effectively guarantee it)

Code ahead, type inference, everything goes.

I then have to project clean and/or close & re-open the source file
before I can escape from blind coding.

Could be a Juno issue, I have no clue, just pointing it out.

If everyone else has rock solid consistent code ahead + type
inference, count me as envious...



On Oct 22, 12:41 pm, iulian dragos <jagua...@gmail.com> wrote:

iulian dragos

unread,
Oct 23, 2012, 7:13:47 AM10/23/12
to scala-i...@googlegroups.com
On Tue, Oct 23, 2012 at 10:58 AM, virtualeyes <sit...@gmail.com> wrote:
It can actually happen without errors as well (although errors in
source file will effectively guarantee it)

Code ahead, type inference, everything goes.

I then have to project clean and/or close & re-open the source file
before I can escape from blind coding.

Could be a Juno issue, I have no clue, just pointing it out.

If everyone else has rock solid consistent code ahead + type
inference, count me as envious...

Are you on 2.10? That sounds like a crash in the presentation compiler. Check your Error Log window for suspicious messages, I'm pretty sure you'll find something (just to double check: if the outline view is empty, it's a sure sign of such a crash).

iulian

virtualeyes

unread,
Oct 23, 2012, 9:06:40 AM10/23/12
to Scala IDE User
No, 2.9.2

Outline view is fine.

Could be Juno, could be incremental builds with Play 2 Scala, SBT...

I'll setup Indigo when I get the chance and see what the performance
differences are...

Thanks (semantic highlighting works great, btw, hung thread issue
seems to be gone ;-))


On Oct 23, 1:14 pm, iulian dragos <jagua...@gmail.com> wrote:

iulian dragos

unread,
Oct 23, 2012, 9:27:54 AM10/23/12
to scala-i...@googlegroups.com
On Tue, Oct 23, 2012 at 3:06 PM, virtualeyes <sit...@gmail.com> wrote:
No, 2.9.2

Outline view is fine.

Could be Juno, could be incremental builds with Play 2 Scala, SBT...

I'll setup Indigo when I get the chance and see what the performance
differences are...

Thanks (semantic highlighting works great, btw, hung thread issue
seems to be gone ;-))

At least one good news.. :)

Clint Gilbert

unread,
Oct 23, 2012, 4:11:27 PM10/23/12
to scala-i...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 10/23/2012 04:58 AM, virtualeyes wrote:
> If everyone else has rock solid consistent code ahead + type
> inference, count me as envious...

You're not alone. :( Not infrequently, my Eclipse will get into a
state where it can't show the types of expressions or vals, and can't
offer crtl-space suggestions. (I'm using Juno, so maybe the joke's on
me for that reason.)

The upside, I suppose, is that when types are available, they're
correct. Just today, my IntelliJ-using coworker experienced a
situation where his IDE was "successfully" inferring types, they were
just wrong.
>> -- � Je d�teste la montagne, �a cache le paysage � Alphonse
>> Allais

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://www.enigmail.net/

iEYEARECAAYFAlCG+e8ACgkQ5IyIbnMUeTuO2ACeNI904Yf02MgFz8iYfzqNP80h
FBEAn1SR7QJNzFzmjKwKV93Fgk+mQ5qn
=kwKV
-----END PGP SIGNATURE-----
Reply all
Reply to author
Forward
0 new messages