bugKawa - Bugs: bug #36853, Propagate type parameters


bug #36853: Propagate type parameters

Submitted by:  Helmut Eller <ellerh>
Submitted on:  Mon Jul 16 15:12:07 2012  
Category: Type declaration and inferenceSeverity: 3 - Normal
Item Group: Feature RequestStatus: Fixed
Privacy: PublicAssigned to: Per Bothner <bothner>
Open/Closed: Open

Add a New Comment (Rich MarkupRich Markup):

You are not logged in

Please log in, so followups can be emailed to you.


Tue Jul 17 19:48:06 2012, comment #5:

The problem in the example in comment #4 doesn't seem to be related to type parameters. Note there are no warnings if the function f is inlined.

The problem is that call to f first "validates" (type-checks) the function (i.e. the lambda) before validating the arguments. Usually, that's what you want, so you can type-check the actual argument using the specified type of the formal parameter. But if the formal parameter does't have type specifier, then you'd like to validate the actual argument, and infer the parameter type from that. In principle this shouldn't be too hard, at least when there is only a single call site, but re-factoring the code to support that looks tricky. Another complication is that the same pass also check things like if a variable is initialized, which makes doing things in the right order even more difficult.

Per Bothner <bothner>
Project AdministratorIn charge of this item.
Tue Jul 17 11:23:18 2012, comment #4:

Here's a variation that still has problems:

Helmut Eller <ellerh>
Tue Jul 17 08:09:29 2012, comment #3:

I was thinking more in the line of:
class Foo<E extends java.util.List> ...

... Foo[vector] ...

I.e. using super or extends.

Your example doesn't report any warnings when I tried it. Perhaps because it (as far as I can tell) doesn't use wildcards.

Having wildcard work is probably not a priority.

Per Bothner <bothner>
Project AdministratorIn charge of this item.
Tue Jul 17 07:57:15 2012, comment #2:

>The code doesn't support wildcards yet. Perhaps you could come
>with some testcases using wildcards?

You mean something like this?

Helmut Eller <ellerh>
Tue Jul 17 06:48:44 2012, comment #1:

I checked in a fix for this, as well as your test case.

The code doesn't support wildcards yet. Perhaps you could come up with some testcases using wildcards?

Per Bothner <bothner>
Project AdministratorIn charge of this item.
Mon Jul 16 15:12:07 2012, original submission:

This example:

generates this warning:

It would be nice if the compiler would automatically infer that the
type of iter is Iterator[String] and consequently the type of next is

Helmut Eller <ellerh>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -unavailable- added by bothner (Posted a comment)
  • -unavailable- added by ellerh (Submitted the item)

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.


    Please enter the title of George Orwell's famous dystopian book (it's a date):



    Follow 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue Jul 17 06:48:44 2012bothnerStatusNone=>Fixed
      Assigned toNone=>bothner

    Back to the top

    Powered by Savane 3.1-cleanup1