Skip to content

Instantly share code, notes, and snippets.

@ktoso
Last active August 29, 2015 14:07
Show Gist options
  • Save ktoso/6e3bfce6d13ef6dd35cc to your computer and use it in GitHub Desktop.
Save ktoso/6e3bfce6d13ef6dd35cc to your computer and use it in GitHub Desktop.
IntelliJ 14 EAP 139.1.20 has problems to understand a Scala generated static bridge method. While javac is perfectly happy with it
package com.example;
public class Problem {
{
Thing<String> x1 = ThingJava.make(); // expected, works
Thing<String> x2 = ThingScala.make(); // false red code, is also a static method, java's inference should work
// Javac is happy with this and compiles properly, yet idea panics with:
// Incompatible types:
// Found: Thing<Object>
// Expected: Thing<String>
}
}
class ThingJava {
public static <T> Thing<T> make() {
return new Thing<T>();
}
}
$ javap Thing
Compiled from "Thing.scala"
public class com.example.Thing extends java.lang.Object{
public static com.example.Thing make();
public com.example.Example();
}
package com.example
class Thing[T]
object ThingScala {
def make[T]() = new Thing[T] // as this is a comapnion object of Thing, it will generate static bridge methodsin class Thing
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment